Jail command
#1

Need some help with my jail command, the player doesn't get released after he gets jailed, also i have textdraws that i want to set as a timer (so it shows for the player) when unjail it will disapear,

pawn Код:
CMD:jail(playerid, params[])
{
    new pID;
    new string[128];
    new time, reason[128];
    if (sscanf(params, "udS", pID, time, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /jail (Nick/ID) (Seconds) (Reason)");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_RED, "This Player Is Not Connected.");
    if(pID == cellmin) return SendClientMessage(playerid, COLOR_RED, "Multiple Players Found. Please Be More Specific.");
    if(pID == playerid) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command On Yourself.");
    if(Dead[pID] == 1) return SendClientMessage(playerid, COLOR_RED, "You Cannot Use This Command On A Dead Player.");
    if(Jailed{pID} == true) return SendClientMessage(playerid, COLOR_RED, "This Player Is Already Jailed.");
    format(string, sizeof string, "JAIL: %s (%d)  (JAIL) %s", PlayerName(pID));
    SendClientMessageToAll(COLOR_PINK, string);
    GameTextForPlayer(pID, "~w~busted by an ~r~admin", 3500, 3);
    SetPVarInt(pID, "IsJailed", 1);
    Jailed{pID} = true;
    SetPlayerInterior(pID, 3);
    SetPlayerPos(pID, 198.0666,175.6295,1003.0234);
    ResetPlayerWeapons(pID);
        return 1;
}
Reply
#2

Do you want to set a specific jail time for this player? Then use SetTimerEx (https://sampwiki.blast.hk/wiki/SetTimerEx)
Reply
#3

Yes, but how do i set the timer to the time?

I mean, if the player gets jailed for 4 minutes (260 seconds) it will be a timer of 260 seconds, if its 3 minutes (200 seconds) it will set to 200 and so on
Reply
#4

Last time I checked 3 minutes were equal to 180 seconds, and four minutes were also equal to 240 seconds.

Timers work in milliseconds so you'll have to multiply any value you input (in this case, your 'time' parameter) by 1000.
Reply
#5

This command lets you set the time you want to jail the player.
pawn Код:
COMMAND:jail(playerid,params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 1) // Change to your preferred admin level.
    {
        new player, time, reason[128];
        if(sscanf(params, "rds[128]", player, time, reason))
        {
            SendClientMessage(playerid,RED,"Usage: /jail (playerid) (minutes) (reason)");
            return 1;
        }

        if(IsPlayerConnected(player) && player != INVALID_PLAYER_ID )
        {
            if(PlayerInfo[player][Jailed] == false)
            {
                PlayerInfo[playerid][JailTime] = time * 1000 * 60;
                SetTimerEx("JailPlayer", 5000, 0, "d", player);
                SetTimerEx("Jail1", 1000, 0, "d", player);
                PlayerInfo[player][Jailed] = true;
               
                format(string, sizeof(string), "**%s has been jailed for %i minutes by admin %s [Reason: %s]", GetName(player), time, GetName(playerid), reason);
                SendClientMessageToAll(RED,string);
            } else SendClientMessage(playerid, RED, "ERROR: Player is already in jail");
        }else SendClientMessage(playerid, RED, "ERROR: Player is not connected!");
    }
    else
    {
        SendClientMessage(playerid, RED, "You're not admin!");
    }
    return 1;
}
NOTE: That command is from MellAdmin.
Reply
#6

The time is in minutes, so you need to multiply it by 60 to make in in seconds.
Then after that, you multiply it by 1000 so it will become in milliseconds.

SetTimerEx("JailTime", time * 60 * 100, false, "i", pID);
Reply
#7

I dont understand,

what should i do?
Reply
#8

Do you want the command to set the jail time in Minutes or Seconds?
Reply
#9

Well, i guess minutes (-:

EDIT: like i said, if player gets jailed for one minute, it will be like

0:60
0:59
0:58

and so on,

if it is two minutes, it will be

1:60
1:59
1:58

and o so on, i have the textdraws ready to set too, how do i make it like this?
Reply
#10

- Deleted -
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)