Raised This Month: $ Target: $400
 0% 

Improve anti fast fire method and optimize ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
faki
Senior Member
Join Date: Jul 2013
Old 07-25-2013 , 10:37  
Reply With Quote #1

here is some edits of original anti fire plugin:
Code:
#include <amxmodx>
#include <hamsandwich>
#include <amxmisc>
#include <engine>

#define PLUGIN "Anti FastFire"
#define VERSION "1.2"
#define AUTHOR "Darksnow"

new bool:g_IsAlive[ 33 ]

#define MAX_PLAYERS 32 

new countBullets[MAX_PLAYERS+1]
new g_nCurWeapon[MAX_PLAYERS][2]
new g_MaxPlayers

new g_Classname1[] = "fastfire"

new cvar_af_active, cvar_af_max;

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_event( "CurWeapon", "Event_ShotFired",  "b" )
	cvar_af_active = register_cvar("amx_af","1")
	cvar_af_max = register_cvar("amx_af_max","16")

	RegisterHam(Ham_Spawn, "player", "spawn_player", 1)

	//fast fire task
	new Ent = create_entity("info_target")
	entity_set_string(Ent,EV_SZ_classname,g_Classname1)
	entity_set_float(Ent,EV_FL_nextthink,1.0)
	register_think(g_Classname1,"checkBulletCount")
	//end
}

public client_connect(id)
{
g_IsAlive[ id ] = false 
}

public spawn_player(id)
{
if(is_user_alive(id))
{
g_IsAlive[id] = true
}
}

public Event_ShotFired( id ) 
{ 
	new weaponID = read_data( 2 ) 
	new wAmmo = read_data( 3 ) 

	g_MaxPlayers = get_maxplayers()
	
	if( g_nCurWeapon[id-1][0] != weaponID ) // User Changed Weapons.. 
	{ 
		g_nCurWeapon[id-1][0] = weaponID 
		g_nCurWeapon[id-1][1] = wAmmo 
		return PLUGIN_CONTINUE 
	} 
	if( g_nCurWeapon[id-1][1] < wAmmo ) // User Reloaded.. 
	{ 
		g_nCurWeapon[id-1][1] = wAmmo 
		return PLUGIN_CONTINUE 
	} 
	if( g_nCurWeapon[id-1][1] == wAmmo ) // User did something else, but didn't shoot.. 
		return PLUGIN_CONTINUE 
	g_nCurWeapon[id-1][1] = wAmmo 
	g_nCurWeapon[id-1][0] = weaponID 

	countBullets[id]++ //Counting the bullets, one by one, all day long :)

	return PLUGIN_CONTINUE 
}  

public checkBulletCount(Ent)
{
	if (get_pcvar_num(cvar_af_active) == 1)
	{
		for(new id=1;id<=g_MaxPlayers;id++)
		{
			if(g_IsAlive[id])
			{
				if (countBullets[id] > get_pcvar_num(cvar_af_max))
				{
					new Name[32], szIP[40];
					get_user_name(id,Name,31)
					get_user_ip ( id, szIP, charsmax(szIP) , 1 );
					client_print(id, print_chat,"[Anti FastFire] %s using FastFire type of cheat",Name)
					server_cmd("amx_ban ^"500^" ^"%s^" ^"Banned for cheating^"", szIP)
					
				}
			}
			countBullets[id] = 0
		}
	}
	entity_set_float(Ent,EV_FL_nextthink,1.0)
}
Tell me how ot improve detection for fast fire and how more optimize the code.

Please, someone redit this code to works with Ham_Weapon_PrimaryAttack from register_event( "CurWeapon", "Event_ShotFired", "b" )
.

Last edited by YamiKaitou; 07-25-2013 at 11:38.
faki is offline
faki
Senior Member
Join Date: Jul 2013
Old 07-25-2013 , 13:45   Re: Improve anti fast fire method and optimize ?
Reply With Quote #2

I do it by myself but i have question, here is the code:
Quote:
#include <amxmodx>
#include <hamsandwich>
#include <amxmisc>
#include <engine>

#define PLUGIN "Anti FastFire"
#define VERSION "1.2"
#define AUTHOR "Darksnow"

new bool:g_IsAlive[ 33 ]

#define MAX_PLAYERS 32

new countBullets[MAX_PLAYERS+1]
new g_nCurWeapon[MAX_PLAYERS][2]
new g_MaxPlayers

new g_Classname1[] = "fastfire"

new cvar_af_active, cvar_af_max;

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

cvar_af_active = register_cvar("amx_af","1")
cvar_af_max = register_cvar("amx_af_max","16")

RegisterHam(Ham_Spawn, "player", "spawn_player", 1)


new const weaponIdentifiers[][] =
{
"weapon_glock18",
"weapon_elite",
"weapon_p228",
"weapon_usp",
"weapon_deagle",
"weapon_fiveseven",
"weapon_m3",
"weapon_xm1014",
"weapon_mp5navy",
"weapon_tmp",
"weapon_p90",
"weapon_mac10",
"weapon_ump45",
"weapon_famas",
"weapon_sg552",
"weapon_ak47",
"weapon_m4a1",
"weapon_aug",
"weapon_scout",
"weapon_awp",
"weapon_g3sg1",
"weapon_sg550",
"weapon_galil",
"weapon_m249"
}

for( new i = 0; i < sizeof weaponIdentifiers; i++ )
{
RegisterHam( Ham_Weapon_PrimaryAttack, weaponIdentifiers[ i ], "Weps_PrimaryAttack_Pre", false );
}

//fast fire task
new Ent = create_entity("info_target")
entity_set_string(Ent,EV_SZ_classname,g_Class name1)
entity_set_float(Ent,EV_FL_nextthink,1.0)
register_think(g_Classname1,"checkBulletCount ")
//end

g_MaxPlayers = get_maxplayers();
}

public client_connect(id)
{
g_IsAlive[ id ] = false
}

public spawn_player(id)
{
if(is_user_alive(id))
{
g_IsAlive[id] = true
}
}

public Weps_PrimaryAttack_Pre( const weapon )
{

new weaponID = read_data( 2 )
new wAmmo = read_data( 3 )

for(new id=1;id<=g_MaxPlayers;id++) {


if( g_nCurWeapon[id-1][0] != weaponID ) // User Changed Weapons..
{
g_nCurWeapon[id-1][0] = weaponID
g_nCurWeapon[id-1][1] = wAmmo
return PLUGIN_CONTINUE
}
if( g_nCurWeapon[id-1][1] < wAmmo ) // User Reloaded..
{
g_nCurWeapon[id-1][1] = wAmmo
return PLUGIN_CONTINUE
}
if( g_nCurWeapon[id-1][1] == wAmmo ) // User did something else, but didn't shoot..
return PLUGIN_CONTINUE
g_nCurWeapon[id-1][1] = wAmmo
g_nCurWeapon[id-1][0] = weaponID

countBullets[id]++ //Counting the bullets, one by one, all day long
}
return PLUGIN_CONTINUE

}

public checkBulletCount(Ent)
{
if (get_pcvar_num(cvar_af_active) == 1)
{
for(new id=1;id<=g_MaxPlayers;id++)
{
if(g_IsAlive[id])
{
if (countBullets[id] > get_pcvar_num(cvar_af_max))
{
new Name[32], szIP[40];
get_user_name(id,Name,31)
get_user_ip ( id, szIP, charsmax(szIP) , 1 );
client_print(id, print_chat,"[Anti FastFire] %s using FastFire type of cheat",Name)
server_cmd("amx_ban ^"500^" ^"%s^" ^"Banned for cheating^"", szIP)

}
}
countBullets[id] = 0
}
}
entity_set_float(Ent,EV_FL_nextthink,1.0)
}
in the bold text i have marked some code, do this code need some corrections or optimizations ?
faki is offline
avril-lavigne
Banned
Join Date: Apr 2009
Old 07-25-2013 , 17:23   Re: Improve anti fast fire method and optimize ?
Reply With Quote #3

look at VEN`s toturial how to catch shot event
__________________
VDS in Europe 1 gb/s unmetered.Any configurations.
I accept Paypal, Moneybookers,etc
avril-lavigne is offline
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

Forum Jump


All times are GMT -4. The time now is 06:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode