Kick Problem
#1

I made a custom /kick command, but everytime i use it..it kicks me instead of the targetid. Can someone point out the problem?

pawn Code:
COMMAND:kick(playerid, params[])
{
    if(GetPlayerAdminLevel(playerid) <= 1) return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command!");
    {
        new
            targetid,
            reason[128];
        if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /kick (playerid | name) (reason)");
        else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "That player is not connected!");
        {
            new
                string[128];
            format(string, sizeof(string), "Staff Member %s has kicked %s for %s", PlayerName(playerid), PlayerName(targetid), reason);
            SendClientMessageToAll(COLOR_WHITE, string);
           
            format(string, sizeof(string), "You have been kicked from this server | Reason: %s", reason);
            SendClientMessage(targetid, COLOR_WHITE, string);

            SendClientMessage(playerid, COLOR_WHITE, "You have kicked the player successfully.");
            KickPlayer(targetid, PlayerName(playerid), reason);
        }
    }
    return 1;
}
Reply
#2

Can you post your "KickPlayer" function?
Reply
#3

All it has is the fuction kickplayer(target, kicker, reason) or such and then I have insert mysql query for logs .
Reply
#4

Why not just use Kick(targetid);
Reply
#5

We still need to see the "KickPlayer" function because the error lies in there...
Reply
#6

I was on my blackberry last night, so couldn't post it, I'm home from football now, so here it is:

pawn Code:
stock KickPlayer(playerid, kickername[], reason[])
{
    new string[267];
    format(string, sizeof(string), "INSERT INTO `kicked` (Username, IP, Kicker, Reason) VALUES ('%s', '%s', '%s', '%s')", PlayerName(playerid), PlayerIP(playerid), kickername, reason);
    mysql_query(string);
    Kick(playerid);
}
Should I just change it to like targetid? a bit confused with it
Reply
#7

Okay, I rewrote your code a little. Does this work for you?

pawn Code:
COMMAND:kick(playerid, params[])
{
    new
        targetid,
        reason[128],
        string[128];

    if(GetPlayerAdminLevel(playerid) <= 1)
        return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command!");
    if(sscanf(params, "us[128]", targetid, reason))
        return SendClientMessage(playerid, COLOR_RED, "USAGE: /kick (playerid | name) (reason)");
    if(!IsPlayerConnected(targetid))
        return SendClientMessage(playerid, COLOR_RED, "That player is not connected!");

    format(string, sizeof(string), "Staff Member %s has kicked %s for %s", PlayerName(playerid), PlayerName(targetid), reason);
    SendClientMessageToAll(COLOR_WHITE, string);

    format(string, sizeof(string), "You have been kicked from this server | Reason: %s", reason);
    SendClientMessage(targetid, COLOR_WHITE, string);

    SendClientMessage(playerid, COLOR_WHITE, "You have kicked the player successfully.");
    KickPlayer(playerid, targetid, reason);
    return 1;
}

stock KickPlayer(adminid, targetid, reason[])
{
    new
        szQuery[300];
       
    format(szQuery, sizeof(szQuery), "INSERT INTO `kicked` (Username, IP, Kicker, Reason) VALUES ('%s', '%s', '%s', '%s')", PlayerName(targetid), PlayerIP(targetid), PlayerName(adminid), reason);
    mysql_query(szQuery);
    Kick(targetid);
    return 1;
}
Reply
#8

Sadly, I can't test this out, due to my database being on my webhost which is down atm. I'll let you know a.s.a.p if this works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)