OnPlayerUpdate bug!!!
#1

WTF!! I putted this code:

pawn Код:
public OnPlayerUpdate(playerid)
{
    if (PlayerToPoint(2.0, playerid, 1750.0591,-1592.9020,13.5422))
    {
    SendClientMessage(playerid, 0x00FF00FF, "SPRUNK MACHINE: Drink by pressing F one time");
    }
  return 1;
}
And when i get near the coord, it spams me with SPRUNK MACHINE: Drink by pressing F one time
Reply
#2


yes, because OnPlayerUpdate resume after one second
pawn Код:
public OnPlayerUpdate(playerid)
{
new xtr[MAX_PLAYERS]=0;
    if (PlayerToPoint(2.0, playerid, 1750.0591,-1592.9020,13.5422))
    {
    if(xtr[playerid]==0)
    {
    xtr[playerid]++;
    SendClientMessage(playerid, 0x00FF00FF, "SPRUNK MACHINE: Drink by pressing F one time");
    }
    }else xtr[playerid]=0;
  return 1;
}
Reply
#3

OnPlayerUpdate is called everytime you move your mouse, keyboard or type a message
Reply
#4

Also:
Lose health, gain health, switch weapon(?), many more.
Reply
#5

so every time i need to use OnPlayerUpdate i will have to use this xtr thingy?

EDIT: Farse, i used your code and it still shows many messages!
Reply
#6

Don't use OnPlayerUpdate at all unless you want your whole server to lagg.

Quote:
Important note: This callback is valid from SA-MP 0.2X, it does not work in earlier releases!
Important note: Remember! This callback is called VERY frequently! Avoid having a lot of code in it!
Reply
#7

thanks for info but tell me other way to show this message when he is near this coord instead of using OnPlayerUpdate then!!!!!!!!!

I tried OnPlayerStateChange but the message didn't appear at all!
Reply
#8

pawn Код:
new nearsprunk[MAX_PLAYERS];
public OnPlayerUpdate(playerid)
{
    if (!(PlayerToPoint(2.0, playerid, 1750.0591,-1592.9020,13.5422)))
    {
        nearsprunk[playerid]=true;
        return 1;
    }
   
    if(nearsprunk[playerid])
    {
        SendClientMessage(playerid, 0x00FF00FF, "SPRUNK MACHINE: Drink by pressing F one time");
        nearsprunk[playerid]=false;
    }
    return 1;
}
This should work
Reply
#9

The code you posted even spams the chat without getting near the place!!
Reply
#10

Whoops, made a silly mistake. Try now
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)