How to set time ?
#1

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.)
Reply
#2

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

I don't understand, Can you help me ?
Reply
#4

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.
Reply
#5

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.
Reply
#6

Oh.. Thanks a lot
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)