problem with worldtime and realtime
#1

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));}
        }
    }

Reply
#2

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
}
Reply
#3

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)
Reply
#4

bump...
Reply
#5

can anyone know about this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)