12.09.2014, 14:24
(
Последний раз редактировалось streetpeace; 18.09.2014 в 10:46.
)
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.
Just like this, don't forget to add INI_Int in loadaccount_user.
Now, we're going to create the command,
First, we create the new variables that we're going to use in our command.
If player isn't administrator, he can't do this command.
We're going to show the administrator the correct example to use this command.
Now we're going to send a message to all players to inform them that the player has been banned.
Now we save player.
Let's go to the OnPlayerConnect,
If player is banned.
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 :
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)
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],
}
Now, we're going to create the command,
pawn Код:
CMD:banplayer(playerid, params[])
{
new string[144], idname, reason[30];
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");
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]");
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);
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;
Let's go to the OnPlayerConnect,
pawn Код:
public OnPlayerConnect
{
if(pInfo[playerid][Banned])
{
}
return 1;
}
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;
}
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;
}
pawn Код:
name[30];
pawn Код:
AdminBanName[30],
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)