Keys loop 3 times on OnPlayerUpdate - 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: Keys loop 3 times on OnPlayerUpdate (
/showthread.php?tid=366590)
Keys loop 3 times on OnPlayerUpdate -
maxisaibot - 07.08.2012
When i press to left key, server giving 3 times "left" message. How can i fix this?
[06:13:15] LEFT
[06:13:15] LEFT
[06:13:15] LEFT
[06:13:16] LEFT
[06:13:16] LEFT
[06:13:16] LEFT
[06:13:18] RIGHT
[06:13:18] RIGHT
[06:13:18] RIGHT
Код:
public OnPlayerUpdate(playerid)
{
new Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
if(Keys == 0 && ud > 0)
{
SendClientMessage(playerid, 0xFFFFFFFF, "DOWN");
}
else if(Keys == 0 && ud < 0)
{
SendClientMessage(playerid, 0xFFFFFFFF, "UP");
}
else if(Keys == 0 && lr > 0)
{
SendClientMessage(playerid, 0xFFFFFFFF, "RIGHT");
}
else if(Keys == 0 && lr < 0)
{
SendClientMessage(playerid, 0xFFFFFFFF, "LEFT");
}
...
Re: Keys loop 3 times on OnPlayerUpdate -
Jikesh - 07.08.2012
How about you use
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Re: Keys loop 3 times on OnPlayerUpdate -
shitbird - 07.08.2012
What are you trying to fix? :S
OnPlayerUpdate is called
20 times in a second. Quite frankly, I'm surprised you're not being spammed more than this.
Re: Keys loop 3 times on OnPlayerUpdate -
maxisaibot - 07.08.2012
Quote:
Originally Posted by Jikesh
|
Код:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
if(newkeys & KEY_DOWN == (KEY_DOWN)) not working
PRESSED(KEY_FIRE) not working
Left, right, up, down keys not working on my script.
Quote:
Originally Posted by shitbird
OnPlayerUpdate is called 20 times in a second. Quite frankly, I'm surprised you're not being spammed more than this.
|
Thanks for info
Quote:
Originally Posted by shitbird
What are you trying to fix? :S
|
So may i should using timer or check script ?