How do I
#1

Hey there SA:MP Community,

I've created a jail cmd. But the thing is, how do I find out if the player is already jailed?

Here's my code, please provide with something like "You need this becasue !?Ј$#"
So I can learn why.

pawn Код:
CMD:jail(playerid, reason)
{
    if(pInfo[playerid][AdminLevel] < 2) return 0;
    {
    SendClientMessage(playerid, COLOR_RED, "-Warning- /Jail [Playername/id] [Reason]");
    return 1;
    }
    new id,pjailed;
    if(IsPlayerNPC(id))return SendClientMessage(playerid, COLOR_RED, "-Warning- This player is an Bot.");
    if(id == playerid)return SendClientMessage(playerid, COLOR_RED, "-Warning- You can't jail yourself.");
    if( return SendClientMessage(playerid, COLOR_RED, "This player is already in jail.");
    new reason[128];
    reason = bigstrtok(cmdtext, idx);
    if(!strlen(reason)) return SendClientMessage(playerid, COLOR_RED, "-Warning- /Jail [playername/id] [Reason]",reason);
    JB_Playerinfo[targetid][JB_pJailed]=180;
    SetPlayerInterior(id, 6);
    SetPlayerPos(targetid, 264.3700,77.5700,1001.0391);
    SetPlayerFacingAngle(id, 272.6900);
    TogglePlayerControllable(id, false);
    ResetPlayerMoney(targetid);
    new string[128];
    format(string,sizeof(string), "-AdminInfo- Admin %s has jailed %s [Reason: %d]",pName(playerid),GetName(targetid));
    SendClientMessageToAll(-1,string);
    return 1;
    }
    else
    {
    SendClientMessage(playerid, COLOR_RED, "-Warning- This player isn't online.");
    }
    }
    else SendClientMessage(id, COLOR_RED, "-Warning- You have to be level 2 for this command!");
    return 1;
}
Reply
#2

Well I'm assuming that...

Код:
JB_Playerinfo[targetid][JB_pJailed]=180;
Means they are Jailed, correct?

So you could set it up as so...

Код:
if(JB_Playerinfo[targetid][JB_pJailed] == 180) return SendClientMessage(playerid, 0xFF0000, "Player is already jailed!");
Reply
#3

Variable.
pawn Код:
//Put it under the includes
Jailed[MAX_PLAYERS];
pawn Код:
CMD:jail(playerid, reason)
{
    if(pInfo[playerid][AdminLevel] < 2) return 0;
    {
    SendClientMessage(playerid, COLOR_RED, "-Warning- /Jail [Playername/id] [Reason]");
    return 1;
    }
    new id,pjailed;
    if(IsPlayerNPC(id))return SendClientMessage(playerid, COLOR_RED, "-Warning- This player is an Bot.");
    if(id == playerid)return SendClientMessage(playerid, COLOR_RED, "-Warning- You can't jail yourself.");
    if(Jailed[playerid] == 1)return SendClientMessage(playerid, COLOR_RED, "This player is already in jail.");
    new reason[128];
    reason = bigstrtok(cmdtext, idx);
    if(!strlen(reason)) return SendClientMessage(playerid, COLOR_RED, "-Warning- /Jail [playername/id] [Reason]",reason);
    JB_Playerinfo[targetid][JB_pJailed]=180;
    SetPlayerInterior(id, 6);
    SetPlayerPos(targetid, 264.3700,77.5700,1001.0391);
    SetPlayerFacingAngle(id, 272.6900);
    TogglePlayerControllable(id, false);
    ResetPlayerMoney(targetid);
    Jailed[playerid] = 1;
    new string[128];
    format(string,sizeof(string), "-AdminInfo- Admin %s has jailed %s [Reason: %d]",pName(playerid),GetName(targetid));
    SendClientMessageToAll(-1,string);
    return 1;
    }
    else
    {
    SendClientMessage(playerid, COLOR_RED, "-Warning- This player isn't online.");
    }
    }
    else SendClientMessage(id, COLOR_RED, "-Warning- You have to be level 2 for this command!");
    return 1;
}
Put this in Unjail cmd and under the callbacks OnPlayerSpawn,OnPlayerRequestClass and OnPlayerDeath to avoid bugs
pawn Код:
//Setting back the variable to 0
Jailed[playerid] = 0;
Reply
#4

Код:
if(JB_Playerinfo[targetid][JB_pJailed] > 0) return SendClientMessage(playerid, 0xFF0000, "Player is already jailed!");
This has more sense, due that player's jail time will decrease and it won't be 180 all the time.
Reply
#5

pawn Код:
G:\Server info\Mein - Kopia\gamemodes\gys.pwn(341) : warning 225: unreachable code
G:\Server info\Mein - Kopia\gamemodes\gys.pwn(342) : warning 209: function "S@@_OnPlayerRequestClass" should return a value
G:\Server info\Mein - Kopia\gamemodes\gys.pwn(781) : warning 225: unreachable code
G:\Server info\Mein - Kopia\gamemodes\gys.pwn(784) : error 017: undefined symbol "JB_Playerinfo"
G:\Server info\Mein - Kopia\gamemodes\gys.pwn(784) : error 017: undefined symbol "targetid"
G:\Server info\Mein - Kopia\gamemodes\gys.pwn(784) : error 029: invalid expression, assumed zero
G:\Server info\Mein - Kopia\gamemodes\gys.pwn(784) : fatal error 107: too many error messages on one line
Reply
#6

Anyone? I need the help
Reply
#7

Assuming JB_Playerinfo[targetid][JB_pJailed] is 0 when not jailed:

pawn Код:
if(JB_Playerinfo[playerid][JB_pJailed] != 0) // player is jailed
Reply
#8

Well, I copied that JB_playerinfo from CFW by Nino, but I can't find out whats wrong. So I'm creating a new one.

And I'll probably need help.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)