problem with worldtime and realtime - 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: problem with worldtime and realtime (
/showthread.php?tid=446750)
problem with worldtime and realtime[SOLVED] -
drichie - 27.06.2013
im try to make a code that if the time is set to 1:00, 2:00 3:00 it automatically setworldtime and automatically setworldtime when the server start
SOLVED:
i just add && second == 0 inside together with the minute
then SetTimer("Time",1000,true); --> OnGameModeInit
here is my code
PHP код:
public Time()
{
new hour,minute,second;
gettime(hour,minute,second);
FixHour(hour);
hour = shifthour;
if(minute == 0)
{
switch(hour)
{
case 1:{SetWorldTime(1);SetWeather(random(18));}
case 2: {SetWorldTime(2); SetWeather(random(18));}
case 3: {SetWorldTime(3); SetWeather(random(18));}
case 4: {SetWorldTime(4); SetWeather(random(18));}
case 5: {SetWorldTime(5); SetWeather(random(18));}
case 6: {SetWorldTime(6); SetWeather(random(18));}
case 7: {SetWorldTime(7); SetWeather(random(18));}
case 8: {SetWorldTime(8); SetWeather(random(18));}
case 9: {SetWorldTime(9); SetWeather(random(18));}
case 10: {SetWorldTime(10);SetWeather(random(18));}
case 11: {SetWorldTime(11); SetWeather(random(18));}
case 12: {SetWorldTime(12); SetWeather(random(18));}
case 13: {SetWorldTime(13); SetWeather(random(18));}
case 14: {SetWorldTime(14); SetWeather(random(18));}
case 15: {SetWorldTime(15); SetWeather(random(18));}
case 16: {SetWorldTime(16); SetWeather(random(18));}
case 17: {SetWorldTime(17); SetWeather(random(18));}
case 18: {SetWorldTime(18); SetWeather(random(18));}
case 19: {SetWorldTime(19); SetWeather(random(18));}
case 20: {SetWorldTime(20); SetWeather(random(18));}
case 21: {SetWorldTime(21); SetWeather(random(18));}
case 22: {SetWorldTime(22); SetWeather(random(18));}
case 23: {SetWorldTime(23); SetWeather(random(18));}
case 24: {SetWorldTime(0);SetWeather(random(18));}
}
}
}
Re: problem with worldtime and realtime -
Niko_boy - 27.06.2013
whats the problem with that ?
though ur code can be shortened:
pawn Код:
public Time()
{
new hour,minute,second;
gettime(hour,minute,second);
FixHour(hour);
hour = shifthour;
if( hour >= 24 ) SetWorldTime(0);
else SetWorldTime(hour);
SetWeather(random(18));
}
add Time() in ongamemodeinit;
like
pawn Код:
public OnGameModeInit()
{
Time();//will call the function
}
Re: problem with worldtime and realtime -
drichie - 27.06.2013
the problem with that is it will not update as the time pass by the world time that is set when the server start will be the same until the server restart or close (sorry if im not good at english)
Re: problem with worldtime and realtime -
drichie - 27.06.2013
bump...
Re: problem with worldtime and realtime -
drichie - 27.06.2013
can anyone know about this?