SA-MP Forums Archive
How to set time ? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to set time ? (/showthread.php?tid=185787)



How to set time ? - gunnrcrakr - 26.10.2010

I want to enable war = 1; when 10.00 o'clock every day and change to war = 0; 11.00 o'clock every day, how i do

(Sorry, I bad English language.)


Re: How to set time ? - Jochemd - 26.10.2010

GetPlayerTime or GetWorldTime in a one-minute timer would help you


Re: How to set time ? - gunnrcrakr - 26.10.2010

I don't understand, Can you help me ?


Re: How to set time ? - Simon - 26.10.2010

If you want it to be 10 o'clock real time (server time) then you could do this, you'll need to make some minor edits if you want it for ingame time:

pawn Код:
forward WarSync();

public OnGameModeInit()
{
    // Set a repeating timer to check the time every second for precision
    SetTimer("WarSync", 1000, true);
}

public WarSync()
{
    new
        hours,
        minutes,
        seconds;

    // Save the time into the variables.
    gettime(hours, minutes, seconds);
   
    // Check if the hour of the day is 10 o'clock.
    if (hours == 10)
        war = 1;
    else
        war = 0;
}
If you wanted it to be ingame time then you'd do a similar thing except you'd have to use SetWorldTime every hour (or however long you want an ingame hour to be ...), have a global variable and then set war = 1 when the hour is 0.


Re: How to set time ? - Jochemd - 26.10.2010

You can better do it as follwing:

pawn Код:
if(hour == 10 && minutes == 0)
{
    war = 1;
}
else if(hour == 11 && minutes == 0)
{
    war = 0;
}
Maybe it doesn't make a difference but it is better.


Re: How to set time ? - gunnrcrakr - 26.10.2010

Oh.. Thanks a lot