Code: Select all
//Simple plugin for CS1.5/1.6: Autoreload when player holding mouse1(attacking)...
//Notice: switch the following definitions(dont use both!) to specify your cs version!
//If u r using cs1.5, u cine use 2nd def(AUTORELOAD_CS15) for a better effect(1st cine still work), else(1.6) u have to
//use the 1st(AUTORELOAD_CS16)...
#define AUTORELOAD_CS16
//#define AUTORELOAD_CS15
//CVARS:
//amx_autoreload <1/0> to active/deactive this plugin
#include <amxmodx>
#include <engine>
new pactive//point to on-off
public plugin_init(){
register_plugin("Auto Reload", "1.0", "Flea")
pactive = register_cvar("amx_autoreload","1")//def: active , 0 to off
}
new reloading[33]//store whether player's reloading or not
public client_PostThink(id){
if(!get_pcvar_num(pactive) || !is_user_alive(id)) return PLUGIN_CONTINUE//plugin unabled o players dead...
if( !(get_user_button(id) & IN_ATTACK) ) return PLUGIN_CONTINUE//not attacking
new clip,ammo; get_user_weapon(id,clip,ammo)//curwp? don care currently...
if(clip || !ammo) return PLUGIN_CONTINUE//Clip positive: ammos remain.../negative(-1):holding knife o nade...
//o if no ammos in backpack...
if(reloading[id]) return PLUGIN_CONTINUE//Skip if still reloading...
#if defined AUTORELOAD_CS15
client_cmd(id,"+reload;wait;-reload")//For 1.5,Hm,seems better...
#else
client_cmd(id,"-attack")//For 1.6 just release:),by the way, +attack is a terrible cmd in my opinion :(
#endif
reloading[id] = 1
set_task(4.0,"reloaddone",id)//Assume 4s to reload,surely not a pefect way but...
return PLUGIN_CONTINUE
}
public reloaddone(id) reloading[id] = 0