SA-MP Forums Archive
Help getting total time paused - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help getting total time paused (/showthread.php?tid=359092)



Help getting total time paused - Mishima - 12.07.2012

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.


Re: Help getting total time paused - [MM]RoXoR[FS] - 13.07.2012

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.


Re: Help getting total time paused - Mishima - 13.07.2012

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.


Re: Help getting total time paused - [MM]RoXoR[FS] - 13.07.2012

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]++;



Re: Help getting total time paused - Mishima - 13.07.2012

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