OnPlayerUpdate
#1

Hi,

i want to report a bug with OnPlayerUpdate:

If a player has a trailer attached to his vehicle and he is not moving, OnPlayerUpdate won't be called anymore.

I made a little script to test this (only working for playerid 0 if no other players are connected):

pawn Code:
new bool:afk = false;
public OnGameModeInit()
{
    SetGameModeText("Blank Script");
    SetTimer("AFKTimer", 1000, 1);
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

forward AFKTimer();
public AFKTimer()
{
    if (IsPlayerConnected(0))
    {
        if (afk)
            SendClientMessageToAll(0xFFFFFFAA, "AFK!");
        afk = true;
    }
}

public OnPlayerUpdate(playerid)
{
    afk = false;
    return 1;
}
Reply
#2

I don't see afk become true?
Reply
#3

Quote:
Originally Posted by Cypog
View Post
pawn Code:
public OnPlayerUpdate(playerid)
{
    afk = false;
    return 1;
}
OnPlayerUpdate is called every 60 ms... /facepalm.

pawn Code:
public OnPlayerUpdate(playerid)
{
    return 1;
}
Reply
#4

Quote:
Originally Posted by Joe_
View Post
I don't see afk become true?
Code:
forward AFKTimer();
public AFKTimer()
{
    if (IsPlayerConnected(0))
    {
        if (afk)
            SendClientMessageToAll(0xFFFFFFAA, "AFK!");
        afk = true;//Can you see it now?
    }
}
@TheHoodRat: Yes, and what is your problem now?

Anyway, this is just a test script. The thread is about the bug.
Reply
#5

pawn Code:
forward AFKTimer();
public AFKTimer()
{
    if (IsPlayerConnected(0)) // What is the "0" number?
    {
        if (afk)
            SendClientMessageToAll(0xFFFFFFAA, "AFK!");
        afk = true;
    }
}
Reply
#6

Quote:
Originally Posted by TheHoodRat
View Post
OnPlayerUpdate is called every 60 ms... /facepalm.

pawn Code:
public OnPlayerUpdate(playerid)
{
    return 1;
}
OnPlayerUpdate don't laggs if you don't have a lot of stuff there.
Reply
#7

he is saying OnPlayerUpdate is not called when your not moving and its not supposed to! all OnPlayerUpdate does is respond when a player is moving presses a key and so forth. If I may ask if your trying to detect if they have gone afk compare there old pos to there new if it is the same after so many checks set afk = true and if there not afk = false

@Basicz
the number represents playerid 0 so instead of making this global he made it for playerid 0 only but I dont get if its for player 0 only why is he sending the message to everyone ...
Reply
#8

I prefer SendClientMessageToAll when debugging.

Now, back to the topic:

I didn't say, that OnPlayerUpdate is not called, when he is not moving, cause it is.

But it is not called, when he is not pressing any keys (it doesn't matter if he is moving, he could be frozen) and he has attached a trailer to his vehicle, thats the point!

How I discovered this:
I made a script, where players have to drive to a filling station with tanker truck and petrol trailer.
When players start filling, they get frozen for 30 seconds. (But they can still exit the truck)
I also have an afk timer, which darkens the player color.
Guess, what will happen, when they start filling!
They are handled as being afk, even if they are not.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)