onPlayerKeyPress problem

Need advices or help troubleshooting? Ask for help here.
Post Reply
wbty
Posts: 9
Joined: Fri Sep 07, 2018 7:17 pm

onPlayerKeyPress problem

Post by wbty » Fri Sep 07, 2018 7: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
Posts: 20
Joined: Sun Jul 30, 2017 4:28 am

Re: onPlayerKeyPress problem

Post by Armelin » Sat Sep 08, 2018 12:50 am

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: Fri Sep 07, 2018 7:17 pm

Re: onPlayerKeyPress problem

Post by wbty » Sat Sep 08, 2018 3:55 am

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 1 guest