Raised This Month: $ Target: $400
 0% 

Improve anti fast fire method and optimize ?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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