Simple Ban System Tutorial -
GoldZoroGrab - 23.12.2012
Hey Guys....
I Will Show You How To Create A Simple Ban System By Rcon Admins
Add This In The Top Of The Script if you don't have one like it
pawn Код:
#define PATH "/Users/%s.ini"
Step One:
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <YSI\y_ini>
//Note: Gonna Give You Includes Link In The End Of The Post [Don't Copy This Note BTW lol]
Step Two:
pawn Код:
enum PlayerInfo
{
Banned
};
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Banned",SInfo[playerid][Banned]);
return 1;
}
//Note: Here So We Can Make The Banned To Save The Stats ;)
//Note: Put This Above The Command That I'll Show Below[Don't Copy This Note BTW lol]
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}//Thats Also To Read And Load The Player Stats (we Added only ban) so it will load only ban
Step Three:
pawn Код:
command(ban, playerid, params[])
{
if(IsPlayerAdmin(playerid))//RCON
{
new ID, R[25], string[100];//R = Reason
new name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
if(sscanf(params, "is", ID, R)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /ban [ID] [Reason]");
{
if(ID != INVALID_PLAYER_ID)
{
SInfo[ID][Banned]=1;//To Make Player Banned When He Connect It Kick Him
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(ID, name2, sizeof(name2));
format(string, sizeof(string), "%s[%d] has been banned By The Admin %s[%d] - %s", ID,name2, playerid, name, R);
SendClientMessageToAll(0xFF1493FF, string);
Kick(ID);
}
else SendClientMessage(playerid, 0xFF0000AA, "ID Not Connected.");
}
}
else SendClientMessage(playerid, 0xFF0000AA, "Only Admins Can Use This COmmand.");
Step 4:
We Added
pawn Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
Before the if(SInfo[playerid][banned]) because first it loads the stats then check if player is banned
pawn Код:
public OnPlayerConnect(playerid)
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);//Thats Hard To Explain, Just To Load The Data
if(SInfo[playerid][Banned]==1)
{
SendClientMessage(playerid, 0xFF1493FF, "You Are Banned From The Server, Kicked!!!.");
Kick(playerid);
}
return 1;
}
Step 5:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
INI_WriteInt(File,"Banned",SInfo[playerid][Banned]);
return 1;
}
If You Found Any Bug. Inform Me
To UnBan A Playeer goto the scriptfile - playeruser then PlayerBanned = 0
SSCANF =
https://sampforum.blast.hk/showthread.php?tid=120356
ZCMD =
https://sampforum.blast.hk/showthread.php?tid=91354
YINI =
https://sampforum.blast.hk/showthread.php?tid=175565
Re: Simple Ban System Tutorial -
Havak - 23.12.2012
Nice tutorial, thanks. Helped me out, I'm pretty shit at scripting :P
Re: Simple Ban System Tutorial -
GoldZoroGrab - 23.12.2012
Quote:
Originally Posted by Havak
Nice tutorial, thanks. Helped me out, I'm pretty shit at scripting :P
|
No Problem Bro
Re: Simple Ban System Tutorial -
[HiC]TheKiller - 23.12.2012
The tutorial was a cool idea but it simply wouldn't work. You're just preventing a certain playerid from joining which means that every person under that playerid will be kicked on connect rather than a name being banned. Just use the ban function or save names into a file / database and check it when a player connects.
Re: Simple Ban System Tutorial -
GoldZoroGrab - 23.12.2012
so ill change OnPlayerConnect to OnPlayerRequestClass
and tommorow when i wake up (going to sleep now) im gonna make little edits and add another include so i remove all it's bugs
thanks to make me remember TheKillr
Good Night Guys
Re: Simple Ban System Tutorial -
thefatshizms - 24.12.2012
When doing the ban command you are setting playerid as banned not I'd also you can shorten this down to about 10 lines and save a lot of space plus looks neater
Re: Simple Ban System Tutorial -
Lynn - 24.12.2012
Should explain everything more.
Re: Simple Ban System Tutorial -
Djole1337 - 24.12.2012
Quote:
Originally Posted by GoldZoroGrab
so ill change OnPlayerConnect to OnPlayerRequestClass
|
You obviously don't get him.
Re: Simple Ban System Tutorial -
GoldZoroGrab - 24.12.2012
Quote:
Originally Posted by Mr_DjolE
You obviously don't get him.
|
I Think I Did Know, Please If there is other bugs, you can inform me also :P
Re: Simple Ban System Tutorial -
Private200 - 24.12.2012
Quote:
Originally Posted by GoldZoroGrab
I Think I Did Know, Please If there is other bugs, you can inform me also :P
|
They shall not inform you because you made a tutorial and you have to find out what's the problem is and fix them by your self ! You had to explain everything more . It is not good explained .