Help getting total time paused
#1

Hello guys Im trying to make a pausing sustem to detect the ammount of time that a player is paused, the ammount of minutes to be more precise.

I tried to search but I had no success so I decided to post here.

I have this at the moment.


pawn Код:
new bool:Pausing[MAX_PLAYERS];
new lastupdate[MAX_PLAYERS];
public OnPlayerUpdate(playerid)
{
    lastupdate[playerid] = GetTickCount();
    //Detecting the pause
    if(GetTickCount() > (lastupdate[i]+2000) )
    {
        SetPlayerChatBubble(i, "I'm Paused - Time:", 0x691107AA, 100.0, 1000);
    Pausing[i] = true;
    }
    else
    {
    Pausing[i] = false;
    }
    return 1;
}
I dont know if I should be using OnPlayerUpdate or not.
But yeah, what I want is to make it so the SetPlayerChatBubble shows the ammount of minutes that the player is paused.
Please help and thanks in advance.
Reply
#2

Make a global variable for time.
When Player Pause use SetTimerEx. and start increasing the value of global variable.

When he unpause, Kill the timer and use SendClientMessage.
Reply
#3

I think I did something, that is kinda.. working.
I have this piece of code.

minutes[playerid] = seconds[playerid]/60;
seconds[playerid] %= 60;

format(stringlolo,sizeof(stringlolo),"Paused - %d:%02d",minutes[playerid],seconds[playerid]);
Pausetext[playerid] = Create3DTextLabel(stringlolo,0x640000FF,X, Y, Z,15.0,0);
seconds[playerid]++;

Then
format(stringlolo,sizeof(stringlolo),"Paused - %d:%02d",minutes[playerid],seconds[playerid]);
Update3DTextLabelText(Pausetext[playerid],0x640000FF,stringlolo);
seconds[playerid]++;

But I have a little problem, when the seconds reach 60, the minutes go to 1 like normally, but when the seconds go to 1 again, the minutes go back to 0 and I dont know why.
I want it so the minutes show too, but it seems not to be working.

Somebody please help, thanks for your reply RoXor btw, it helped me.
Reply
#4

Try this
pawn Код:
if(seconds[playerid] > 59)
{
    ++minutes[playerid];
    seconds[playerid] = 0;
}
format(stringlolo,sizeof(stringlolo),"Paused - %d:%02d",minutes[playerid],seconds[playerid]);
Pausetext[playerid] = Create3DTextLabel(stringlolo,0x640000FF,X, Y, Z,15.0,0);
seconds[playerid]++;
Reply
#5

I was able to put it working, thanks man! ^^
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)