SA-MP Forums Archive
Using TextDraws And Timers? - 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: Using TextDraws And Timers? (/showthread.php?tid=288516)



Using TextDraws And Timers? - DaRkAnGeL[NBK] - 08.10.2011

hey i would like to know is it possible to use text draws to show a timer countdown if so a quick how-to would be much appreciated

thanks


Re: Using TextDraws And Timers? - DaRkAnGeL[NBK] - 08.10.2011

no one knows eh ? XD


Re: Using TextDraws And Timers? - Drakon - 08.10.2011

Very Simple,

Use a normal countdown (GameText)

create text draws

https://sampwiki.blast.hk/wiki/TextDrawCreate

then

https://sampwiki.blast.hk/wiki/TextDrawShowForPlayer

https://sampwiki.blast.hk/wiki/TextDrawHideForPlayer

In a timer


Re: Using TextDraws And Timers? - DaRkAnGeL[NBK] - 08.10.2011

but how to add the timer?


Re: Using TextDraws And Timers? - Rachael - 08.10.2011

here is a thing, using gametext style 3, not textdraws.
pawn Код:
new PlayerCount[MAX_PLAYERS]; //variable to hold the players countdown value
new PlayerCountTimer; //timer id for countdown timer
forward PlayerCountDown();

public OnGameModeInit()
{
    PlayerCountTimer = SetTimer( "PlayerCountDown" , 1000 , true ); //sets one second loop, you could also use an existing timer loop
    return 1;
}

public OnPlayerConnect( playerid )
{
    PlayerCount[playerid] = 0;
    return 1;
}
public PlayerCountDown() //this function is called every second
{
    new
        string[6]
    ;
    for( new i; i < MAX_PLAYERS; i++ )
    {
        if( IsPlayerConnected(i) )
        {
            if( PlayerCount[i] > 0 )
            {
                PlayerCount[i]--;
                if( PlayerCount[i] == 0 )
                {
                    //put code in here, depends on the function I guess
                }
                format( string , sizeof(string) , "~r~%d" , PlayerCount[i] );
                GameTextForPlayer( playerid , string , 1000 , 3 );
            }
        }
    }
    return 1;
}
You have to add those things to the associated callbacks, or create them if they do not exist.
If you want to use textdraws, thats fine, I just dont think it is needed.