PDA

View Full Version : Textdraw that shows time in jail LEFT. [REP ++]


Dan.
08/04/2012, 06:25 PM
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.

HondaCBR
08/04/2012, 08:39 PM
Top

new PlayerText:TextdrawBW2[MAX_PLAYERS];


Ones he goes to jail: (You might need to change playerid if you using an /arrest command)

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

PlayerTextDrawHide(playa,TextdrawBW2[playerid]);


You need to use a timer to update the textdraw. in such way:


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