SA-MP Forums Archive
Textdraw that shows time in jail LEFT. [REP ++] - 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: Textdraw that shows time in jail LEFT. [REP ++] (/showthread.php?tid=332593)



Textdraw that shows time in jail LEFT. [REP ++] - Dan. - 08.04.2012

Hi. I have an arrest command, what sets you in jail for X seconds, depending on the amount of wanted stars you have. After X time when the timer stops, you get released from jail. But how do show the time left in textdraw? Waiting for your replies.


Re: Textdraw that shows time in jail LEFT. [REP ++] - HondaCBR - 08.04.2012

Top
pawn Код:
new PlayerText:TextdrawBW2[MAX_PLAYERS];
Ones he goes to jail: (You might need to change playerid if you using an /arrest command)
pawn Код:
new bwstring[256];
            format(bwstring,sizeof(bwstring),"%d sec",/*here the time line eg. PlayerInfo[playerid][pJailTime]*/);
            TextdrawBW2[playerid] = CreatePlayerTextDraw(playerid, 571.000000, 431.000000, bwstring);
            PlayerTextDrawBackgroundColor(playerid, TextdrawBW2[playerid], 255);
            PlayerTextDrawFont(playerid, TextdrawBW2[playerid], 1);
            PlayerTextDrawLetterSize(playerid, TextdrawBW2[playerid], 0.500000, 1.000000);
            PlayerTextDrawColor(playerid, TextdrawBW2[playerid], -65281);
            PlayerTextDrawSetOutline(playerid, TextdrawBW2[playerid], 1);
            PlayerTextDrawSetProportional(playerid, TextdrawBW2[playerid], 1);
            PlayerTextDrawShow(playerid,  TextdrawBW2[playerid]);
Once he is free
pawn Код:
PlayerTextDrawHide(playa,TextdrawBW2[playerid]);
You need to use a timer to update the textdraw. in such way:

pawn Код:
forward Timer1(playerid);
public Timer1(playerid)
{
PlayerTextDrawHide(playa,TextdrawBW2[playerid]);
            new bwstring[256];
            format(bwstring,sizeof(bwstring),"%d sec",/*here the time line eg. PlayerInfo[playerid][pJailTime]*/);
            TextdrawBW2[playerid] = CreatePlayerTextDraw(playerid, 571.000000, 431.000000, bwstring);
            PlayerTextDrawBackgroundColor(playerid, TextdrawBW2[playerid], 255);
            PlayerTextDrawFont(playerid, TextdrawBW2[playerid], 1);
            PlayerTextDrawLetterSize(playerid, TextdrawBW2[playerid], 0.500000, 1.000000);
            PlayerTextDrawColor(playerid, TextdrawBW2[playerid], -65281);
            PlayerTextDrawSetOutline(playerid, TextdrawBW2[playerid], 1);
            PlayerTextDrawSetProportional(playerid, TextdrawBW2[playerid], 1);
            PlayerTextDrawShow(playerid,  TextdrawBW2[playerid]);
}

SetTimerEx("Timer1", 1000, 1, "d", playerid);
KillTimer(Timer1[playerid]);

then kill timer when he is out