Check hours - 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: Check hours (
/showthread.php?tid=657974)
Check hours -
djoudjou - 19.08.2018
Hello,
How can I check if it was 15h00 o'clock on the server ? With gettime() function ?
Because it's for a bonus at all 15h00...
Thank's
Re: Check hours -
victory88 - 20.08.2018
At the top of your script, below the includes put this
Inside OnGameModeInit put this
PHP код:
SetTimer("ThreeOClockPartyTimeR", 5000, true);
PartyTime = 0;
Add this to the very bottom
PHP код:
forward ThreeOClockPartyTimeR();
public ThreeOClockPartyTimeR()
{
new hour, minute, second;
gettime(hour, minute, second);
printf("%i %i %i",hour, minute, second);
if(hour == 15 && minute < 1 && PartyTime == 0)
{
PartyTime = 1;
SendClientMessageToAll(-1, "It is currently 1500 server time in UNIX and u know what that means *wink wink* MINIGUNS");
SendClientMessageToAll(-1, "It has been some time since 1th of January 1970 and I thought we'd all appriciate that");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GivePlayerWeapon(i, 38, 200);
SetPlayerVelocity(i,0.0, 0.0, 0.3);
PlayerPlaySound(i, 3201, 0.0, 0.0, 0.0);
GameTextForPlayer(i, "1500 - ohh yeah!", 8000, 1);
}
}
}
if(hour == 1)
{
PartyTime = 0;
}
}
However, if you meant worldtime there is no function to get it, so you will have to construct your own time system.
https://sampforum.blast.hk/showthread.php?tid=282260
Then you would have to make the party arrangements whenever the hour is 15