SA-MP Forums Archive
Kick command is kicking the player using the command - 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: Kick command is kicking the player using the command (/showthread.php?tid=539492)



Kick command is kicking the player using the command - Josh_Main - 28.09.2014

Hey, my kick command isn't kicking the player it's meant to kick, it keeps kicking me (the player using kick). Not sure what I'm doing wrong? Here's the command:

pawn Код:
if(listitem == 2)
            {
                new id;
                new string[128];
                new name[MAX_PLAYERS];
                new name2[MAX_PLAYERS];
                GetPlayerName(id, name2, sizeof(name2));
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "You have kicked %s from the server", name2);
                SendClientMessage(playerid, COLOR_WHITE, string);
                format(string, sizeof(string), "%s was kicked from the server by %s", name2, name);
                SendClientMessageToAll(COLOR_WHITE, string);
                Kick(id); // <-------- It's not kicking "id", it's kicking playerid
                return 1;
            }
EDIT: It seems my ID 0 is bugged. I don't know what's going on. Whenever ID 0 tries to use a command, it uses it on himself. What am I doing wrong? I am not using sscanf at all.




Also, when it formats the strings, how do I get rid of the underscore when it says "was kicked by John_Doe"? I would like it to be "was kicked by John Doe" with a space instead of an underscore. In the normal chat, I've gotten rid of the underscores using
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    format(string,sizeof(string),"%s says: %s",RemoveUnderScore(playerid),text);
    SendClientMessageToAll(COLOR_WHITE,string);
    return 0;
}
I've already created the stock for the above ^^

pawn Код:
stock RemoveUnderScore(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}
Whenever a string comes up, I'd rather a space display instead of the underscore.

Any help would be greatly appreciated. Thanks in advanced!


Re: Kick command is kicking the player using the command - EnforcerDon - 28.09.2014

pawn Код:
if(listitem == 2)
            {
                new id; // where do you assign this a value?

                new string[128];
                new name[MAX_PLAYERS];
                new name2[MAX_PLAYERS];
                GetPlayerName(id, name2, sizeof(name2));
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "You have kicked %s from the server", name2);
                SendClientMessage(playerid, COLOR_WHITE, string);
                format(string, sizeof(string), "%s was kicked from the server by %s", name2, name);
                SendClientMessageToAll(COLOR_WHITE, string);
                Kick(id); // <-------- It's not kicking "id", it's kicking playerid
                return 1;
            }
I don't see you assign a value to the variable "id", therefore "id" will equal zero.

I assume that while you are testing your server, your playerid will also be zero, therefore when you Kick(id), and id is zero, you will kick yourself.


Quote:

Configure an 100% FREE San Andreas Multiplayer Server today!
Visit http://www.infinity-host.net to get started.

btw your link (^^) is broken

______________

If I have helped you, please rep++ to show your appreciation.


Re: Kick command is kicking the player using the command - Josh_Main - 28.09.2014

Yes that's it I think man! I'm gonna fix it up, I think that's why my ID 0 is always bugged. Whenever using commands, if you are ID 0 it uses them on yourself.


Re: Kick command is kicking the player using the command - Josh_Main - 28.09.2014

Quote:
Originally Posted by EnforcerDon
Посмотреть сообщение
pawn Код:
if(listitem == 2)
            {
                new id; // where do you assign this a value?

                new string[128];
                new name[MAX_PLAYERS];
                new name2[MAX_PLAYERS];
                GetPlayerName(id, name2, sizeof(name2));
                GetPlayerName(playerid, name, sizeof(name));
                format(string, sizeof(string), "You have kicked %s from the server", name2);
                SendClientMessage(playerid, COLOR_WHITE, string);
                format(string, sizeof(string), "%s was kicked from the server by %s", name2, name);
                SendClientMessageToAll(COLOR_WHITE, string);
                Kick(id); // <-------- It's not kicking "id", it's kicking playerid
                return 1;
            }
I don't see you assign a value to the variable "id", therefore "id" will equal zero.

I assume that while you are testing your server, your playerid will also be zero, therefore when you Kick(id), and id is zero, you will kick yourself.



btw your link (^^) is broken

______________

If I have helped you, please rep++ to show your appreciation.
Yeah hahah thanks man, didn't even realise I gotta change it lol


Re: Kick command is kicking the player using the command - EnforcerDon - 28.09.2014

Haha, I hate things like that myself, you lose hair looking for a problem, then when you find it you feel like a total loser because it was so simple to start with


Re: Kick command is kicking the player using the command - Josh_Main - 28.09.2014

Quote:
Originally Posted by EnforcerDon
Посмотреть сообщение
Haha, I hate things like that myself, you lose hair looking for a problem, then when you find it you feel like a total loser because it was so simple to start with
Yeah man haha But I'm not sure how to add a value to my ID variable. How can I do that haha


Re: Kick command is kicking the player using the command - Ox1gEN - 28.09.2014

Bro, you can not kick a specifiec ID if you are using a listitem.
I was about to write how you are going to define the ID variable but then I noticed that you need to show the player an inputtext dialog checking for the id, etc, plus making the ID variable global.


Re: Kick command is kicking the player using the command - EnforcerDon - 28.09.2014

Quote:
Originally Posted by Josh_Main
Посмотреть сообщение
Yeah man haha But I'm not sure how to add a value to my ID variable. How can I do that haha
Use the OnPlayerCommandText callback to detect when an admin or someone types /kick {playerid} or something, then call code I PMed you, as such

pawn Код:
kickAPlayer(idToKick, playerid);
you will need to use strcmp or sscanf to do the commands, but if you need help with commands, that is a different issue (which as it turns out, I could also help you with).


Re: Kick command is kicking the player using the command - Josh_Main - 28.09.2014

Quote:
Originally Posted by Ox1gEN
Посмотреть сообщение
Bro, you can not kick a specifiec ID if you are using a listitem.
I was about to write how you are going to define the ID variable but then I noticed that you need to show the player an inputtext dialog checking for the id, etc, plus making the ID variable global.
Do you mean I need to use an DIALOG_STYLE_INPUT dialog to write in the reason why the player is being kicked?


Re: Kick command is kicking the player using the command - Ox1gEN - 28.09.2014

Yes, that's what I mean, but you can like do that when he presses to kick a player it'll show a DIALOG_STYLE_INPUT dialog, that way you can ask for the ID and for the reason, everything will be better.