Liberty Unleashed
Scripting => Script Help => Topic started by: sseebbyy on August 09, 2013, 08:19:41 am
-
I need to use onPlayerKeyStateChange, but the wiki doesn't show anything about it, just that it exist.
I'm trying to add info when a player press some buttons.
This is how I did:
if(newkeys && "Y") {
But it is not working... and when I press a moveable key of ped, the info appears.
How to fix it ?
( here I use server-side script )
-
onPlayerKeyStateChange only detects GTA's control keys, and it can't be used to detect other keys. For that you'll want to use client-side key binds (BindKey etc.)
The parameters for onPlayerKeyStateChange are a player pointer and two integers, oldkeys and newkeys. These show the current and previous states of the player's GTA controls. For example, if you want to detect whether the fire key was pressed (you can find a list of key constants here (http://liberty-unleashed.co.uk/LUWiki/Squirrel/Server/Constants#GTA_Keys))
function onPlayerKeyStateChange( player, oldkeys, newkeys )
{
if ( ( oldkeys & KEY_ONFOOT_FIRE == 0 ) && ( newkeys & KEY_ONFOOT_FIRE != 0 ) )
{
MessagePlayer( "Fire key pressed", player );
}
return 1;
}
Didn't actually test it but it should give you the right idea.
-
hhmm, I got it somehow, thank you !