SetWorldTime is not working [HELP]
#1

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
Reply
#2

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

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

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)
}
Reply
#5

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
Reply
#6

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

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.
Reply
#8

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++;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)