Keys loop 3 times on OnPlayerUpdate
#1

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");
	}
...
Reply
#2

How about you use https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#3

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.
Reply
#4

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 ?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)