Jail -_-
#1

I have made a jail command with timer and when the time is over so it uses the unjail function for all the players

Command:
Код:
CMD:jail(playerid, params[])
{
	new str[128], id, reason[128],rand = random(sizeof(JailRandomSpawn)),time;
	if(PlayerInfo[playerid][pAdmin] >= 3)
	{
		if(sscanf(params, "usd[128]", id, reason, time)) return GameTextForPlayer(playerid,"~g~/jail~w~~n~(id)~w~~n~(reason)~w~~n~(time)",4500,3);
		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) for %d minuites (Reason:%s)", GetName(playerid), playerid, GetName(id), id,time,reason);
		SendClientMessageToAll(BAN, str);
		JailLog(playerid, id, reason);
		SetTimer("Unjail",time*60000,false);
		fr[id] = 0;
		PlayerInfo[id][JailC]++;
		format(str, sizeof(str), "You jailed %s(%d) for %d minuites (Reason:%s)", GetName(id), id,time,reason);
		SendClientMessage(playerid, BAN, str);
        format(str, sizeof(str), ""COL_GREEN"\nYou have been jailed for %d minuites\n(Reason:%s)",time, reason);
       	ShowPlayerDialog(id, 122, DIALOG_STYLE_MSGBOX, ""COL_GREEN"Jailed", str, "OK", "");
	    }
	    else return ErrorMessages(playerid, 1);
    return 1;
}
Unjail function:
Код:
public Unjail(playerid)
{
    PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
	PlayerInfo[playerid][Jail] = 0;
    SetPlayerInterior(playerid, 0);
    inJail[playerid] = false;
    fr[playerid] = 1;
    SpawnPlayer(playerid);
}
Reply
#2

You should set the player position to somewhere too, use "SetPlayerPos" or "SetSpawnInfo"
also you didn't say what's the problem
Reply
#3

You should use it with enums.
Reply
#4

Well, instead of
pawn Код:
SetTimer("Unjail",time*60000,false);
use
pawn Код:
SetTimerEx("Unjail",time*60000,false, "i", playerid);
I hope I helped any feedback is appreciated!
Reply
#5

Whats your problem? you haven't tell anything in your topic?
Reply
#6

Quote:
Originally Posted by SpikY_
Посмотреть сообщение
Whats your problem? you haven't tell anything in your topic?
The problem is that if i jail a player for 1 min so after one min all the server players(not jailed and jailed both) will be unjailed
Reply
#7

pawn Код:
CMD:jail(playerid, params[])
{
    new str[128], id, reason[128],rand = random(sizeof(JailRandomSpawn)),time;
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
        if(sscanf(params, "usd[128]", id, reason, time)) return GameTextForPlayer(playerid,"~g~/jail~w~~n~(id)~w~~n~(reason)~w~~n~(time)",4500,3);
        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) for %d minuites (Reason:%s)", GetName(playerid), playerid, GetName(id), id,time,reason);
        SendClientMessageToAll(BAN, str);
        JailLog(playerid, id, reason);
//      SetTimer("Unjail",time*60000,false); // removed it
        SetTimerEx("Unjail",time*60000,false, "i", id);// added it for specific player
        fr[id] = 0;
        PlayerInfo[id][JailC]++;
        format(str, sizeof(str), "You jailed %s(%d) for %d minuites (Reason:%s)", GetName(id), id,time,reason);
        SendClientMessage(playerid, BAN, str);
        format(str, sizeof(str), ""COL_GREEN"\nYou have been jailed for %d minuites\n(Reason:%s)",time, reason);
        ShowPlayerDialog(id, 122, DIALOG_STYLE_MSGBOX, ""COL_GREEN"Jailed", str, "OK", "");
        }
        else return ErrorMessages(playerid, 1);
    return 1;
}
Reply
#8

Quote:
Originally Posted by gurmani11
Посмотреть сообщение
pawn Код:
CMD:jail(playerid, params[])
{
    new str[128], id, reason[128],rand = random(sizeof(JailRandomSpawn)),time;
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
        if(sscanf(params, "usd[128]", id, reason, time)) return GameTextForPlayer(playerid,"~g~/jail~w~~n~(id)~w~~n~(reason)~w~~n~(time)",4500,3);
        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) for %d minuites (Reason:%s)", GetName(playerid), playerid, GetName(id), id,time,reason);
        SendClientMessageToAll(BAN, str);
        JailLog(playerid, id, reason);
//      SetTimer("Unjail",time*60000,false); // removed it
        SetTimerEx("Unjail",time*60000,false, "i", id);// added it for specific player
        fr[id] = 0;
        PlayerInfo[id][JailC]++;
        format(str, sizeof(str), "You jailed %s(%d) for %d minuites (Reason:%s)", GetName(id), id,time,reason);
        SendClientMessage(playerid, BAN, str);
        format(str, sizeof(str), ""COL_GREEN"\nYou have been jailed for %d minuites\n(Reason:%s)",time, reason);
        ShowPlayerDialog(id, 122, DIALOG_STYLE_MSGBOX, ""COL_GREEN"Jailed", str, "OK", "");
        }
        else return ErrorMessages(playerid, 1);
    return 1;
}
Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)