SA-MP Forums Archive
Getting a specific time to make something happen - 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: Getting a specific time to make something happen (/showthread.php?tid=473847)



Getting a specific time to make something happen - Twizted - 04.11.2013

So, I want a bot to appear when the time is 00:00. I know how to connect the bot, I'm just missing the knowledge on how to get the time and make the bot connect at 00:00.

Thanks in advance.


Re: Getting a specific time to make something happen - InglewoodRoleplay - 04.11.2013

Should be like this I guess:

pawn Код:
new Hour, Minute, Second;
gettime(Hour,Minute, Second);
if(Hour == 0) {
    /* Your code here */
}
In case you want it running every second, you would need to have it running under a timer.


Re: Getting a specific time to make something happen - iGetty - 04.11.2013

As InglewoodRoleplay said above:

pawn Код:
new Hour, Minute, Second;

public OnGameModeInit()
{
    gettime(Hour, Minute, Second);
    SetTimer("TimeGrab", 1000, true);
    return 1;
}

forward TimeGrab();
public TimeGrab()
{
    gettime(Hour, Minute, Second);
    if(Hour == 0)
    {
        SendClientMessageToAll(-1, "It is midnight!");
    }
    return 1;
}