How to make a simple ban system with admin name. (Y_INI) -
streetpeace - 12.09.2014
Hello everybody,
Today, I'm going to show you how to do a simple ban system with administrator name.
First, you have to add Banned, AdminBanName in your enum.
pawn Код:
enum PlayerInfo
{
Banned,
AdminBanName[30],
}
Just like this, don't forget to add INI_Int in loadaccount_user.
Now, we're going to create the command,
pawn Код:
CMD:banplayer(playerid, params[])
{
new string[144], idname, reason[30];
First, we create the new variables that we're going to use in our command.
pawn Код:
CMD:banplayer(playerid, params[])
{
new string[144], idname, reason[30];
if(!pInfo[playerid][Administrator]) return SendClientMessage(playerid, -1, "you aren't enabled to use this command");
If player isn't administrator, he can't do this command.
pawn Код:
CMD:banplayer(playerid, params[])
{
new string[144], idname, reason[30];
if(!pInfo[playerid][Administrator]) return SendClientMessage(playerid, -1, "you aren't enabled to use this command");
if(sscanf(params, "us[128]", idname, reason)) return SendClientMessage(playerid, -1, "Correct usage: /banplayer [playerid] [reason]");
We're going to show the administrator the correct example to use this command.
pawn Код:
CMD:banplayer(playerid, params[])
{
new string[144], idname, reason[30];
if(!pInfo[playerid][Administrator]) return SendClientMessage(playerid, -1, "you aren't enabled to use this command");
if(sscanf(params, "us[128]", target, text)) return SendClientMessage(playerid, -1, "Correct usage: /banplayer [playerid] [reason]");
format(string, sizeof(string), "%s has banned %s for %s", Name(playerid), Name(idname), reason);
SendClientMessageToAll(-1, string);
Now we're going to send a message to all players to inform them that the player has been banned.
pawn Код:
CMD:banplayer(playerid, params[])
{
new string[144], idname, reason[30];
if(!pInfo[playerid][Administrator]) return SendClientMessage(playerid, -1, "you aren't enabled to use this command");
if(sscanf(params, "us[128]", target, text)) return SendClientMessage(playerid, -1, "Correct usage: /banplayer [playerid] [reason]");
format(string, sizeof(string), "%s has banned %s for %s", Name(playerid), Name(idname), reason);
SendClientMessageToAll(-1, string);
pInfo[idname][Banned] = 1;
pInfo[idname][AdminBanName] = Name(playerid);
return 1;
Now we save player.
Let's go to the OnPlayerConnect,
pawn Код:
public OnPlayerConnect
{
if(pInfo[playerid][Banned])
{
}
return 1;
}
If player is banned.
pawn Код:
public OnPlayerConnect(playerid)
{
new string[100];
INI_ParseFile(Path(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid);
if(pInfo[playerid][Banned])
{
format(string, sizeof(string), "you have been banned by admin %s", pInfo[playerid][AdminBanName]);
SendClientMessage(playerid, -1, string);
Kick(playerid);
}
return 1;
}
We kick banned player from the server and he gets the admin who bans him.
IMPORTANT PS :
The function who is going to get the name of the administrator must have the same number of letters of the AdminBanName. Short example :
pawn Код:
stock Name(playerid)
{
new name[30];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}
has the same number of
It's important or you're going to get an error.
IMPORTANT PS :
THE INI PARSE FILE AT THE BEGINNING OF THE SCRIPT IN THE FUNC ONPLAYERCONNECT IS IMPORTANT, DO NOT DELETE HIM OR THE BAN SYSTEM ISN'T GOING TO WORK.
I hope that I helped some persons. (and sorry for my bad english, I'm a beginner)
Re: How to make a simple ban system with admin name. (Y_INI) -
biker122 - 12.09.2014
This won't even work..
Re : How to make a simple ban system with admin name. (Y_INI) -
streetpeace - 12.09.2014
Why ?
Re: How to make a simple ban system with admin name. (Y_INI) -
AndreiWow - 05.09.2015
Not working
Re: How to make a simple ban system with admin name. (Y_INI) -
MrSwift - 08.09.2015
Its not working, since the users doesnt have the folder where the bans are written.
Re: How to make a simple ban system with admin name. (Y_INI) -
Variable™ - 08.09.2015
https://sampwiki.blast.hk/wiki/BanEx