SA-MP Forums Archive
[FilterScript] [FS][PWN]Basic Banned System - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] [FS][PWN]Basic Banned System (/showthread.php?tid=355584)



[FS][PWN]Basic Banned System - Prosettur - 30.06.2012

It is a simple system of banning, after banned player in Bans folder in the scriptfiles a file called ip player in the ini extension. When a player enters a file with the ip exists, it displays the information for what when and who has been banned. The command to rcon ban only for the administrator / Aban [ID] and the unbans is / Aunban [IP]. Variable PlayerBanned in OnPlayerDisconnect prevents spamom banned players who enter the server and if they are banned, their throws, and most often in OnPlayerDisconnect is the information that the player came out, so if a player is banned, such information will not appear. Since the code does not even have 100 lines, it gives it here. Required sscanf2 and zcmd.
Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>

#define MAXIMAL_PLAYERS 30
#define WHITE "{FFFFFF}"
#define DARK_WHITE "{BBBBBB}"
#define RED "{FF0000}"
#define DARK_RED "{BB0000}"
#define GREEN "{00FF00}"
#define DARK_GREEN "{00BB00}"

new PlayerName[MAXIMAL_PLAYERS][50];
new PlayerIp[MAXIMAL_PLAYERS][50];
new PlayerBanned[MAXIMAL_PLAYERS];
new PlayerBannedDate[MAXIMAL_PLAYERS][50];
new PlayerBannedAdmin[MAXIMAL_PLAYERS][50];
new PlayerBannedReason[MAXIMAL_PLAYERS][150];

public OnPlayerConnect(playerid)
{
	new String[150];
	GetPlayerName(playerid,PlayerName[playerid],50);
	GetPlayerIp(playerid,PlayerIp[playerid],50);
	PlayerBanned[playerid] = 0;
	format(PlayerBannedDate[playerid],50," ");
	format(PlayerBannedAdmin[playerid],50," ");
	format(PlayerBannedReason[playerid],50," ");
	format(String,150,"Bans/%s.ini",PlayerIp[playerid]);
	if(fexist(String))
	{
	    PlayerBanned[playerid] = 1;
	    SendClientMessage(playerid,0,""WHITE">> You ip has been banned.");
	    new File:File = fopen(String,io_read);
	    new Banned[150];
	    fread(File,Banned);
	    sscanf(Banned,"s[50] s[50] s[150]",PlayerBannedAdmin[playerid],PlayerBannedDate[playerid],PlayerBannedReason[playerid]);
	    format(String,150,""WHITE">> You have banned "DARK_WHITE"%s"WHITE".",PlayerBannedDate[playerid]);
	    SendClientMessage(playerid,0,String);
	    format(String,150,""WHITE">> Admin banned you it "DARK_WHITE"%s"WHITE".",PlayerBannedAdmin[playerid]);
	    SendClientMessage(playerid,0,String);
	    format(String,150,""WHITE">> The reason of ban this "DARK_WHITE"%s",PlayerBannedReason[playerid]);
	    SendClientMessage(playerid,0,String);
	    Kick(playerid);
	    return 0;
	}
	return 1;
}

public OnPlayerDisconnect(playerid,reason)
{
	if(PlayerBanned[playerid] == 1) return 0;
	return 1;
}

COMMAND:aban(playerid,params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0,""RED">> You can't use this command.");
	new PlayerID,Reason[150];
	if(sscanf(params,"is[150]",PlayerID,Reason)) return SendClientMessage(playerid,0,""RED">> Type /Aban [ID] [Reason].");
	if(!IsPlayerConnected(PlayerID)) return SendClientMessage(playerid,0,""RED">> This player id not is avaiable.");
	new String[150];
	format(String,150,""RED">> Player "DARK_RED"%s (%i) "RED"has been banned by admin "DARK_RED"%s (%i)"RED". Reason: "DARK_RED"%s",PlayerName[PlayerID],PlayerID,PlayerName[playerid],playerid,Reason);
	SendClientMessageToAll(0,String);
	format(String,150,""RED">> You banned player about ip "DARK_RED"%s"RED".",PlayerIp[PlayerID]);
	SendClientMessage(playerid,0,String);
	BanPlayer(PlayerID,playerid,Reason);
	return 1;
}

COMMAND:aunban(playerid,params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0,""RED">> You can't use this command.");
	new Ip[50];
	if(sscanf(params,"s[50]",Ip)) return SendClientMessage(playerid,0,""RED">> Type /Aunban [IP].");
	new String[150];
	format(String,150,"%s.ini",Ip);
	if(!fexist(String)) return SendClientMessage(playerid,0,""RED">> This ip not be banned.");
	format(String,150,""GREEN">> You unbanned ip "DARK_GREEN"%s"GREEN".",Ip);
	SendClientMessage(playerid,0,String);
	fremove(String);
	return 1;
}

stock BanPlayer(playerid,AdminID,Reason[])
{
	new String[150];
	format(String,150,"Bans/%s.ini",PlayerIp[playerid]);
	new File:File = fopen(String,io_write);
	new Day,Month,Year,Hour,Minute,Second;
	getdate(Year,Month,Day);
	gettime(Hour,Minute,Second);
	format(String,150,"%s [%02d/%02d/%02d][%02d:%02d:%02d] %s",PlayerName[AdminID],Day,Month,Year,Hour,Minute,Second,Reason);
	fwrite(File,String);
	fclose(File);
	Kick(playerid);
	return 1;
}
Sorry for my bad english.


Re: [FS][PWN]Basic Banned System - RedWingz - 30.06.2012

Look's good,
I'll test it later.. Nice work man.


Re: [FS][PWN]Basic Banned System - LaGrande - 30.06.2012

Basic but cool


Re: [FS][PWN]Basic Banned System - $$inSane - 01.07.2012

simple(6/10)


Re: [FS][PWN]Basic Banned System - Unirom Shaw - 01.07.2012

Simple script, good for beginner