Isn't this the same? - 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: Isn't this the same? (
/showthread.php?tid=248220)
Isn't this the same? -
The Woody - 12.04.2011
Okay i was going to make a "Wait 30seconds" thing but what would be best to use?.
Re: Isn't this the same? -
Andy6999 - 12.04.2011
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
}
*/
Re: Isn't this the same? -
The Woody - 12.04.2011
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

.
Re: Isn't this the same? -
Andy6999 - 12.04.2011
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]);
}