onPlayerKeyPress problem

Need advices or help troubleshooting? Ask for help here.
Post Reply
wbty
Posts: 9
Joined: September 7th, 2018, 2:17 pm

onPlayerKeyPress problem

Post by wbty » September 7th, 2018, 2:29 pm

Hi,
I need a little help with this, does anyone know correct way to detect player keys?
I already made something but I got error

Code: Select all

Event onPlayerKeyPress: attempt to call a number value

Armelin

Re: onPlayerKeyPress problem

Post by Armelin » September 7th, 2018, 7:50 pm

Thanks for reporting this bug and a solution will be uploaded on our Bitbucket downloads page.

Here is an example anyway

Code: Select all

function keyHook(playerId, virtualKey, isKeyUp)
	local i = 0
	if isKeyUp then i = 1 end
	sendPlayerMsg(playerId, "Key " .. virtualKey .. " status: " .. i, 0xFFFF0000)
end
registerEvent("keyHook", "onPlayerKeyPress")


function playerSpawnCredentials(playerid)
	--Whatever code you wanna have here
	
	setPlayerKeyHook(playerid, 0x41, true) -- 0x41 is the A key
end
registerEvent("playerSpawnCredentials", "onPlayerCredential")

wbty
Posts: 9
Joined: September 7th, 2018, 2:17 pm

Re: onPlayerKeyPress problem

Post by wbty » September 7th, 2018, 10:55 pm

Thanks, it works. That was very quick fix you guys are awesome.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests