How to set time without clock? - 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 without clock? (
/showthread.php?tid=194468)
How to set time without clock? -
blackwave - 29.11.2010
Im trying to make an clock, but just on time change:
Код:
forward relogio(playerid);
Код:
Public OnFilterScriptInit()
{
SetTimer("relogio", 2000, false);
return 1;
}
Код:
public relogio(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new hour,minute;
GetPlayerTime(i, hour, minute);
SetPlayerTime(i, hour, minute+1);
if(minute == 59)
{
SetPlayerTime(i, hour+1, 0);
}
}
SetTimer("relogio", 2000, true);
return 1;
}
It's like setting the minute of server time by 1min per 2seconds on real life, and if minute = 59, add hour+1 and set minute to 0. It's like an clock which updates every 2 seconds on real life, for each player, and changing server time
Re: How to set time without clock? -
TPD - 29.11.2010
Personally, I would do this:
pawn Код:
forward relogio();
public relogio()
{
minutes = minutes + 1;
if(minutes == 60)
{
minutes = 0;
hours = hours + 1;
SetWorldTime(hours);
}
if(hours == 24)
{
minutes = 0;
hours = 0;
}
}
That's how it was done for me, I hope this helps a bit.