Isn't this the same?
#1

Okay i was going to make a "Wait 30seconds" thing but what would be best to use?.
Reply
#2

Personally I'd stick to timers lol.

pawn Код:
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

}

*/
Reply
#3

Quote:
Originally Posted by Andy6999
Посмотреть сообщение
Personally I'd stick to timers lol.

pawn Код:
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

}

*/
Oh okay thanks for your reply. Your code looks pretty simple so im gonna use that thanks .
Reply
#4

Quote:
Originally Posted by The Woody
Посмотреть сообщение
Oh okay thans for your reply. Your code looks pretty simple so im gonna use that thanks .
No problem 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.

pawn Код:
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]);

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)