help with jail and unjail
#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


Messages In This Thread
help with jail and unjail - by James124 - 15.08.2010, 02:33
Re: help with jail and unjail - by CT_Ronnie_Deo - 15.08.2010, 03:10
Re: help with jail and unjail - by PotH3Ad - 15.08.2010, 03:34
Re: help with jail and unjail - by Mike_Peterson - 15.08.2010, 07:58
Re: help with jail and unjail - by akis_tze - 15.08.2010, 09:28

Forum Jump:


Users browsing this thread: 1 Guest(s)