Quote:
Originally Posted by devicenull
What we are looking for in plugins:- Make sure it's code is clean, concise, and readable.
|
Quote:
Originally Posted by Johnny got his gun
Badly coded plugins that do stuff in a silly way that there obviously are better and more sleek ways of doing will be trashed.
|
Instead of trashing, I will show you how you could make it better:
Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta_util>
public plugin_init()
{
register_plugin("Auto Reload", "0.1", "Exolent");
register_event("CurWeapon", "EventCurWeapon", "be", "1=1");
}
public EventCurWeapon(client)
{
new clip, ammo;
new weapon = get_user_weapon(client, clip, ammo);
if( !clip && ammo ) // empty clip, but has backpack ammo
{
new classname[32];
get_weaponname(weapon, classname, sizeof(classname) - 1);
new ent = fm_find_ent_by_owner(-1, classname, client);
if( pev_valid(ent) )
{
if( pev(client, pev_button) & IN_ATTACK )
{
client_cmd(client, "-attack");
}
ExecuteHamB(Ham_Weapon_Reload, ent);
}
}
}
__________________