I wanted the icon to disappear when i open the menu because it disrupts the menu view, and if it exited the menu it appears again
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zp50_gamemodes>
#define PLUGIN "Biohazard Icon"
#define VERSION "1.0"
#define AUTHOR "Zombie Lurker"
new iconstatus
new g_GameModeSurvivorID,
g_GameModeNemesisID,
g_GameModeMultiID,
g_GameModeSwarmID,
g_GameModePlagueID,
g_GameModeInfectionID,
g_GameModeArmageddon,
g_GameModeAvsS
new icon[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_PlayerPreThink,"fw_prethink")
iconstatus = get_user_msgid("StatusIcon")
register_clcmd("say /menu", "menu")
}
public plugin_cfg()
{
g_GameModeNemesisID = zp_gamemodes_get_id("Nemesis Mode")
g_GameModeSurvivorID = zp_gamemodes_get_id("Survivor Mode")
g_GameModeSwarmID = zp_gamemodes_get_id("Swarm Mode")
g_GameModePlagueID = zp_gamemodes_get_id("Plague Mode")
g_GameModeInfectionID = zp_gamemodes_get_id("Infection Mode")
g_GameModeMultiID = zp_gamemodes_get_id("Multiple Infection Mode")
g_GameModeArmageddon = zp_gamemodes_get_id("Armageddon Mode")
g_GameModeAvsS = zp_gamemodes_get_id("Assassin vs Snipers Mode")
}
public fw_prethink(id)
{
if (is_user_connected(id))
{
if(icon[id])
{
icon[id] = true
if (zp_gamemodes_get_current() == g_GameModeNemesisID)
{
set_user_icon(id , 1 , 255 , 0 , 0)
}
else if (zp_gamemodes_get_current() == g_GameModeSurvivorID)
{
set_user_icon(id , 1 , 0 , 0 , 255)
}
else if (zp_gamemodes_get_current() == g_GameModeSwarmID)
{
set_user_icon(id , 1 , 255 , 255 , 0)
}
else if (zp_gamemodes_get_current() == g_GameModePlagueID)
{
set_user_icon(id , 1 , 255 , 0 , 0)
}
else if (zp_gamemodes_get_current() == g_GameModeInfectionID)
{
set_user_icon(id , 1 , 0 , 255 , 0)
}
else if (zp_gamemodes_get_current() == g_GameModeMultiID)
{
set_user_icon(id , 1 , 0 , 255 , 0)
}
else if (zp_gamemodes_get_current() == g_GameModeArmageddon)
{
set_user_icon(id , 1 , 0 , 0 , 200)
}
else if (zp_gamemodes_get_current() == g_GameModeAvsS)
{
set_user_icon(id , 1 , 100 , 0 , 0)
}
}
if(!icon[id])
{
icon[id] = false
set_user_icon(id , 0 , 0 , 0 , 0)
}
}
}
stock set_user_icon(id, mode, red, green, blue)
{
message_begin(MSG_ONE, iconstatus, {0,0,0}, id)
write_byte(mode)
write_string("dmg_bio")
write_byte(red)
write_byte(green)
write_byte(blue)
message_end()
}
public menu(id)
{
icon[id] = !icon[id] ? true : false
new menu = menu_create("\rMenu:", "menu_handler")
menu_additem(menu, "\wTest", "1")
menu_additem(menu, "\wTest", "2")
menu_setprop(menu, MPROP_EXITNAME, "\wExit")
// Fix for AMXX custom menus
set_pdata_int(id, OFFSET_CSMENUCODE, 0)
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
public menu_handler(id, menu, item)
{
if(item == MENU_EXIT)
{
return PLUGIN_HANDLED
}
new data[6], iName[64], access, callback
menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)
switch (str_to_num(data))
{
case 1:
{
menu(id)
}
case 2:
{
menu(id)
}
}
return PLUGIN_HANDLED
}