warn cmd help
#1

Hello, this warn cmd i made it doesn't show the reason of the warn.

Is like: Admin user (irc) has warned playername (id) for:

pawn Код:
IRCCMD:warn(botid, channel[], user[], host[], params[])
{
    new ID; new reason[64]; new string[128]; new pname[24]; new string2[128];
    if(IRC_IsOp(botid, channel, user))
    {
        if(isnull(params)) return IRC_GroupSay(gGroupID, channel,"3Usage: !warn [playerid] [reason]");
        if(!IsPlayerConnected(ID))return IRC_GroupSay(gGroupID, channel,"4*** Error: Invalid player ID.");
        GetPlayerName(ID, pname, 24);
        format(string, sizeof(string), "Admin %s (IRC) has warned %s (%d) for: %s", user,pname, ID, reason);
        SendClientMessageToAll(COLOR_GREEN, string);
        IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
        IRC_GroupSay(gGroupID,IRC_ACHANNEL, string);
        SendClientMessage(ID, red, "You have been warned by an IRC admin (IRC) to follow the rules.");
        SendClientMessage(ID, red, "Please follow the rules with /rules");
        PlayerInfo[ID][pWarn] ++;
        SetPVarInt(ID, "Warnings", GetPVarInt(ID, "Warnings") +1);
        if(GetPVarInt(ID, "Warnings") == 3)
        {
            format(string2, sizeof(string2), "[AUTO KICK] %s (%d) Too many admin warnings.", pname, ID);
            SendClientMessageToAll(COLOR_RED, string2);
            IRC_GroupSay(gGroupID,IRC_CHANNEL, string2);
            IRC_GroupSay(gGroupID,IRC_ACHANNEL, string2);
            Kick(ID);
        }
    }
        return 1;
}
Thank you.
Reply
#2

Here you go, I also cleaned your code up since it was a mess

pawn Код:
IRCCMD:warn(botid, channel[], user[], host[], params[]) {
    if(IRC_IsOp(botid, channel, user)) {
       
        new ID, reason[64], string[128], pname[24], string2[128];
       
        if(isnull(params))
            return IRC_GroupSay(gGroupID, channel,"3Usage: !warn [playerid] [reason]");
           
        if(!IsPlayerConnected(ID)) 
            return IRC_GroupSay(gGroupID, channel,"4*** Error: Invalid player ID.");
           
        GetPlayerName(ID, pname, 24);
        format(string, sizeof(string), "Admin %s (IRC) has warned %s (%d) for: %s", user, pname, ID, reason);
        SendClientMessageToAll(COLOR_GREEN, string);
        IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
        IRC_GroupSay(gGroupID,IRC_ACHANNEL, string);
        SendClientMessage(ID, red, "You have been warned by an IRC admin (IRC) to follow the rules.");
        SendClientMessage(ID, red, "Please follow the rules with /rules");
        PlayerInfo[ID][pWarn] ++;
        SetPVarInt(ID, "Warnings", GetPVarInt(ID, "Warnings") +1);
        if(GetPVarInt(ID, "Warnings") == 3) {
            format(string2, sizeof(string2), "[AUTO KICK] %s (%d) Too many admin warnings.", pname, ID);
            SendClientMessageToAll(COLOR_RED, string2);
            IRC_GroupSay(gGroupID,IRC_CHANNEL, string2);
            IRC_GroupSay(gGroupID,IRC_ACHANNEL, string2);
            Kick(ID)
        }
    }
    return 1;
}
Reply
#3

Thanks but help but i get the same problem.
Reply
#4

Don't know about sscanf in irc but how about try using sscanf??
Reply
#5

Quote:
Originally Posted by Romel
Посмотреть сообщение
Don't know about sscanf in irc but how about try using sscanf??
Sscanf can be used on irc too.

Anyway still didn't fixed, any help?
Reply
#6

pawn Код:
if(isnull(params))
if sscanf can be used then Why not trying to use
pawn Код:
if(sscanf(params,"ds[100]", playerid, reason))
? i hope it will work.
Reply
#7

pawn Код:
COMMAND:warn(playerid, params[])
{
    new PlayerToWarn, Reason[128], ReasonMsg[128], Name[24];

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        //  . You can change it to anything you want if you don't want that cmd is for lv 1 admins
        if (APlayerData[playerid][PlayerLevel] >= 1)
        {
            if (sscanf(params, "us[128]", PlayerToWarn, Reason)) SendClientMessage(playerid, 0xFFFF00AA, "Usage: \"/warn <PlayerToWarn> <Reason>\"");
            else
                if (IsPlayerConnected(PlayerToWarn)) // If the player is a valid playerid (he's connected)
                {
                    // Increase the number of warnings
                    APlayerData[PlayerToWarn][Warnings]++;

                    // Get the name of the player who warned the player
                    GetPlayerName(playerid, Name, sizeof(Name));
                    // Send the warned player a message who warned him and why he's been warned
                    format(ReasonMsg, 128, "You have been warned by %s %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
                    SendClientMessage(PlayerToWarn, 0xFFFF00AA, ReasonMsg);
                    format(ReasonMsg, 128, "Reason: %s", Reason);
                    SendClientMessage(PlayerToWarn, 0xFFFF00AA, ReasonMsg);
                    format(ReasonMsg, 128, "~w~Warning %i/%i: ~r~%s~w~", APlayerData[PlayerToWarn][Warnings], AutoKickWarnings, Reason);
                    GameTextForPlayer(PlayerToWarn, ReasonMsg, 5000, 4);

                    // Get the name of the warned player
                    GetPlayerName(PlayerToWarn, Name, sizeof(Name));
                    // Let the admin know who has been warned and why
                    format(ReasonMsg, 128, "You have warned %s (warnings: %i/%i)", Name, APlayerData[PlayerToWarn][Warnings], AutoKickWarnings);
                    SendClientMessage(playerid, 0xFFFF00AA, ReasonMsg);
                    format(ReasonMsg, 128, "Reason: %s", Reason);
                    SendClientMessage(playerid, 0xFFFF00AA, ReasonMsg);

                    // Automatically kick the player if he got 3 warnings (if autokick is enabled)
                    if ((APlayerData[PlayerToWarn][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1))
                        Kick(PlayerToWarn);
                }
                else
                    SendClientMessage(playerid, 0xFF0000FF, "That player isn't online");
        }
        else
            return 0;
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}
Hope it helps
Reply
#8

Quote:
Originally Posted by Private200
Посмотреть сообщение
Hope it helps
.................how can this code help me if you are using YOUR custom variables?

I dont have APlayerData, LoggedIn, PlayerToWarn etc etc.

But thanks for trying to help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)