SA-MP Forums Archive
[Tutorial] Easy /Ban and /Kick - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Easy /Ban and /Kick (/showthread.php?tid=372089)



Easy /Ban and /Kick - [Y]P90 - 25.08.2012

Hello everybody, this is my first thread here so both good critics and bad are accepted. However, Iґve been working with PAWN for several years. In this topic you will learn how to do a /ban and /kick command easily.

First include this files on top of your script:
Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
Then we can proceed to creating the commands:

The ban command:
Code:
CMD:ban(playerid,params[])
{
new targetid;
if(!sscanf(params, "u", targetid))
{
if(IsPlayerAdmin(playerid)) //Checks if player is RCON. Can also change it to PlayerInfo[playerid][pAdmin]
{
if(IsPlayerConnected(targetid)) //Checks if the player to be banned is connected
{
SendClientMessage(playerid,-1,"SERVER: You have been banned from the server.");//Sends the banned a message
Ban(targetid); //Bans him
}
}
}
return 1;
}
The kick command:
Code:
CMD:kick(playerid,params[])
{
new targetid;
if(!sscanf(params, "u", targetid))
{
if(IsPlayerAdmin(playerid)) //Checks if player is RCON. Can also change it to PlayerInfo[playerid][pAdmin]
{
if(IsPlayerConnected(targetid)) //Checks if the player to be kicked is connected
{
SendClientMessage(playerid,-1,"SERVER: You have been kicked from the server.");//Sends the kicked a message
Kick(targetid); //Kicks him
}
}
}
return 1;
}
Please comment if it didnґt work for you or if you have any request to be added, because iґm more than happy to help you.


Re: Easy /Ban and /Kick - SAMPHacker - 25.08.2012

pawn Code:
Ban(targetid); //Kicks him
lolwut ?


Respuesta: Easy /Ban and /Kick - [Y]P90 - 25.08.2012

LOL Sorry i confused. Its now fixed to Kick(targetid);


Re: Easy /Ban and /Kick - budelis - 25.08.2012

Change this:

Code:
Kick(targetid); //Kicks him
SendClientMessage(playerid,-1,"SERVER: You have been banned from the server.");//Sends the kicked a message
To this:

Code:
SendClientMessage(targetid,-1,"SERVER: You have been banned from the server.");//Sends the kicked a message
Kick(targetid); //Kicks him



Re: Easy /Ban and /Kick - SAMPHacker - 25.08.2012

Change This:
pawn Code:
SendClientMessage(playerid,-1,"SERVER: You have been banned from the server.");//Sends the kicked a message
To This:
pawn Code:
SendClientMessage(playerid,-1,"SERVER: You have been kicked from the server.");//Sends the kicked a message



Respuesta: Easy /Ban and /Kick - [Y]P90 - 25.08.2012

LOL Iґm very sorry guys, I did this in a hurry
I edited now


Re: Easy /Ban and /Kick - SAMPHacker - 25.08.2012

Every one make mistakes :3


Re: Easy /Ban and /Kick - Devilxz97 - 25.08.2012

Quote:
Originally Posted by budelis
View Post
Change this:

Code:
Kick(targetid); //Kicks him
SendClientMessage(playerid,-1,"SERVER: You have been banned from the server.");//Sends the kicked a message
To this:

Code:
SendClientMessage(targetid,-1,"SERVER: You have been banned from the server.");//Sends the kicked a message
Kick(targetid); //Kicks him
or maybe use this.
pawn Code:
new pname[MAX_PLAYER_NAME], str[256];
    new targetid;
    GetPlayerName(targetid, pname, sizeof(pname));
    format(str, sizeof(str), "%s has been kicked from the server", pname);
    SendClientMessageToAll(-1, str);



AW: Easy /Ban and /Kick - [Y]P90 - 25.08.2012

Yes, but that would fill up the chat a lot, and if you want a RP for example it wouldnґt be good
But if you donґt care about it or are not making a RP server it would be good too.
@GoldenFox you can use the RCON command for that:
Code:
/rcon unban <ip>



Re: Easy /Ban and /Kick - PawnFox - 27.08.2012

Quote:
Originally Posted by SAMPHacker
View Post
Change This:
pawn Code:
SendClientMessage(playerid,-1,"SERVER: You have been banned from the server.");//Sends the kicked a message
To This:
pawn Code:
SendClientMessage(playerid,-1,"SERVER: You have been kicked from the server.");//Sends the kicked a message
Whats the difference ?. Its same shit.

If is 'playerid' the message will appear only to admin ...

Change 'playerid' to 'targetid' and then the message will appear to banned player.

And also, you could add and a reason for kick / ban .. /ban [id] [reason] ..

Anyway is more a snippet then a tutorial.