#include <amxmodx>
#include <fakemeta>
#define VERSION "0.2.0"
#define PLUGIN "Adrenaline Weapons Icons"
const WEAPON_NONE = 0
//const MAX_PLAYERS = 32
// the maximum amount of ammo each weapon's clip can hold
const WEAPON_NOCLIP = -1
new const g_iMaxClip[] = {
0, // WEAPON_NONE
WEAPON_NOCLIP, // WEAPON_CROWBAR
17, // WEAPON_GLOCK
6, // WEAPON_PYTHON
50, // WEAPON_MP5
WEAPON_NOCLIP, // WEAPON_CHAINGUN
5, // WEAPON_CROSSBOW
8, // WEAPON_SHOTGUN
1, // WEAPON_RPG
WEAPON_NOCLIP, // WEAPON_GAUSS
WEAPON_NOCLIP, // WEAPON_EGON
WEAPON_NOCLIP, // WEAPON_HORNETGUN
WEAPON_NOCLIP, // WEAPON_HANDGRENADE
WEAPON_NOCLIP, // WEAPON_TRIPMINE
WEAPON_NOCLIP, // WEAPON_SATCHEL
WEAPON_NOCLIP // WEAPON_SNARK
}
new const g_szSprites[][] = {
"", // WEAPON_NONE
"d_crowbar", // WEAPON_CROWBAR
"d_9mmhandgun", // WEAPON_GLOCK
"d_357", // WEAPON_PYTHON
"d_9mmAR", // WEAPON_MP5
"d_bolt", // WEAPON_CHAINGUN
"d_crossbow", // WEAPON_CROSSBOW
"d_shotgun", // WEAPON_SHOTGUN
"d_rpg_rocket", // WEAPON_RPG
"d_gauss", // WEAPON_GAUSS
"d_egon", // WEAPON_EGON
"d_hornet", // WEAPON_HORNETGUN
"d_grenade", // WEAPON_HANDGRENADE
"d_tripmine", // WEAPON_TRIPMINE
"d_satchel", // WEAPON_SATCHEL
"d_snark" // WEAPON_SNARK
}
new g_iCurWeapon[ MAX_PLAYERS + 1 char ]
new g_bUsBot[ MAX_PLAYERS + 1 char ]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
register_event("CurWeapon", "Event_CurWeapon_OnDeath", "bd", "1=0", "2=255", "3=255")
}
public client_putinserver( id )
{
g_bUsBot{id} = is_user_bot( id )
g_iCurWeapon{id} = WEAPON_NONE
}
public Event_CurWeapon_OnDeath( id )
{
if( g_bUsBot{id} )
{
return
}
new iOldWeapon = g_iCurWeapon{id}
if( iOldWeapon )
{
g_iCurWeapon{id} = WEAPON_NONE
Util_StatusIcon(id, 0, g_szSprites[ iOldWeapon ])
}
}
public Event_CurWeapon( id )
{
if( g_bUsBot{id} )
{
return
}
new iOldWeapon = g_iCurWeapon{id}
new iCurWeapon = read_data(2) // % 0xFF
if( iOldWeapon && iOldWeapon != iCurWeapon )
{
g_iCurWeapon{id} = iCurWeapon
Util_StatusIcon(id, 0, g_szSprites[ iOldWeapon ])
}
if( iCurWeapon )
{
new maxClip = g_iMaxClip{iCurWeapon}
if( maxClip != WEAPON_NOCLIP )
{
new green = (read_data(3) * 255) / maxClip
new red = 255 - green
Util_StatusIcon(id, 1, g_szSprites[ iCurWeapon ], red, green, 20)
}
else
{
Util_StatusIcon(id, 1, g_szSprites[ iCurWeapon ], 25, 150, 25)
}
}
}
Util_StatusIcon(id, iStatus, szSprite[], r=0, g=0, b=0)
{
static msgStatusIcon = -1, msgNewStatusIcon = 0
if( msgStatusIcon == -1 )
{
new const StatusIcon[] = "StatusIcon"
if( !(msgStatusIcon = get_user_msgid(StatusIcon)) )
{
msgNewStatusIcon = engfunc(EngFunc_RegUserMsg, StatusIcon, -1)
}
}
if( msgStatusIcon )
{
message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgStatusIcon, .player=id)
}
else
{
engfunc(EngFunc_MessageBegin, id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, msgNewStatusIcon, Float:{0.0,0.0,0.0}, id)
}
write_byte(iStatus)
write_string(szSprite)
if( iStatus )
{
write_byte(r)
write_byte(g)
write_byte(b)
}
message_end()
}