Delay between functions - 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)
+--- Thread: Delay between functions (
/showthread.php?tid=512306)
Delay between functions -
Twizted - 10.05.2014
I figure out this is quite of a beginner, but these two functions are running at the same time (as they should be, I suppose). How do I make it so the first one runs for 10 seconds, and then the other one, PlayerTutorial(playerid);, starts? Basically, to simple everything up, how to do a delay between functions?
Re: Delay between functions -
RajatPawar - 10.05.2014
Use a timer? Set a timer, call the FIRST function in there, call another timer and call the second function.. (or just make the timer call itself and use a variable to distinguish between two functions)
Re: Delay between functions -
iZN - 10.05.2014
SetTimerEx?
pawn Код:
SetTimerEx("PlayerTutorial", time_in_ms, false, "i", playerid);
forward public PlayerTutorial(playerid);
PlayerTutorial(playerid)
{
// code
}
EDIT: late.
Re: Delay between functions -
Twizted - 10.05.2014
I have that, but it's not working.
pawn Код:
new Tutorial[ MAX_PLAYERS ][ 2 ]; //Should be global, so we can use it.
forward PlayerTutorial(playerid);
public PlayerTutorial(playerid)
{
Tutorial[ playerid ][ 1 ] = SetTimerEx( "PlayerTutorial", 100*10*2, true, "i", playerid );
switch(Tutorial[playerid][0])
{
case 0:
{
SendClientMessage(playerid, GREEN, "=========================================");
SendClientMessage(playerid, -1, "Hello there. Welcome to San Andreas Online.");
SendClientMessage(playerid, -1, "In this server, you will be able to ................");
SendClientMessage(playerid, -1, "---------------------------------------------------");
SendClientMessage(playerid, GREEN, "=========================================");
}
case 1:
{
}
case 2:
{
SendClientMessage(playerid, -1, "Hello, welcome to SAOnline");
}
case 3:
{
SendClientMessage(playerid, -1, "Hello, welcome to SAOnline");
}
case 4:
{
SendClientMessage(playerid, -1, "Hello, welcome to SAOnline");
}
case 5:
{
SendClientMessage(playerid, -1, "Hello, welcome to SAOnline");
}
case 6:
{
SpawnPlayer(playerid);
SendClientMessage(playerid, -1, "The end");
}
case 7:
{
KillTimer(Tutorial[ playerid ][ 1 ]);
}
}
Tutorial[ playerid ][ 0 ] ++;
return true;
}
new Tutorial2[ MAX_PLAYERS ][ 2 ]; //Should be global, so we can use it.
forward wTutorial(playerid);
public wTutorial(playerid)
{
Tutorial2[ playerid ][ 1 ] = SetTimerEx( "wTutorial", 100*10*5, true, "i", playerid );
switch(Tutorial2[playerid][0])
{
case 0:
{
SendClientMessage(playerid, GREEN, "We're now loading the tutorial for you.\n Please, bare with us, it will not take more than five secodns!");
}
case 1:
{
for(new i = 0; i < 16; i++) SendClientMessageToAll(-1," "); return 1;
}
case 2:
{
KillTimer(Tutorial2[ playerid ][ 1 ]);
}
}
Tutorial2[ playerid ][ 0 ] ++;
return true;
}