Remove Warning command (Ladmin) +Rep
#1

This command ADD a warning but I want a command to remove 1 warning, but I dont know how :/
pawn Код:
CMD:warn(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 2) {
        new tmp[128], tmp2[128], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid,LIGHTBLUE2, "Usage: /Warn [PlayerID] [Reason]") && SendClientMessage(playerid,orange, "Function: Will give a warning in a specified reason to a specified player");
        new warned = strval(tmp), str[128];
        if(PlayerInfo[warned][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(warned) && warned != INVALID_PLAYER_ID) {
            if(warned != playerid) {
                CMDMessageToAdmins(playerid,"Warn");
                PlayerInfo[warned][Warnings]++;
                if( PlayerInfo[warned][Warnings] == MAX_WARNINGS) {
                    format(str, sizeof (str), "4|- Administrator \"%s\" has kicked \"%s\". | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
                    IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, str);
                    format(str, sizeof (str), "|- Administrator \"%s\" has kicked \"%s\". | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    SendClientMessageToAll(red, str);
                    SaveToFile("KickLog",str);  Kick(warned);
                    return PlayerInfo[warned][Warnings] = 0;
                } else {
                    format(str, sizeof (str), "8|- Administrator \"%s\" has given \"%s\" a Warning. | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
                    IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, str);
                    format(str, sizeof (str), "|- Administrator \"%s\" has given \"%s\" a Warning. | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    return SendClientMessageToAll(yellow, str) && SaveToFile("WarnLog",str);
                }
            } else return SendClientMessage(playerid, red, "ERROR: You cannot warn yourself");
        } else return SendClientMessage(playerid, red, "ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
Reply
#2

PlayerInfo[warned][Warnings]--;
Reply
#3

Quote:
Originally Posted by Tomer!.$
Посмотреть сообщение
PlayerInfo[warned][Warnings]--;
Ok thanks but now I have to do so the command only works like this:
/RemWarn [PlayerID]
(Without having to type a reason).

This is how the command looks like now:

pawn Код:
CMD:remwarn(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 2) {
        new tmp[128], tmp2[128], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid,LIGHTBLUE2, "Usage: /RemWarn [PlayerID]") && SendClientMessage(playerid,orange, "Function: Will remove a warning from a specified player");
        new warned = strval(tmp), str[128];
        if(PlayerInfo[warned][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(warned) && warned != INVALID_PLAYER_ID) {
            if(warned != playerid) {
                CMDMessageToAdmins(playerid,"Warn");
                PlayerInfo[warned][Warnings]--;
                if( PlayerInfo[warned][Warnings] == MAX_WARNINGS) {
                    format(str, sizeof (str), "4|- Administrator \"%s\" has kicked \"%s\". | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
                    IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, str);
                    format(str, sizeof (str), "|- Administrator \"%s\" has kicked \"%s\". | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    SendClientMessageToAll(red, str);
                    SaveToFile("KickLog",str);  Kick(warned);
                    return PlayerInfo[warned][Warnings] = 0;
                } else {
                    format(str, sizeof (str), "8|- Administrator \"%s\" has removed a warning from \"%s\" | (Warnings: %d/%d) -|", pName(playerid), pName(warned), PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
                    IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, str);
                    format(str, sizeof (str), "|- Administrator \"%s\" has removed a warning from \"%s\" | (Warnings: %d/%d) -|", pName(playerid), pName(warned), PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    return SendClientMessageToAll(yellow, str) && SaveToFile("WarnLog",str);
                }
            } else return SendClientMessage(playerid, red, "ERROR: You cannot remove your own warnings");
        } else return SendClientMessage(playerid, red, "ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
Reply
#4

Hope this works:
pawn Код:
CMD:warnremove(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 2) {
        new tmp[128], tmp2[128], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid,LIGHTBLUE2, "Usage: /Warnremove [PlayerID] [Reason]") && SendClientMessage(playerid,orange, "Function: Will remove a warning in a specified reason to a specified player");
        new warned = strval(tmp), str[128];
        if(PlayerInfo[warned][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(warned) && warned != INVALID_PLAYER_ID) {
            if(warned != playerid) {
                CMDMessageToAdmins(playerid,"UnWarn");
                PlayerInfo[warned][Warnings]--;
                if( PlayerInfo[warned][Warnings] == MAX_WARNINGS) {
                    format(str, sizeof (str), "4|- Administrator \%s\ has removed \%s\'s  one warning". | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
                    IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, str);
                    format(str, sizeof (str), "
|- Administrator \%s\ has removed \%s\'s one warning". | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    SendClientMessageToAll(red, str);
                    SaveToFile("KickLog",str);  Kick(warned);
                    return PlayerInfo[warned][Warnings] = 0;
                } else {
                    format(str, sizeof (str), "8|- Administrator \%s\ has removed \%s\'s one warning". | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
                    IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, str);
                    format(str, sizeof (str), "|- Administrator \"%s\" has removed \%s\'s one warning". | Reason: %s (Warnings: %d/%d) -|", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    return SendClientMessageToAll(yellow, str) && SaveToFile("WarnLog",str);
                }
            } else return SendClientMessage(playerid, red, "ERROR: You cannot unwarn yourself");
        } else return SendClientMessage(playerid, red, "ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
Reply
#5

I dont see the difference..

Please read my second post.
Reply
#6

I am only begginer and in my knowldge this think should work
pawn Код:
CMD:remwarn(playerid,params[]) {
    if(PlayerInfo[playerid][Level] >= 2) {
        new tmp[128], tmp2[128], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid,LIGHTBLUE2, "Usage: /RemWarn [PlayerID]") && SendClientMessage(playerid,orange, "Function: Will remove a warning from a specified player");
        new warned = strval(tmp), str[128];
        if(PlayerInfo[warned][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(warned) && warned != INVALID_PLAYER_ID) {
            if(warned != playerid) {
                CMDMessageToAdmins(playerid,"Warn");
                PlayerInfo[warned][Warnings]--;
                if( PlayerInfo[warned][Warnings] == MAX_WARNINGS) {
                    format(str, sizeof (str), "4|- Administrator \"%s\" has kicked \"%s\".(Warnings: %d/%d) -|", pName(playerid), pName(warned), PlayerInfo[warned][Warnings], MAX_WARNINGS);// I change here
                    IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
                    IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, str);
                    format(str, sizeof (str), "|- Administrator \"%s\" has kicked \"%s\". (Warnings: %d/%d) -|", pName(playerid), pName(warned), PlayerInfo[warned][Warnings], MAX_WARNINGS);// I change here
                    SendClientMessageToAll(red, str);
                    SaveToFile("KickLog",str);  Kick(warned);
                    return PlayerInfo[warned][Warnings] = 0;
                } else {
                    format(str, sizeof (str), "8|- Administrator \"%s\" has removed a warning from \"%s\" | (Warnings: %d/%d) -|", pName(playerid), pName(warned), PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
                    IRC_GroupSay(gGroupID2, IRC_ADMINCHANNEL, str);
                    format(str, sizeof (str), "|- Administrator \"%s\" has removed a warning from \"%s\" | (Warnings: %d/%d) -|", pName(playerid), pName(warned), PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    return SendClientMessageToAll(yellow, str) && SaveToFile("WarnLog",str);
                }
            } else return SendClientMessage(playerid, red, "ERROR: You cannot remove your own warnings");
        } else return SendClientMessage(playerid, red, "ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
Reply
#7

Try this made in a few minutes:
pawn Код:
CMD:unwarn(playerid, params[])
{
    if(AccInfo[playerid][Level] < 2) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
    new
        tempname,
        temptext[128];
    if(sscanf(params, "us[128]", tempname, temptext)) return SendClientMessage( playerid, -1, "Usage: /unwarn [PlayerID] [reason]");
    if(!IsPlayerConnected(tempname)) return SendClientMessage( playerid, -1, "Player is not connected.");
    SetPVarInt(tempname, "Warnings", GetPVarInt( tempname, "Warnings") - 1 );
    new
        String[50];
    format(String, sizeof(String), "Admin %u removed your one warning.", playerid);
    SendClientMessage( tempname, -1, String );
    format(String, sizeof(String), "You removed a warning for player %u for %s.", tempname, temptext);
    SendClientMessage(playerid, -1, String);
    return 1;
}
Reply
#8

Quote:
Originally Posted by Faisal_khan
Посмотреть сообщение
Try this made in a few minutes:
pawn Код:
CMD:unwarn(playerid, params[])
{
    if(AccInfo[playerid][Level] < 2) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
    new
        tempname,
        temptext[128];
    if(sscanf(params, "us[128]", tempname, temptext)) return SendClientMessage( playerid, -1, "Usage: /unwarn [PlayerID] [reason]");
    if(!IsPlayerConnected(tempname)) return SendClientMessage( playerid, -1, "Player is not connected.");
    SetPVarInt(tempname, "Warnings", GetPVarInt( tempname, "Warnings") - 1 );
    new
        String[50];
    format(String, sizeof(String), "Admin %u removed your one warning.", playerid);
    SendClientMessage( tempname, -1, String );
    format(String, sizeof(String), "You removed a warning for player %u for %s.", tempname, temptext);
    SendClientMessage(playerid, -1, String);
    return 1;
}
AccInfo? And still the Reason part is there..
Reply
#9

just remove the temtext thingy. I think that should help
Reply
#10

pawn Код:
CMD:unwarn(playerid, params[])
{
    if(PlayerInfo[playerid][Level] >= 2) return SendClientMessage(playerid, COLOR_ERROR, "You are not Admin!");
    new tempname, temptext[128];
    if(sscanf(params, "us[128]", tempname, temptext)) return SendClientMessage( playerid, -1, "Usage: /unwarn [PlayerID] [reason]");
    if(!IsPlayerConnected(tempname)) return SendClientMessage( playerid, -1, "Player is not connected.");
    SetPVarInt(tempname, "Warnings", GetPVarInt( tempname, "Warnings") - 1 );
    new String[50];
    format(String, sizeof(String), "Admin %u removed your one warning.", playerid);
    SendClientMessage( tempname, -1, String );
    format(String, sizeof(String), "You removed a warning for player %u for %s.", tempname, temptext);
    SendClientMessage(playerid, -1, String);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)