Timer in textdraw
#1

Hello fellow scripters,

Once again I stumbled on a problem :\, I want to display my round timer from 30 minutes in a textdraw which will count down and when it reaches 0 it will stop untill the new round starts. I tried to search but I had no luck in succeeding. I hope you guys can help me.

Code I got so far:
pawn Код:
forward NewRoundTimer(playerid);

public NewRoundTimer(playerid)
{
    new InfoString[300];
   
    new Min = 30, sec;
    format(InfoString, sizeof(InfoString), "%d:%d", Min, sec);
    TextDrawSetString(timer1, InfoString);

    SetTimer("StartedNewRound",8000,false);
    return 1;
}

public StartedNewRound()                      
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        SpawnPlayer(i);
        SurvivorSpawn(i);
    }
    return 1;
}

public OnGameModeInit()
{
    SetTimer("NewRoundTimer",1800000,true);
    return 1;
}
Reply
#2

I believe this is what you want, you simple make the variable global and created a 1,000 mile seconds timer and decrease the variable by one

pawn Код:
forward NewRoundTimer( );
forward StartedNewRound( );
forward StartRoundTimer( );

new Minutes, Seconds;

public NewRoundTimer(  )
{
    new
        InfoString[ 15 ];
   
    format( InfoString, sizeof( InfoString ), "%d:%d", Minutes, Seconds );
    TextDrawSetString( timer1, InfoString );

    SetTimer("StartedNewRound", 8000, false);
    return 1;
}

public StartedNewRound( )                      
{
    for( new i = 0; i < MAX_PLAYERS; i++ )
    {
        SpawnPlayer( i );
        SurvivorSpawn( i );
    }
    return 1;
}

public StartRoundTimer( )
{
    if( Seconds <= 0 ) Minutes --;
    return Seconds --;
}



public OnGameModeInit( )
{
    SetTimer( "NewRoundTimer", 1800000, true );
    SetTimer( "StartRoundTimer", 1000, true );
    return 1;
}
Reply
#3

Thank you, I will try it tomorrow!
Reply
#4

Doesn't work :/.. maybe something is wrong with my textdraw?
pawn Код:
timer1 = TextDrawCreate(310.857208, 29.866657, "30:00");
TextDrawLetterSize(timer1, 0.449999, 1.600000);
TextDrawAlignment(timer1, 1);
TextDrawColor(timer1, -5963521);
TextDrawSetShadow(timer1, 0);
TextDrawSetOutline(timer1, 1);
TextDrawBackgroundColor(timer1, 255);
TextDrawFont(timer1, 2);
TextDrawSetProportional(timer1, 1);
Reply
#5

Anyone?
Reply
#6

Here is a .pwn that I made for your problem (i made something lake a side-script gamemode)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)