PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
// CS Offsets
#if cellbits == 32
const OFFSET_CLIPAMMO = 51
#else
const OFFSET_CLIPAMMO = 65
#endif
const OFFSET_LINUX_WEAPONS = 4
// Max Clip for weapons
new const MAXCLIP[] = { -1, 13, -1, 10, 1, 7, -1, 30, 30, 1, 30, 20, 25, 30, 35, 25, 12, 20,
10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, -1, 50 }
new g_szUnClipMenu[33]
new g_szNoClipMenu[33]
public plugin_init()
{
register_plugin("aDmin Menu", "1.0", "DeXTeR")
register_concmd("adminmenu", "Show_aDmin_Menu", ADMIN_BAN)
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
}
public Show_aDmin_Menu(id,level,cid)
{
if(!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED;
if(!is_user_alive(id))
return PLUGIN_HANDLED
new szInfo[256], szUnClipMenu[256], szNoClipMenu[256];
formatex(szInfo, charsmax(szInfo), "AdmiN Menu");
new menu = menu_create(szInfo , "aDmin_Menu");
if(g_szUnClipMenu[id]) { formatex(szUnClipMenu, charsmax(szUnClipMenu), "Unlimited Clip \r[\yON\r]"); }
else { formatex(szUnClipMenu, charsmax(szUnClipMenu), "Unlimited Clip \r[\dOFF\r]"); }
if(g_szNoClipMenu[id]) { formatex(szNoClipMenu, charsmax(szNoClipMenu), "Noclip Clip \r[\yON\r]"); }
else { formatex(szNoClipMenu, charsmax(szNoClipMenu), "Noclip Clip \r[\dOFF\r]"); }
new szExit[15];
formatex(szExit, charsmax(szExit), "Close");
menu_setprop(menu, MPROP_EXITNAME, szExit);
menu_display(id , menu , 0);
}
public aDmin_Menu(id , menu , item)
{
if (!is_user_alive(id))
return PLUGIN_HANDLED;
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new item_id = str_to_num(data);
switch (item_id)
{
case 0:
{
if(!g_szUnClipMenu[id])
{
g_szUnClipMenu[id] = 1;
Show_aDmin_Menu(id);
}
else
{
g_szUnClipMenu[id] = 0;
Show_aDmin_Menu(id);
}
}
case 1:
{
if(!g_szNoClipMenu[id])
{
g_szNoClipMenu[id] = 1;
set_user_noclip(id, 1)
Show_aDmin_Menu(id);
}
else
{
g_szNoClipMenu[id] = 0;
set_user_noclip(id, 0)
Show_aDmin_Menu(id);
}
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public client_putinserver(id)
{
g_szUnClipMenu[id] = 0;
g_szNoClipMenu[id] = 0;
}
public client_disconnected(id)
{
g_szUnClipMenu[id] = 0;
g_szNoClipMenu[id] = 0;
}
// Unlimited clip code
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
// Player doesn't have the unlimited clip upgrade
if (!g_szUnClipMenu[msg_entity])
return;
// Player not alive or not an active weapon
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
return;
static weapon, clip
weapon = get_msg_arg_int(2) // get weapon ID
clip = get_msg_arg_int(3) // get weapon clip
// Unlimited Clip Ammo
if (MAXCLIP[weapon] > 2) // skip grenades
{
set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time
if (clip < 2) // refill when clip is nearly empty
{
// Get the weapon entity
static wname[32], weapon_ent
get_weaponname(weapon, wname, sizeof wname - 1)
weapon_ent = fm_find_ent_by_owner(-1, wname, msg_entity)
// Set max clip on weapon
fm_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
}
}
}
// Find entity by its owner (from fakemeta_util)
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {}
return entity;
}
// Set Weapon Clip Ammo
stock fm_set_weapon_ammo(entity, amount)
{
set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
}