Question about timers/time
#1

I set that when its 00:00 all players get extra point for being in game at that time.

Question is, while I'm afk and I get 10 minutes after 00:00 message that I got point for being at 00:00 active.

So I'm afk, I should get message at 00:00 no matter what, but if I'm afk I will get message when I come ingame (in this example after 10 minutes I'll get at 00:10).

Any ideas?


PHP код:
new yearmonthdayhoursminutesseconds;
    
getdate(yearmonthday), gettime(hoursminutesseconds);
    if(
hours == && minutes == && seconds == 0)
    {
        foreach(
Playeri
        {
            
SendClientMessage(iCOLOR_NOTIFICATION"SERVER: Extra point for being online at {EEEEEE}00:00{F39746}.");
        }
    } 
This is under timer that is called every second.
Reply
#2

Just check if the player is paused or not when hours, minutes and seconds equals 0

pawn Код:
#define PAUSE_THRESHOLD_SECONDS \
    5

new g_PlayerLastUpdate[MAX_PLAYERS];

#define GetPlayerPausedTime(%0) \
    (gettime() - g_PlayerLastUpdate[%0])

#define IsPlayerPaused(%0) \
    (gettime() - g_PlayerLastUpdate[%0] > PAUSE_THRESHOLD_SECONDS)

public OnPlayerUpdate(playerid) {
    g_PlayerLastUpdate[playerid] = gettime();
    return 1;
}
Reply
#3

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
Just check if the player is paused or not when hours, minutes and seconds equals 0
This code should execute for all players that are online, no matter if they are afk or not.
Reply
#4

i'm pretty sure all messages sent to a paused player will be sent to them once they unpause.
Reply
#5

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
i'm pretty sure all messages sent to a paused player will be sent to them once they unpause.
Yes, they all get but when the message is send at chat, timestamp is showing it is sent at 00:10 or 00:12 or at the time the player come back from afk.
Reply
#6

So i guess we have figured out clientmessages work this way. Maybe you can use another solution, like textdraws that hide after a while?
Reply
#7

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
So i guess we have figured out clientmessages work this way. Maybe you can use another solution, like textdraws that hide after a while?
My first post when I posted code, that code worked for sending message when the player is not afk, or he gets back from afk.

The problem I want to fix is that if the player is afk at 00:00 he will get the same message as if he is not afk.
Reply
#8

The message gets sent once the player unpauses.
The timestamp contains the time when the message was sent.
You can't change this unfortunately.

But maybe there is another solution you can find instead?
Reply
#9

It's normal, it's not your code bug.
When players are afk they don't send packets and OnPlayerUpdate doesn't get called.
The message you send gets delivered once they come back.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)