Delay between functions
#1

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?
Reply
#2

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)
Reply
#3

SetTimerEx?

pawn Код:
SetTimerEx("PlayerTutorial", time_in_ms, false, "i", playerid);

forward public PlayerTutorial(playerid);
PlayerTutorial(playerid)
{
    // code
}
EDIT: late.
Reply
#4

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)