Player Keys W,S,A,D - UP,DOWN,LEFT,RIGHT [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)
+--- Thread: Player Keys W,S,A,D - UP,DOWN,LEFT,RIGHT [Problem] (
/showthread.php?tid=497834)
Player Keys W,S,A,D - UP,DOWN,LEFT,RIGHT [Problem] -
Phil_Cutcliffe - 28.02.2014
When using this code it doesn't work when I'm pressing they keys.. I pressed buttons on my numpad and it worked. What am I doing wrong?
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if ((newkeys & KEY_UP) && !(oldkeys & KEY_UP))
{
PlayerMoving[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "You are moving!");
}
if ((newkeys & KEY_DOWN) && !(oldkeys & KEY_DOWN))
{
PlayerMoving[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "You are moving!");
}
if ((newkeys & KEY_LEFT) && !(oldkeys & KEY_LEFT))
{
PlayerMoving[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "You are moving!");
}
if ((newkeys & KEY_RIGHT) && !(oldkeys & KEY_RIGHT))
{
PlayerMoving[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "You are moving!");
}
if ((oldkeys & KEY_UP) && !(newkeys & KEY_UP))
{
if ((newkeys & KEY_UP) || (newkeys & KEY_DOWN) || (newkeys & KEY_LEFT) || (newkeys & KEY_RIGHT))
{
return 0;
}
else
{
PlayerMoving[playerid] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You stopped moving!");
}
}
if ((oldkeys & KEY_DOWN) && !(newkeys & KEY_DOWN))
{
if ((newkeys & KEY_UP) || (newkeys & KEY_DOWN) || (newkeys & KEY_LEFT) || (newkeys & KEY_RIGHT))
{
return 0;
}
else
{
PlayerMoving[playerid] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You stopped moving!");
}
}
if ((oldkeys & KEY_LEFT) && !(newkeys & KEY_LEFT))
{
if ((newkeys & KEY_UP) || (newkeys & KEY_DOWN) || (newkeys & KEY_LEFT) || (newkeys & KEY_RIGHT))
{
return 0;
}
else
{
PlayerMoving[playerid] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You stopped moving!");
}
}
if ((oldkeys & KEY_RIGHT) && !(newkeys & KEY_RIGHT))
{
if ((newkeys & KEY_UP) || (newkeys & KEY_DOWN) || (newkeys & KEY_LEFT) || (newkeys & KEY_RIGHT))
{
return 0;
}
else
{
PlayerMoving[playerid] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "You stopped moving!");
}
}