help with jail and unjail
#1

if(strcmp(cmd, "/jail", true) == 0) // Jails a player
{

if (adminlevel[playerid] >= 2)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "USAGE: /jail [name/id] [reason]");
return 1;
}
new targetid = ReturnUser(tmp);
if(IsPlayerConnected(targetid))
{
if(targetid != INVALID_PLAYER_ID)
{
if(jail[giveplayerid] == 0)
{
GetPlayerName(targetid, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, sendername, sizeof(sendername));
new reason[128];
reason = bigstrtok(cmdtext, idx);
if(!strlen(reason)) return SendClientMessage(playerid, ORANGE, "USAGE: /jail [name/id] [reason]");
format(string, sizeof(string), "You got jailed by Admin %s. Reason: %s", sendername, reason);
SendClientMessage(targetid, ADMIN_RED, string);
format(string, sizeof(string), "Administrator %s jailed %s. [ Reason: %s ]",sendername,giveplayername, reason);
SendClientMessageToAll(ADMIN_RED,string);
jail[targetid] = 1;
OnPlayerJailed(targetid);
return 1;
}
else SendClientMessage(playerid, RED, "Player is already jailed!");
}
else
{
format(string, sizeof(string), "%d is not an active player.", targetid);
SendClientMessage(playerid, RED, string);
}
}
else
{
format(string, sizeof(string), "%d is not an active player.", targetid);
SendClientMessage(playerid, RED, string);
}
}
else SendClientMessage(playerid, RED, "You are not an admin with the required level.");
return 1;
}

if(strcmp(cmd, "/unjail", true) == 0) // Unjails a player
{

if (adminlevel[playerid] >= 2)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "USAGE: /unjail [name/id]");
return 1;
}

new targetid = ReturnUser(tmp);
if(targetid != INVALID_PLAYER_ID)
{
if(jail[giveplayerid] == 1)
{
GetPlayerName(targetid, giveplayername, sizeof(giveplayername));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "Administrator %s unjailed %s",sendername, giveplayername);
SendClientMessageToAll(ADMIN_RED,string);
jail[targetid] = 0;
OnPlayerUnjailed(targetid);
}
else SendClientMessage(playerid, RED, "Player is not jailed!");
}
else
{
format(string, sizeof(string), "%d is not an active player.", targetid);
SendClientMessage(playerid, RED, string);
}
}
else SendClientMessage(playerid, RED, "You cannot use this command!");
return 1;
}


this is my jail commands to jail a player which admins can only do ! the /jail command works correctly but /unjail is not working ! i cannot unjail a person ! i cannot find the problem and i dont know how to fix it ! So please help !
Reply
#2

place in [code]
Reply
#3

Give this a try:

pawn Код:
if(!strcmp(cmd, "/jail", true, 5) // Jails a player
{
    if(adminlevel[playerid] < 2) return SendClientMessage(playerid, RED, "You are not an admin with the required level.");

    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, ORANGE, "USAGE: /jail [name/id] [reason]");

    new targetid = ReturnUser(tmp);
    if(targetid == INVALID_PLAYER_ID)
    {
        format(string, sizeof(string), "%d is not an active player.", targetid);
        return SendClientMessage(playerid, RED, string);
    }
    else if(jail[giveplayerid] == 1) return SendClientMessage(playerid, RED, "Player is already jailed!");
    else
    {
        GetPlayerName(targetid, giveplayername, sizeof(giveplayername));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new reason[128];
        reason = bigstrtok(cmdtext, idx);
        if(!strlen(reason)) return SendClientMessage(playerid, ORANGE, "USAGE: /jail [name/id] [reason]");
        format(string, sizeof(string), "You got jailed by Admin %s. Reason: %s", sendername, reason);
        SendClientMessage(targetid, ADMIN_RED, string);
        format(string, sizeof(string), "Administrator %s jailed %s. [ Reason: %s ]",sendername,giveplayername, reason);
        SendClientMessageToAll(ADMIN_RED,string);
        jail[targetid] = 1;
        OnPlayerJailed(targetid);
    }
    return 1;
}

if(!strcmp(cmd, "/unjail", true, 7)) // Unjails a player
{
    if(adminlevel[playerid] < 2) return SendClientMessage(playerid, RED, "You cannot use this command!");

    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        return SendClientMessage(playerid, ORANGE, "USAGE: /unjail [name/id]");
    }

    new targetid = ReturnUser(tmp);
    if(targetid == INVALID_PLAYER_ID)
    {
        format(string, sizeof(string), "%d is not an active player.", targetid);
        return SendClientMessage(playerid, RED, string);
    }
    else if(jail[giveplayerid] == 0) return SendClientMessage(playerid, RED, "Player is not jailed!");
    else
    {
        GetPlayerName(targetid, giveplayername, sizeof(giveplayername));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "Administrator %s unjailed %s",sendername, giveplayername);
        SendClientMessageToAll(ADMIN_RED, string);
        jail[targetid] = 0;
        OnPlayerUnjailed(targetid);
    }
    return 1;
}
Reply
#4

P0thead, [pawn] is easy to read but not the best!
[code] allows you to copy and paste text
[pawn] does it in a few lines like if(!strcmp(cmd, "/unjail", true, 7)) // Unjails a player{ if(adminlevel[playerid] < 2) return SendClientMessage(playerid, RED, "You cannot use this command!"); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) aight' see?
Reply
#5

maybe the problem is with
OnPlayerUnjailed(targetid);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)