Diretional keys Problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Diretional keys Problem (
/showthread.php?tid=174399)
Diretional keys Problem -
CyNiC - 05.09.2010
I'm trying to detect the directional keys and can not.
I read something about my OS is windows vista but nothing concrete, then I wonder what is happening.
pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
new string[20];
format(string,20,"KEY: %d OLDKEY: %d",newkeys,oldkeys);
SendClientMessage(playerid,Sistema,string);
if(newkeys & KEY_RIGHT)
{
if(GetPlayerSelState(playerid) > 0)
SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)+1);
else
return 1;
}
if(newkeys & KEY_LEFT)
{
if(GetPlayerSelState(playerid) > 0)
SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)-1);
else
return 1;
}
return 1;
}
I made debug, and when press the diretional keys, nothing happens, while the others wwere send via client message.
Re: Diretional keys Problem -
[XST]O_x - 05.09.2010
https://sampwiki.blast.hk/wiki/GetPlayerKeys
pawn Код:
public OnPlayerUpdate(playerid)
{
new Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
if(lr > 0)
{
if(GetPlayerSelState(playerid) > 0)
SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)+1);
else
return 1;
}
if(lr < 0)
{
//etc
return 1;
}
return 1;
}
Re: Diretional keys Problem -
CyNiC - 05.09.2010
Thanks ****** and O_x, i was tried use GetPlayerKeys in the OnPlayerKeyStateChange, but i will try again.
EDIT: No sucess, now i will try using the OnPlayerUpdate.
pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
new string[20];
new keys,ud,lr;
GetPlayerKeys(playerid,keys,ud,lr);
format(string,20,"UD: %d LR: %d",ud,lr);
SendClientMessage(playerid,Sistema,string);
if(lr == KEY_RIGHT)
{
if(GetPlayerSelState(playerid) > 0)
SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)+1);
else
return 1;
}
else if(lr == KEY_LEFT)
{
if(GetPlayerSelState(playerid) > 0)
SetPlayerSelectionID(playerid,GetPlayerSelectionID(playerid)-1);
else
return 1;
}
return 1;
}
EDIT 2: In the OnPlayerUpdate works, i want use in the KeyStateChange but looks impossible.