SA-MP Forums Archive
/warn help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /warn help (/showthread.php?tid=286035)



/warn help - Luis- - 26.09.2011

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!


Re: /warn help - System64 - 26.09.2011

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;
}



Re: /warn help - Luis- - 26.09.2011

Thanks for that, it works!