/ajail command
#4

For offline ban...I'm going use ZCMD, sscanf2, and dini for an example

pawn Код:
CMD:offlineban(playerid, params[])
{
    if(pInfo[playerid][Level] >= 3) //this would be your admin variables instead of mine same with the level you want
    {
        new name[MAX_PLAYER_NAME], reason[64];
        if(sscanf(params, "s[24]S('No Reason')[64]", name, reason)) return SendClientMessage(playerid, 0xCC0000AA, "USAGE: /offlineban <playername> <OPTIONAL:reason>");
       
       
        new file[32];
        format(file, sizeof(file), "WHEREMYFILES/ARE/%s.ini", Name(playerid));
        if(dini_Exists(file)) //We check if the file exists so we can modify it
        {
            if(dini_Int(file, "Banned") == 0)
            {
                dini_IntSet(file, "Banned", 1);
                new str[128];
                format(str,sizeof(str), "%s(%d) has offline banned %s for %s.", Name(playerid), playerid, name, reason);
                SendClientMessageToAll(0x00CCCCAA, str);
                dini_Set(file, "BanReason", reason);
            }
            else return SendClientMessage(playerid, 0xCC0000AA, "This player is already banned!");
        }
        else return SendClientMessage(playerid, 0xCC0000AA, "This player isn't registered!"); //If their file doesn't exist, send an error message
    }
}
CMD:oban(playerid, params[]) return cmd_offlineban(playerid, params);
You'll need this to use the above code.
pawn Код:
stock Name(playerid)
{
    new daname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, daname, sizeof(daname));
    return daname;
}

Then you'd do something like this...
pawn Код:
public OnPlayerConnect(playerid)
{
    new file[32];
    format(file, sizeof(file), "WHEREMYFILES/ARE/%s.ini", Name(playerid));
    if(dini_Exists(file))
    {
        if(dini_Int(file, "Banned") == 1)
        {
            new str[128];
            format(str,sizeof(str), "You were banned while you were offline for %s.", dini_Get(file, "BanReason"));
            SendClientMessage(playerid, 0xCC0000AA, str);
            format(str,sizeof(str), "%s - offline banned for %s", Name(playerid), dini_Get(file, "BanReason"))
            BanEx(playerid, str);
        }
    }
}
Reply


Messages In This Thread
/ajail command - by Polomikey - 21.01.2012, 14:16
Re: /ajail command - by milanosie - 21.01.2012, 14:24
Re: /ajail command - by Polomikey - 21.01.2012, 14:51
Re: /ajail command - by [ABK]Antonio - 21.01.2012, 15:15

Forum Jump:


Users browsing this thread: 2 Guest(s)