JAIL, TEXTDRAW AND TIMER *REP+*
#1

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.
Reply
#2

bump
Reply
#3

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;
}
Reply
#4

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
Reply
#5

It is okay, i forgot to write, but i understood it myself, anyways thanks for feedback guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)