Hello, can someone help me add custom icons for custom weapons ?
I try the revolver first...
I started something here :
Code:
#include <amxmodx>
#define PLUGIN "Weapon Icon"
#define VERSION "1.2"
#define AUTHOR "hoboman313/Zenix"
#define MAX_PLAYERS 32
new iconstatus, pcv_iloc
new user_icons[MAX_PLAYERS + 1][16]
public IsUserHasRevolver(id)
{
return true;
}
public IsUserHasMolotov(id)
{
return true;
}
public plugin_natives()
{
register_native("IsUserHasRevolver", "NativeIsUserHasRevolver", 1);
register_native("IsUserHasMolotov", "NativeIsUserHasMolotov", 1);
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_event("CurWeapon", "update_icon", "be", "1=1");
register_event("AmmoX", "draw_icon", "be");
register_event("DeathMsg", "event_death", "a");
pcv_iloc = register_cvar("amx_weapon_location", "1");
check_icon_loc();
}
public plugin_precache()
{
precache_model("sprites/revolver.spr");
precache_model("sprites/molotov.spr");
}
public update_icon(id)
{
remove_weapon_icon(id);
check_icon_loc();
if (get_pcvar_num(pcv_iloc) == 0 || is_user_bot(id))
return;
new sprite[16], iwpn, clip, ammo;
iwpn = get_user_weapon(id, clip, ammo);
if (IsUserHasRevolver(id))
{
sprite = "revolver.spr";
}
else if (IsUserHasMolotov(id))
{
sprite = "molotov.spr";
}
else
{
switch (iwpn)
{
case CSW_P228:
case CSW_SCOUT:
case CSW_HEGRENADE:
case CSW_XM1014:
case CSW_MAC10:
case CSW_AUG:
case CSW_SMOKEGRENADE:
case CSW_ELITE:
case CSW_FIVESEVEN:
case CSW_UMP45:
case CSW_SG550:
case CSW_GALIL:
case CSW_FAMAS:
case CSW_USP:
case CSW_MP5NAVY:
case CSW_M249:
case CSW_M3:
case CSW_M4A1:
case CSW_TMP:
case CSW_G3SG1:
case CSW_FLASHBANG:
case CSW_DEAGLE:
case CSW_SG552:
case CSW_AK47:
case CSW_KNIFE:
case CSW_P90:
case CSW_GLOCK18:
case CSW_AWP:
sprite = "d_" + iwpn;
break;
}
}
user_icons[id] = sprite;
draw_icon(id);
}
public draw_icon(id)
{
new iwpn, clip, ammo, icon_color[3];
iwpn = get_user_weapon(id, clip, ammo);
icon_color[0] = 255;
icon_color[1] = 0;
icon_color[2] = 0;
message_begin(MSG_ONE, iconstatus, {0, 0, 0}, id);
write_byte(1);
write_string(user_icons[id]);
write_byte(icon_color[0]);
write_byte(icon_color[1]);
write_byte(icon_color[2]);
message_end();
}
public remove_weapon_icon(id)
{
message_begin(MSG_ONE, iconstatus, {0, 0, 0}, id);
write_byte(0);
write_string(user_icons[id]);
message_end();
}
public event_death()
{
new id = read_data(2);
if (!is_user_bot(id))
remove_weapon_icon(id);
}
public check_icon_loc()
{
new value = get_pcvar_num(pcv_iloc);
if (value == 1)
iconstatus = get_user_msgid("StatusIcon");
else if (value == 2)
iconstatus = get_user_msgid("Scenario");
else
iconstatus = 0;
return PLUGIN_CONTINUE;
}
__________________