Display a timer +REP
#1

Hello fellas,
How can I create a GMX timer? I was trying to script the following command:
/gmx [Timer]
The main issue was that I want players to be able to view the timer somewhere around their screen(as a gametext)
and couldn't find a way to do so. How can I do so that players will be able to view an updating timer regarding the restart, and when it hits 0 the server will automatically restart?

Thanks for the helpers, +REPing.
Reply
#2

https://sampwiki.blast.hk/wiki/SetTimerEx

Using a timer of 1000 as interval and there in the timer you may display a gametext or textdraw.
Reply
#3

Quote:
Originally Posted by Gammix
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/SetTimerEx

Using a timer of 1000 as interval and there in the timer you may display a gametext or textdraw.
I know how to create a timer, the thing is that I don'tknow how to sync it with the command itself so it won't interrupt the GMX or alternatively happen at the same time(the GMX will take place will the timer is counting down)
Can you gimme some sort of an example and I'll re-vise it?
Reply
#4

for example:


Код:
new Time;

CMD:gmx(playerid,params[])
{
new seconds;
if(!sscanf(params,"i",seconds))
{
SetTimer("Timer",1000,true);
Time = seconds;
return 1;
}

forward Timer();
public timer()
{
	if(Time > 0)
	{
	    new string[50];
     	format(string,128,"%i seconds to restart.",Time);
        GameTextForAll(string,1000,3);
        Time--;
	}
	else SendRconCommand("gmx");
}
}
Not tested but try...
Reply
#5

pawn Код:
new tmrGMX;
new gGMXTick;

// When you start your GMX timer
// This part of code can be in your command
tmrGMX = SetTimer("OnServerRestarting", 1000, true);
gGMXTick = 10; // These are in seconds

// Declaring the timer
forward OnServerRestarting();
public    OnServerRestarting()
{
    gGMXTick--;
    if (gGMXTick == 0)
    {
        GameTextForAll("~g~Server restarted!", 1000, 0);
        KillTimer(tmrGMX);
       
        SendRconCommand("gmx");
    }
    else
    {
        new string[35];
        format(string, sizeof (string), "~r~Restart in %i...", gGMXTick);
        GameTextForAll(string, 1000, 0);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)