Quote:
#include <amxmodx>
#include <fakemeta>
new bool:g_bHidden[33];
public plugin_init() {
register_plugin("Hide Weapons", "1.0", "Author");
register_clcmd("say /hide", "cmd_hide");
register_clcmd("say /unhide", "cmd_unhide");
register_forward(FM_SetModel, "fw_setmodel");
}
public cmd_hide(id) {
g_bHidden[id] = true;
client_print(id, print_chat, "Your weapons are now hidden.");
}
public cmd_unhide(id) {
g_bHidden[id] = false;
client_print(id, print_chat, "Your weapons are now visible.");
}
public fw_setmodel(ent, model[]) {
if(pev(ent, pev_owner) && g_bHidden[pev(ent, pev_owner)]) {
set_pev(ent, pev_model, "");
set_pev(ent, pev_rendermode, kRenderTransAlpha);
set_pev(ent, pev_renderamt, 0);
set_pev(ent, pev_renderfx, kRenderFxNone);
}
return FMRES_IGNORED;
}
|
This plugin uses the register_clcmd() function to register the chat commands "/hide" and "/unhide", which call the "cmd_hide" and "cmd_unhide" functions respectively. These functions set a global variable, g_bHidden, to true or false depending on whether the player wants to hide or unhide their weapons.
The plugin also uses the register_forward() function to register a forward for the FM_SetModel event. This forward is called every time a weapon model is set, and it checks if the player has hidden their weapons. If the player has hidden their weapons, the forward sets the weapon's model to an empty string, and sets the weapon's rendermode, renderamt, and renderfx to values that make the weapon invisible.
Please note that this is an example and you may need to modify the code to suit your needs, also, this plugin will hide the weapons and the player can still use them.
Also, please note that this plugin is not tested and it may not work as expected, you may need to test it and make any necessary adjustments.