/warn help
#1

Hi, I have been experimenting with a /warn command for my server which was suggested, but I can't seem to get it to work.

pawn Код:
CMD:warn(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        new achat[128], string[128], id;
        if(sscanf(params, "is[128]", id, achat)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /warn [id] [reason]");

        if(PlayerInfo[id][pWarns] == 1)
        {
            PlayerInfo[id][pWarns]++;
            format(string, sizeof(string), "{009DFF}Admin %s {FFFFFF}has warned {009DFF}%s, {FFFFFF}warn level: {009DFF}%d{FFFFFF}.", PlayerName(playerid), PlayerName(id), PlayerInfo[id][pWarns]);
            SendAdminMessage(COLOR_WHITE, string);
            format(string, sizeof(string), "{009DFF}Admin %s {FFFFFF}has warned {009DFF}%s, {FFFFFF}reason: {009DFF}%s{FFFFFF}.", PlayerName(playerid), PlayerName(id), achat);
            SendClientMessageToAll(COLOR_WHITE, string);
        }
        else if(PlayerInfo[id][pWarns] == 2)
        {
            PlayerInfo[id][pWarns]++;
            format(string, sizeof(string), "Admin {009DFF}%s {FFFFFF}has warned {009DFF}%s, {FFFFFF}warn level: {009DFF}%d{FFFFFF}.", PlayerName(playerid), PlayerName(id), PlayerInfo[id][pWarns]);
            SendAdminMessage(COLOR_WHITE, string);
            format(string, sizeof(string), "{009DFF}Admin %s {FFFFFF}has warned {009DFF}%s, {FFFFFF}reason: {009DFF}%s{FFFFFF}.", PlayerName(playerid), PlayerName(id), achat);
            SendClientMessageToAll(COLOR_WHITE, string);
        }
        else if(PlayerInfo[id][pWarns] == 3)
        {
            PlayerInfo[id][pWarns]++;
            format(string, sizeof(string), "{009DFF}Admin %s {FFFFFF}has warned {009DFF}%s, {FFFFFF}warn level: {009DFF}%d{FFFFFF}.", PlayerName(playerid), PlayerName(id), PlayerInfo[id][pWarns]);
            SendAdminMessage(COLOR_WHITE, string);
            format(string, sizeof(string), "{009DFF}Admin %s {FFFFFF}has warn banned {009DFF}%s, {FFFFFF}reason: {009DFF}%s{FFFFFF}.", PlayerName(playerid), PlayerName(id), achat);
            SendClientMessageToAll(COLOR_WHITE, string);
            Ban(id);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "ERROR: You don't seem to be an admin!");
    }
    return 1;
}
If anyone can see a problem with this, i'll be so happy. Thanks!
Reply
#2

dude, why you need all that if checks etc. easy:
pawn Код:
CMD:warn(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 2)
    {
        new achat[128], string[128], id;
        if(sscanf(params, "is[128]", id, achat)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /warn [id] [reason]");
        PlayerInfo[id][pWarns] = PlayerInfo[id][pWarns] + 1;
        format(string, sizeof(string), "{009DFF}Admin %s {FFFFFF}has warned {009DFF}%s, {FFFFFF}warn level: {009DFF}%d{FFFFFF}.", PlayerName(playerid), PlayerName(id), PlayerInfo[id][pWarns]);
        SendAdminMessage(COLOR_WHITE, string);
        format(string, sizeof(string), "{009DFF}Admin %s {FFFFFF}has warned {009DFF}%s, {FFFFFF}reason: {009DFF}%s{FFFFFF}.", PlayerName(playerid), PlayerName(id), achat);
        SendClientMessageToAll(COLOR_WHITE, string);
        if(PlayerInfo[id][pWarns] == 3)
        {
            format(string, sizeof(string), "{009DFF}Admin %s {FFFFFF}has warned {009DFF}%s, {FFFFFF}warn level: {009DFF}%d{FFFFFF}.", PlayerName(playerid), PlayerName(id), PlayerInfo[id][pWarns]);
            SendAdminMessage(COLOR_WHITE, string);
            format(string, sizeof(string), "{009DFF}Admin %s {FFFFFF}has warn banned {009DFF}%s, {FFFFFF}reason: {009DFF}%s{FFFFFF}.", PlayerName(playerid), PlayerName(id), achat);
            SendClientMessageToAll(COLOR_WHITE, string);
            Ban(id);
        }
    }
    else SendClientMessage(playerid, COLOR_RED, "ERROR: You don't seem to be an admin!");
    return 1;
}
Reply
#3

Thanks for that, it works!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)