new ending;
public OnGameModeInit()
{
for (new id = 0; id < MAX_PLAYERS;id++)
{
if(IsPlayerConnected(id))
{
SetTimerEx("Unfreeze", 120000, false, "i", id);
}
}
}
forward Unfreeze(id);
public Unfreeze(id)
{
SendClientMessage(id, COLOR_PEACH, "Test message");
if(spawn[id] == 1)
{
TogglePlayerControllable(id, 1);
SendClientMessage(id, COLOR_PEACH, "The race has been started! Go!");
}
ending = SetTimer("Next", 180000, false);
return 1;
}
forward Next();
public Next()
{
SendRconCommand("changemode Proj");
return 1;
}
|
You've put the timer at OnGameModeInit() which is being called exactly when the server loads up, which means there are no players online yet. You gotta put it in the start of the race. (as much as I see, you are building a race)
|
SetTimer("Unfreeze", 120000, false);
|
You are doing it in wrong way, first you are starting timers under OnGameModeInit for every connected player (if(IsPlayerConnected(id))), at that point noone is connected.
SetTimer("Unfreeze", 120000, false); False means don't reapeat action, do it just one time. |
|
i was using this code:
PHP код:
Edit: the function "Unfreeze" will be called after 2 mns, and when i join the server, nothing happen so the problem is the timer don't start at the 1st time |
new ending;
public OnGameModeInit()
{
SetTimer("Unfreeze", 120000, false); //After 2mns, "Unfreeze" will be called to unfreeze the online players
return 1;
}
forward Unfreeze();
public Unfreeze()
{
for(new id=0;id<MAX_PLAYERS;id++)
{
SendClientMessage(id, COLOR_PEACH, "Test message");
if(spawn[id] == 1)
{
TogglePlayerControllable(id, 1);
SendClientMessage(id, COLOR_PEACH, "The race has been started! Go!");
}
}
ending = SetTimer("Next", 180000, false);
return 1;
}
forward Next();
public Next()
{
SendRconCommand("changemode Proj");
return 1;
}
|
I don't know ahat are you trying to do with this code, But it won't work for the players who join after 2 minutes of the server start.
|