Kicks ID 0 instead of the ID typed
#1

when i type /kick 8 Reason, it kicks ID 0. Why does this happen?

pawn Code:
CMD:kick(playerid, params[]) //using ZCMD this is how your command will start off looking like.
{
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        SendClientMessage(playerid,COLOR_YELLOW,"Your admin level is not high enough to use this command");
        return 1;
    }
    new adminname[MAX_PLAYER_NAME],otherplayerid,pname[24], reason[128];
    GetPlayerName(otherplayerid,pname,sizeof(pname));
    GetPlayerName(playerid,adminname,sizeof(adminname));
    if(sscanf(params, "uz", otherplayerid, reason))
    SendClientMessage(playerid, 0xFFFFFFFF, "/kick [playerid/name] [reason]");
    else if(otherplayerid == INVALID_PLAYER_ID)
    SendClientMessage(playerid, 0xFFFFFFFF, "This player is not connected");
    else
    {
        new string[250];
        format(string, sizeof(string), "Admin %s kicked %s | Reason: %s",adminname,pname, reason);
        SendClientMessageToAll(0xFFFFFFFF,string);
        Kick(otherplayerid);
     }
    return 1;
}
Reply
#2

Hmm, I'd suggest you to take mine, I don't have too much time to read your whole CMD! ^^

pawn Code:
CMD:kick(playerid, params[])
    {
        if(PlayerInfo[playerid][pAdmin] >= 3) {
            new PID;
            new reason[64];
            new str[128];
            new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, Adminname, sizeof(Adminname));
            GetPlayerName(PID, Playername, sizeof(Playername));
            if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid] [reason]");

            if(!IsPlayerConnected(PID))
                return SendClientMessage(playerid, COLOR_GREY, "Player is not connected!");

            format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
            SendClientMessageToAll(COLOR_RED, str);
            Kick(PID);

        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You have to be level 3 to use that command!");
        }
        return 1;
    }
Reply
#3

If I remember correctly, 'z' as a sscanf parameter was removed and replaced. Take a look at the sscanf release topic again, and please for the love of god space your commands out more so they're readable.
Reply
#4

Try this

pawn Code:
CMD:kick(playerid, params[]) //using ZCMD this is how your command will start off looking like.
{
    if(PlayerInfo[playerid][pAdmin] < 1)
    {
        SendClientMessage(playerid,COLOR_YELLOW,"Your admin level is not high enough to use this command");
        return 1;
    }
    else
    {
           new adminname[MAX_PLAYER_NAME],otherplayerid,pname[24], reason[128];
           if(sscanf(params, "uz", otherplayerid, reason))
           {
                      SendClientMessage(playerid, 0xFFFFFFFF, "/kick [playerid/name] [reason]");
           }
           else
           {
                 GetPlayerName(otherplayerid,pname,sizeof(pname));
                 GetPlayerName(playerid,adminname,sizeof(adminname));
                 new string[250];
                 format(string, sizeof(string), "Admin %s kicked %s | Reason: %s",adminname,pname, reason);
                 SendClientMessageToAll(0xFFFFFFFF,string);
                 Kick(otherplayerid);
           }
     }
    return 1;
}
Reply
#5

I already posted one, which includes everything exactly he wants!
Reply
#6

This happens to me too this is because sscanf and its pretty annoying.

I updated to sscanf 2.5 today lets see if it will get fix'd
Reply
#7

This is indeed a plugin problem, not a scripting problem. The command is fine.
Reply
#8

Checked the log and get this message: [22:25:21] sscanf warning: Strings without a length are deprecated, please add a destination size.

How can i add a destination size?
Reply
#9

Instead of using
pawn Code:
"us"
as your specifiers. Use
pawn Code:
"us[128]"
Your sscanf line should look like this
pawn Code:
if(sscanf(params, "us[128]", otherplayerid, reason))
Don't use "z" it is a depreciated specifier.
Reply
#10

pawn Code:
if(sscanf(params, "us[128]", otherplayerid, reason))
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)