SA-MP Forums Archive
SetWorldTime is not working [HELP] - 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: SetWorldTime is not working [HELP] (/showthread.php?tid=199279)



SetWorldTime is not working [HELP] - admantis - 15.12.2010

Hello all again
Now I have a error here, well, actually not errors or warnings, just a bugged script.

pawn Код:
new WorldTime;
public OnGameModeInit()
{

    SetTimer("SetHour", 5000, 1); // 3600000 = 1 hour in ms - Time was set to 5000 ms for testing purposes.
    WorldTime = SetWorldTime(random(24));
}
pawn Код:
forward SetHour()
public SetHour()
{
    if (WorldTime == 24) WorldTime = 0;
    SetWorldTime((WorldTime)+1);
}
However when I go ingame nothing happens. Thought the time is properly set to a random number upto 24, it won't change every 5000 ms - 5 seconds.

EDIT: I need help really, bcs now I found out time will be set only to hour 24 OnGameModeInit.
Thanks to everyone


Re: SetWorldTime is not working [HELP] - XePloiT - 15.12.2010

i have this exact problem...this is happened after i installed 0.3c...
i this its something with the development... :\


Re: SetWorldTime is not working [HELP] - admantis - 15.12.2010

Quote:
Originally Posted by XePloiT
Посмотреть сообщение
i have this exact problem...this is happened after i installed 0.3c...
i this its something with the development... :\
Ye but im working on 0.3b now not 0.3c


Re: SetWorldTime is not working [HELP] - XePloiT - 15.12.2010

Quote:
Originally Posted by admantis
Посмотреть сообщение
Ye but im working on 0.3b now not 0.3c
ow...try this...
pawn Код:
public OnGameModeInit()
{
    WorldTime = SetWorldTime(random(24));// this before the timer
    SetTimer("SetHour", 5000, 1); // 3600000 = 1 hour in ms - Time was set to 5000 ms for testing purposes.
}
forward SetHour()
public SetHour()
{
    if (WorldTime == 24) WorldTime = 0;
    SetWorldTime((WorldTime)+1);
    return SetTimer(SetHour,"5000",false); // if its doesn't work remove this line and try again...
    // + i don't this its gonna work cuz i think that OnGameModeInit() is only when its loads the GM...
   //just use gl_realtime that comes with the server files... this is will change the time every one hour(in game)
}



Respuesta: SetWorldTime is not working [HELP] - MaRcOsWeB - 15.12.2010

SetPlayerTime(playerid,0,0); // to set the time to playerid.

This is what I guess might work to do that action, you should try it, it might work


Re: Respuesta: SetWorldTime is not working [HELP] - XePloiT - 15.12.2010

Quote:
Originally Posted by MaRcOsWeB
Посмотреть сообщение
SetPlayerTime(playerid,0,0); // to set the time to playerid.

This is what I guess might work to do that action, you should try it, it might work
SetPlayerTime sets the time for one player...if he want to use this he'll have to make a loop...
SetWorldTime is sets it for everyone


Re: SetWorldTime is not working [HELP] - Scenario - 15.12.2010

I am having no issues with this function and I am using 0.3c RC4-2-2. You need to make sure that you have used "TogglePlayerClock" for each player who joins the server. If you didn't, this function will not work. Alternatively, you could perform a loop through all of your online players and use "SetPlayerTime"; as mentioned by the above poster.


Re: SetWorldTime is not working [HELP] - Joe Staff - 15.12.2010

Quote:
Originally Posted by admantis
Посмотреть сообщение
Hello all again
Now I have a error here, well, actually not errors or warnings, just a bugged script.

pawn Код:
new WorldTime;
public OnGameModeInit()
{

    SetTimer("SetHour", 5000, 1); // 3600000 = 1 hour in ms - Time was set to 5000 ms for testing purposes.
    WorldTime = SetWorldTime(random(24));
}
pawn Код:
forward SetHour()
public SetHour()
{
    if (WorldTime == 24) WorldTime = 0;
    SetWorldTime((WorldTime)+1);
}
However when I go ingame nothing happens. Thought the time is properly set to a random number upto 24, it won't change every 5000 ms - 5 seconds.

EDIT: I need help really, bcs now I found out time will be set only to hour 24 OnGameModeInit.
Thanks to everyone
You're not increasing your "WorldTime" variable


pawn Код:
forward SetHour()
public SetHour()
{
    if (WorldTime == 24) WorldTime = 0;
    SetWorldTime((WorldTime)+1);
    WorldTime++;
}