SA-MP Forums Archive
Kicks the wrong person - 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: Kicks the wrong person (/showthread.php?tid=292721)



Kicks the wrong person - iNorton - 24.10.2011

My kick command is a bit "weird"

pawn Код:
CMD:kick(playerid,params[])
    {
        if (MasterAccount[playerid][mSuperAdmin] || Character[playerid][cAdminLevel] >= 1)
        {
            new id,n[MAX_PLAYER_NAME],reason[35], on[MAX_PLAYER_NAME], string[128], string2[128];
            if(sscanf(params,"uz",id, reason)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"[SYNTAX]: /kick [PlayerID/PartOfName] [Reason]");
            else if(playerid == INVALID_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"[ERROR]: Player not found");
            else
            {
            GetPlayerName(playerid,n,sizeof(n));
            GetPlayerName(id,on,sizeof(on));
            format(string,sizeof(string),"You have been kicked by Admin: %s for %s",n,reason);
            SendClientMessage(playerid,COLOR_GOLD,string);
            format(string2, sizeof(string), "[INFO]: Admin Action: %s has kicked %s because: %s",n,on,reason);
            SendClientMessageToAll(COLOR_GOLD,string2);
            Kick(id);
            }
        }
        else return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not a Admin");
        return 1;
}
when I do /kick [1] [Test] it kicks me NOT the person who needs to be kicked? umm whats wrong?


Re: Kicks the wrong person - Toni - 24.10.2011

First of all,
pawn Код:
else if(playerid == INVALID_PLAYER_ID) ..
is wrong. Player ID should be 'ID' unless for some odd reason you were checking if you were a invalid player.

pawn Код:
CMD:kick(playerid, params[])
{
    if (MasterAccount[playerid][mSuperAdmin] || Character[playerid][cAdminLevel] >= 1)
    {
        new
            id,
            n[MAX_PLAYER_NAME],
            on[MAX_PLAYER_NAME],
            string[128],
            reason[64]
        ;
        if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SYNTAX]: /kick [PlayerID/PartOfName] [Reason]");
        else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED,"[ERROR]: Player not found");
        else
        {
            GetPlayerName(playerid, n, sizeof(n)); GetPlayerName(id, on, sizeof(on));
           
            format(string, sizeof(string), "You have been kicked by Admin: %s for %s", n, reason);
            SendClientMessage(playerid,COLOR_GOLD,string);            
           
            format(string, sizeof(string), "[INFO]: Admin Action: %s has kicked %s because: %s", n, on, reason);
            SendClientMessageToAll(COLOR_GOLD, string);
            Kick(id);
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not a Admin");
    return 1;
}
Try that. But you didn't really have some wrong stuff...just unneeded arrays and some mistypes @ the SendClientMessageToAll format.


Re: Kicks the wrong person - iNorton - 24.10.2011

Quote:
Originally Posted by Toni
Посмотреть сообщение
First of all,
pawn Код:
else if(playerid == INVALID_PLAYER_ID) ..
is wrong. Player ID should be 'ID' unless for some odd reason you were checking if you were a invalid player.

pawn Код:
CMD:kick(playerid, params[])
{
    if (MasterAccount[playerid][mSuperAdmin] || Character[playerid][cAdminLevel] >= 1)
    {
        new
            id,
            n[MAX_PLAYER_NAME],
            on[MAX_PLAYER_NAME],
            string[128],
            reason[64]
        ;
        if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SYNTAX]: /kick [PlayerID/PartOfName] [Reason]");
        else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED,"[ERROR]: Player not found");
        else
        {
            GetPlayerName(playerid, n, sizeof(n)); GetPlayerName(id, on, sizeof(on));
           
            format(string, sizeof(string), "You have been kicked by Admin: %s for %s", n, reason);
            SendClientMessage(playerid,COLOR_GOLD,string);            
           
            format(string, sizeof(string), "[INFO]: Admin Action: %s has kicked %s because: %s", n, on, reason);
            SendClientMessageToAll(COLOR_GOLD, string);
            Kick(id);
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not a Admin");
    return 1;
}
Try that. But you didn't really have some wrong stuff...just unneeded arrays and some mistypes @ the SendClientMessageToAll format.
That worked! now however it gives a reason to a person that kicks not the person that gets kicked so it gives me the reason why someone is kicked but its suppose to be showing him?


Re: Kicks the wrong person - lolcake - 24.10.2011

Код:
format(string, sizeof(string), "You have been kicked by Admin: %s for %s", n, reason); 
SendClientMessage(id,COLOR_GOLD,string);



Re: Kicks the wrong person - Toni - 24.10.2011

^

I forgot to go over that SendClientMessage before sending it to all - change playerid to id.


Re: Kicks the wrong person - iNorton - 24.10.2011

Nope, if I do so it goes back again, it kick me not the person I do want to kick.


Re: Kicks the wrong person - Toni - 24.10.2011

You're telling me if you change a parameter for SendClientMessage it changes the Kick entry?

Let's do some easy debug...

Under SendClientMessage just add printf("Target ID: %d", id); and under Kick add the same thing. Read what values are given.


Re: Kicks the wrong person - iNorton - 24.10.2011

Quote:
Originally Posted by Toni
Посмотреть сообщение
You're telling me if you change a parameter for SendClientMessage it changes the Kick entry?

Let's do some easy debug...

Under SendClientMessage just add printf("Target ID: %d", id); and under Kick add the same thing. Read what values are given.
lol... When I added that under where u said it started to work correctly...


Re: Kicks the wrong person - Toni - 24.10.2011

Congratulations! Have fun with whatever mysterious thing happened there


Re: Kicks the wrong person - grand.Theft.Otto - 24.10.2011

pawn Код:
CMD:kick(playerid, params[])
{
    if(MasterAccount[playerid][mSuperAdmin] || Character[playerid][cAdminLevel] >= 1)
    {
        new
            id,
            n[MAX_PLAYER_NAME],
            on[MAX_PLAYER_NAME],
            string[128],
            reason[64]
        ;

        if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SYNTAX]: /kick [PlayerID/PartOfName] [Reason]");
        if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED,"[ERROR]: Player not found");

        GetPlayerName(playerid, n, sizeof(n));
        GetPlayerName(id, on, sizeof(on));

        format(string, sizeof(string), "You have been kicked by Admin: %s for %s", n, reason);
        SendClientMessage(id,COLOR_GOLD,string);

        format(string, sizeof(string), "[INFO]: Admin Action: %s has kicked %s because: %s", n, on, reason);
        SendClientMessageToAll(COLOR_GOLD, string);

        Kick(id);
       
        return 1;
    } else return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not a Admin");
}