#include <amxmodx>
#include <engine>
new bool:gotShield[33]
public pfn_touch(ptr, ptd) {
new entId = ptr
new id = ptd
if ( id < 0 || id > 32 || !is_user_alive(id) || gotShield[id] )
return PLUGIN_CONTINUE
new modelName[32]
entity_get_string(entId, EV_SZ_model, modelName, 31)
if ( containi(modelName,"w_shield.mdl") != -1 ) {
new parm[1]
parm[0] = id
remove_task(2200 + id,0)
set_task(0.1,"check_shield",2200 + id,parm,1)
}
return PLUGIN_CONTINUE
}
public check_shield(parm[1]) {
new id = parm[0]
new modelName[32]
entity_get_string(id, EV_SZ_viewmodel, modelName, 31)
if ( containi(modelName,"v_shield_") != -1 ) {
// Do some stuff in here. It's found!
}
return PLUGIN_HANDLED
}
The problem is finding an efficient way of getting the shield (ie- a forward).. having to listen to too many events for different parts makes for big and sloppy code to find out one simple thing! and setting a milisecond timer (task) is a no no.
the only ways to detect shield are...
client command: shield (whatever buys it right out)
menu command: equipment menu, key 8
touch event when walking over it to pick it up
hideweapon event -OR- curweapon event... just in case any of the above were missed.
however, many plugins give players shields via the give_item function, which does not trigger any of the above events.
it's too bad valve (ming) didnt make this easier for scripters to detect.