12.04.2011, 21:18
Okay i was going to make a "Wait 30seconds" thing but what would be best to use?.
new bool:HasToWait[MAX_PLAYERS];
forward StartWaitTimer(playerid);// start the countdown of 30 seconds(30000milli seconds)
forward WaitOver(playerid);//when the player doesn' have to wait anymore
public OnPlayerConnect(playerid)
{
HasToWait[playerid] = false;//set the wait to false for the newly connected player
//if the player does something that you want him to wait for
StartWaitTimer(playerid);
}
public StartWaitTimer(playerid)
{
HasToWait[playerid] = true;
SetTimerEx("WaitOver",30000,false,"i",playerid);
}
public WaitOver(playerid)
{
HasToWait[playerid] = false;
}
/*
just use the HasToWait array to check if each player is still required to wait.
if(HasToWait[playerid])
{
do wait stuff
}
*/
|
Personally I'd stick to timers lol.
pawn Код:
|
.
|
Oh okay thans for your reply. Your code looks pretty simple so im gonna use that thanks
. |
glad to help, also, personally I would use an array of timers so each player got the timer to set the waiting, that way you can kill the timer if the player disconnects so that it wont bug the next players waiting time incase the player that has to wait ragequits and another joins and 20 seconds later his wait is reset even if he was put to wait the last second.new PLAYER_TIMERS[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
//instead of just SetTimerEx make it a variable so you can kill it later.
PLAYER_TIMERS[playerid] = SetTimerEx("WaitOver",30000,false,"i",playerid);
}
public OnPlayerDisconnect(playerid)
{
KillTimer(PLAYER_TIMERS[playerid]);
}