Jail Timer
#1

How can i set time for jail,i mean how can i make this command like /jail <id> <time>

Код:
CMD:jail(playerid, params[])
{
	new str[128], id, reason[128];
	new rand = random(sizeof(JailRandomSpawn));
	if(PlayerInfo[playerid][pAdmin] >= 3)
	{
		if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_LIME, "[FR Usage] /jail (id) (reason)");
		if(id == INVALID_PLAYER_ID) return ErrorMessages(playerid, 2);
	    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[id][pAdmin]) return ErrorMessages(playerid, 3);
		if(PlayerInfo[id][Jail] == 1) return SendClientMessage(playerid, COLOR_RED, "That player is already in jail!");
		PlayerInfo[id][Jail] = 1;
		ResetPlayerWeapons(id);
        SetPlayerPos(id, JailRandomSpawn[rand][0], JailRandomSpawn[rand][1], JailRandomSpawn[rand][2]);
        SetPlayerFacingAngle(id, JailRandomSpawn[rand][3]);
		SetPlayerInterior(id, 3);
		format(str, sizeof(str), "Admin %s(%d) has jailed %s(%d) (Reason:%s)", GetName(playerid), playerid, GetName(id), id, reason);
		SendClientMessageToAll(BAN, str);
		JailLog(playerid, id, reason);
		PlayerInfo[id][JailC]++;
		format(str, sizeof(str), "You jailed %s(%d) for (Reason:%s)", GetName(id), id, reason);
		SendClientMessage(playerid, BAN, str);
        format(str, sizeof(str), ""COL_GREEN"\nYou have been jailed\n(Reason:%s)", reason);
       	ShowPlayerDialog(id, 122, DIALOG_STYLE_MSGBOX, ""COL_GREEN"Jailed", str, "OK", "");
	    }
	    else return ErrorMessages(playerid, 1);
    return 1;
}
Reply
#2

try this
pawn Код:
CMD:jail(playerid, params[])
{
    new str[128], id, time, szOutput[128], reason[128];
    new rand = random(sizeof(JailRandomSpawn));
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
        if(sscanf(params, "uds[128]", id, time, reason)) return SendClientMessage(playerid, COLOR_LIME, "[FR Usage] /jail (id) (time) (reason)");
        if(id == INVALID_PLAYER_ID) return ErrorMessages(playerid, 2);
        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[id][pAdmin]) return ErrorMessages(playerid, 3);
        if(PlayerInfo[id][Jail] == 1) return SendClientMessage(playerid, COLOR_RED, "That player is already in jail!");
        if(time == 0) return SendClientMessage(playerid, COLOR_RED, "You cannot jail someone for 0 minutes.");
        PlayerInfo[id][Jail] = 1;
        PlayerInfo[id][JailTime] = time * 60;
        ResetPlayerWeapons(id);
        SetPlayerPos(id, JailRandomSpawn[rand][0], JailRandomSpawn[rand][1], JailRandomSpawn[rand][2]);
        SetPlayerFacingAngle(id, JailRandomSpawn[rand][3]);
        SetPlayerInterior(id, 3);
        format(str, sizeof(str), "Admin %s(%d) has jailed %s(%d) (Reason:%s)", GetName(playerid), playerid, GetName(id), id, reason);
        SendClientMessageToAll(BAN, str);
        JailLog(playerid, id, reason);
        PlayerInfo[id][JailC]++;
        format(str, sizeof(str), "You jailed %s(%d) for (Reason:%s)", GetName(id), id, reason);
        SendClientMessage(playerid, BAN, str);
        format(str, sizeof(str), ""COL_GREEN"\nYou have been jailed\n(Reason:%s)", reason);
        format(szOutput, sizeof(szOutput), "~r~%d MINUTES", time);
        GameTextForPlayer(iPlayerID, szOutput, 2000, 4);
        ShowPlayerDialog(id, 122, DIALOG_STYLE_MSGBOX, ""COL_GREEN"Jailed", str, "OK", "");
        }
        else return ErrorMessages(playerid, 1);
    return 1;
}
pawn Код:
task JailTimer[1000]()
{
    foreach(new i: Player)
    {
    if(PlayerInfo[i][JailTime] != 0)
        {
            PlayerInfo[i][JailTime] -= 1;

            if(PlayerInfo[i][JailTime] == 0)
            {
                SetPlayerPos(i, 1541.7244, -1675.3894, 13.5531);
                SetPlayerFacingAngle(i, 91.1223);
                SendClientMessage(i, -1,  "You have served your time & been released.");
                PlayerInfo[i][JailTime] = 0;
                SetPlayerVirtualWorld(i, 0);
            }
        }
    }
    return 1;
}
make sure to add JailTime to the player data enum
+rep if i helped
Reply
#3

anyone other?
Reply
#4

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
anyone other?
not working?
Reply
#5

Quote:
Originally Posted by simo0000
Посмотреть сообщение
not working?
Giving errors and also you dident added SetTimer(...)
Reply
#6

didn't work for me too
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)