#1

PHP код:
CMD:jail(playeridparams[])
{
    new 
str[128], idreason[128];
    new 
rand random(sizeof(JailRandomSpawn));
    new 
time;
    if(
PlayerInfo[playerid][pAdmin] >= 3)
    {
        if(
sscanf(params"usd[128]"idreasontime)) return SendClientMessage(playeridCOLOR_LIME"[FR Usage] /jail (id) (reason) (time)");
        if(
id == INVALID_PLAYER_ID) return ErrorMessages(playerid2);
        if(
PlayerInfo[playerid][pAdmin] < PlayerInfo[id][pAdmin]) return ErrorMessages(playerid3);
        if(
PlayerInfo[id][Jail] == 1) return SendClientMessage(playeridCOLOR_RED"That player is already in jail!");
        
PlayerInfo[id][Jail] = 1;
        
ResetPlayerWeapons(id);
        
SetPlayerPos(idJailRandomSpawn[rand][0], JailRandomSpawn[rand][1], JailRandomSpawn[rand][2]);
        
SetPlayerFacingAngle(idJailRandomSpawn[rand][3]);
        
SetPlayerInterior(id3);
        
format(strsizeof(str), "Admin %s(%d) has jailed %s(%d) (Reason:%s)"GetName(playerid), playeridGetName(id), idreason);
        
SendClientMessageToAll(BANstr);
        
JailLog(playerididreason);
        
SetTimer("Unjail",time,false);
        
PlayerInfo[id][JailC]++;
        
format(strsizeof(str), "You jailed %s(%d) for (Reason:%s)"GetName(id), idreason);
        
SendClientMessage(playeridBANstr);
        
format(strsizeof(str), ""COL_GREEN"\nYou have been jailed\n(Reason:%s)"reason);
           
ShowPlayerDialog(id122DIALOG_STYLE_MSGBOX""COL_GREEN"Jailed"str"OK""");
        }
        else return 
ErrorMessages(playerid1);
    return 
1;

How to convert the jailed time into minuites?
Reply
#2

[I]Try this ^^ :

PHP код:
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;

Exemple of use :

PHP код:
format(stringsizeof(string), "~w~Jail Time:~g~~h~%s"TimeConvert(PlayerInfo[i][PrisonTime]));
 
TextDrawSetString(JailTimeText[i],string);[/i
Reply
#3

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение
[I]Try this ^^ :

PHP код:
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;

Exemple of use :

PHP код:
format(stringsizeof(string), "~w~Jail Time:~g~~h~%s"TimeConvert(PlayerInfo[i][PrisonTime]));
 
TextDrawSetString(JailTimeText[i],string);[/i
how will i use it in my jail command?
Reply
#4

Код:
SetTimer("Unjail",time*1000,false);
As I am taking it, you are now entering it in milliseconds, you can just multiply it by 1000 to go from MS to S
Reply
#5

1000 milliseconds = 1 second.
If you need eg. 1minute (60 seconds) then use : 60000
Reply
#6

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение
PHP код:
        if(seconds>9)format(string,sizeof(string),"%d:%d",minutes,seconds);
        else 
format(string,sizeof(string),"%d:0%d",minutes,seconds); 
*Sigh*

PHP код:
format(stringsizeof(string), "%02d:%02d"minutesseconds); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)