SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 30/06/2012, 03:52 PM   #1
Prosettur
Little Clucker
 
Join Date: Jun 2012
Posts: 42
Reputation: 5
Default [FS][PWN]Basic Banned System

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.
Code:
#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.
Prosettur is offline   Reply With Quote
Old 30/06/2012, 03:54 PM   #2
RedWingz
Banned
 
Join Date: May 2012
Location: Cluckin' Bell
Posts: 171
Reputation: 25
Default Re: [FS][PWN]Basic Banned System

Look's good,
I'll test it later.. Nice work man.
RedWingz is offline   Reply With Quote
Old 30/06/2012, 10:00 PM   #3
LaGrande
Big Clucker
 
Join Date: Apr 2012
Location: NoWhere
Posts: 138
Reputation: 15
Default Re: [FS][PWN]Basic Banned System

Basic but cool
LaGrande is offline   Reply With Quote
Old 01/07/2012, 03:32 AM   #4
$$inSane
Gangsta
 
$$inSane's Avatar
 
Join Date: Feb 2012
Location: Behind you, you cant see me!!!
Posts: 659
Reputation: 56
Default Re: [FS][PWN]Basic Banned System

simple(6/10)
__________________
$$inSane is offline   Reply With Quote
Old 01/07/2012, 04:57 AM   #5
Unirom Shaw
Huge Clucker
 
Unirom Shaw's Avatar
 
Join Date: May 2012
Location: Solar System
Posts: 209
Reputation: 22
Default Re: [FS][PWN]Basic Banned System

Simple script, good for beginner
Unirom Shaw is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very Basic Fuel System iDeal Scripting Help 15 13/02/2012 01:28 PM
[FilterScript] Basic Admin System. Harry_Sandhu Filterscripts 11 07/08/2011 12:11 PM
[FilterScript] [FS]Basic Fuel System! -BETA- [NYRP]Mike. Filterscripts 23 20/04/2011 04:20 PM
need the a basic login system aspire5630 Help Archive 3 04/07/2009 05:06 PM


All times are GMT. The time now is 12:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.