[HELP] Timer and gametext!
#1

Hi guys i realy need to learn how to make this countdown

lets say i have 20 sec to deliver pizza and if i dont make in time it disables checkpoint
Help :P
Reply
#2

pawn Код:
new PlayerText:Countdown[MAX_PLAYERS],PlayerTimer[MAX_PLAYERS],PlayerTime[MAX_PLAYERS] = 20;
public OnPlayerConnect(playerid)
{
    Countdown[playerid] = CreatePlayerTextDraw(playerid, 297.500000, 380.916717, "00:20");
    PlayerTextDrawLetterSize(playerid, Countdown[playerid], 0.475000, 2.405000);
    PlayerTextDrawAlignment(playerid, Countdown[playerid], 1);
    PlayerTextDrawColor(playerid, Countdown[playerid], -1);
    PlayerTextDrawSetShadow(playerid, Countdown[playerid], 0);
    PlayerTextDrawSetOutline(playerid, Countdown[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, Countdown[playerid], 255);
    PlayerTextDrawFont(playerid, Countdown[playerid], 1);
    PlayerTextDrawSetProportional(playerid, Countdown[playerid], 1);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PlayerTextDrawDestroy(playerid,Countdown[playerid]);
    return 1;
}
CMD:startjob(playerid)
{
    PlayerTextDrawShow(playerid,Countdown[playerid]);
    //setplayercheckpoint here
    PlayerTime[playerid] = 20;
    PlayerTimer[playerid] = SetTimerEx("Counter",1000,true,"i",playerid);
    return 1;
}
forward Counter(playerid);
public Counter(playerid)
{
    PlayerTime[playerid] --;
    if(PlayerTime[playerid] > 9)
    {
        new string[24];
        format(string,sizeof(string),"00:%d",PlayerTime[playerid]);
        PlayerTextDrawSetString(playerid,Countdown[playerid],string);
    }
    else if(PlayerTime[playerid] <= 9)
    {
        new string[24];
        format(string,sizeof(string),"00:0%d",PlayerTime[playerid]);
        PlayerTextDrawSetString(playerid,Countdown[playerid],string);
    }
    if(PlayerTime[playerid] <= 0)
    {
        //disable his checkpoint
        KillTimer(PlayerTimer[playerid]);
        PlayerTextDrawHide(playerid,Countdown[playerid]);
    }
    return 1;
}
Don't forget to kill the timer when "OnPlayerEnterCheckpoint" is being called ( When he delivers the pizza ).
Reply
#3

Thank's bro
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)