JAIL, TEXTDRAW AND TIMER *REP+* -
_GHT_MarK445 - 15.03.2016
Hey guys, i am here with another problem. I am making a /jail command, i will explain you, what it should do:
When admin writes /jail [id] [amount of seconds] [reason], it should put player in some position.
Here is the command, i have made (it is not completed, couse i have no idea, how to complete it)
Код:
CMD:jail(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "Zadanэ prнkaz neexistuje");
new
pplayerid,reason[48],banmt[300],banma[300],string[128];
if(sscanf(params, "uis[48]", pplayerid,JailTime,reason)) return SendClientMessage(playerid, COLOR_RED, "Pouћitie /jail <id> <počet minъt 1-59> <dфvod>");
if(!IsPlayerConnected(pplayerid)) return SendClientMessage(playerid, COLOR_RED, "Hrбč nieje pripojenэ");
if(PlayerInfo[pplayerid][pJail] == 1) return SendClientMessage(playerid, COLOR_RED, "Hrбč je uћ na samotke");
switch(PlayerInfo[playerid][pAdmin])
{
case 2:
{
format(banma,sizeof(banma),"Moderбtor %s na %d minъt uvдznil na samotku hrбča %s: %s",GetName(playerid),JailTime,GetName(pplayerid),reason);
format(banmt,sizeof(banmt),"Moderбtor %s vбs na %d minъt uvдznil na samotku: %s",GetName(playerid), JailTime,reason);
}
case 3:
{
format(banma,sizeof(banma),"Administrбtor %s na %d minъt uvдznil na samotku hrбča %s: %s",GetName(playerid),JailTime,GetName(pplayerid),reason);
format(banmt,sizeof(banmt),"Administrбtor %s vбs na %d minъt uvдznil na samotku: %s",GetName(playerid), JailTime,reason);
}
case 4:
{
format(banma,sizeof(banma),"Vedъci Administrбtor %s na %d minъt uvдznil na samotku hrбča %s: %s",GetName(playerid),JailTime,GetName(pplayerid),reason);
format(banmt,sizeof(banmt),"Vedъci Administrбtor %s vбs na %d minъt uvдznil na samotku: %s",GetName(playerid), JailTime,reason);
}
case 5:
{
format(banma,sizeof(banma),"Hlavnэ Administrбtor %s na %d minъt uvдznil na samotku hrбča %s: %s",GetName(playerid),JailTime,GetName(pplayerid),reason);
format(banmt,sizeof(banmt),"Hlavnэ Administrбtor %s vбs na %d minъt uvдznil na samotku: %s",GetName(playerid), JailTime,reason);
}
}
SendClientMessageToAll(COLOR_RED,banma);
SendClientMessage(pplayerid,COLOR_RED,banmt);
PlayerInfo[pplayerid][pJail] = 1;
SetPlayerPos(pplayerid, 279.7186,1815.9452,17.6406);
SetPlayerFacingAngle(pplayerid, 91.7942);
unjailplayer_timer[pplayerid] = SetTimerEx("UnjailPlayer",60000*JailTime,false,"i",pplayerid);
return 1;
}
What i need, is to show a textdraw (which i have already made), in following format:
"Remaining time: %d minutes and %d seconds", so basically i want to get, from that time, which admin sets, seconds. I have no idea how to do it, maybe i need to use some divide, but i again have no idea how and where.
If some of you guys would be enable to help me and explain, what i need to do, i would rep you and be really, really thankful, couse this is one of the hardest thing, i have ever tryed to do.
Re: JAIL, TEXTDRAW AND TIMER *REP+* -
_GHT_MarK445 - 16.03.2016
bump
Re: JAIL, TEXTDRAW AND TIMER *REP+* -
introzen - 16.03.2016
Try this
Код:
TimeConvert(time) {
new minutes;
new seconds;
new string[128];
if(time > 59){
minutes = floatround(time/60);
seconds = floatround(time - minutes*60);
if(seconds>9)format(string,sizeof(string),"%d:%d",minutes,seconds);
else format(string,sizeof(string),"%d:0%d",minutes,seconds);
}
else{
seconds = floatround(time);
if(seconds>9)format(string,sizeof(string),"0:%d",seconds);
else format(string,sizeof(string),"0:0%d",seconds);
}
return string;
}
Re: JAIL, TEXTDRAW AND TIMER *REP+* -
itsCody - 16.03.2016
Show the player textdraw upon entering jail, then in the timer that counts it down update the textdraw.
https://sampwiki.blast.hk/wiki/PlayerTextDrawShow
https://sampwiki.blast.hk/wiki/PlayerTextDrawHide
https://sampwiki.blast.hk/wiki/PlayerTextDrawSetString
Re: JAIL, TEXTDRAW AND TIMER *REP+* -
_GHT_MarK445 - 17.03.2016
It is okay, i forgot to write, but i understood it myself, anyways thanks for feedback guys.