adding keys to an entity if a key is found, overwriting keys if they exist.
I have an entity, several entities actually.. all named "info_tfgoal" and certain entities have keynames "no_grenades_1" and "no_grenades_2" these keys tell how many of each type of grenade that entity will give a player, what I want to do is make a plugin that will find one of these entities and modify it by adding and updating several keys to it, so it will completely replenish health and armor and it will have a more unique sound..
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx> #include <amxmisc> #include <engine> #include <fakemeta>
#define PLUGIN "Spam Packs" #define VERSION "1.0" #define AUTHOR "Master"
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) // Add your code here... }
public plugin_precache() { register_forward(FM_KeyValue, "hook_KeyValue", 1) }
public hook_KeyValue(entId, kvdid) { if(!pev_valid(entId)) return FMRES_HANDLED; new classname[64]; get_kvd(kvdid, KV_ClassName, classname, 63) if(equali(classname, "info_tfgoal")) { new keyname[128] new keydata[128] get_kvd(kvdid, KV_KeyName, keyname, 127) get_kvd(kvdid, KV_Value, keydata, 127) if(containi(keyname, "no_grenades") != -1) { set_keyvalue(entId, "no_grenades_1", "4") set_keyvalue(entId, "no_grenades_2", "4") set_keyvalue(entId, "health", "100") set_keyvalue(entId, "armorvalue", "300") set_keyvalue(entId, "message", "Restocking Explosives.") set_keyvalue(entId, "noise", "items/r_item1.wav") set_keyvalue(entId, "ammo_nails", "200") set_keyvalue(entId, "ammo_rockets", "100") set_keyvalue(entId, "ammo_cells", "200") set_keyvalue(entId, "ammo_shells", "200") set_keyvalue(entId, "wait", "1") set_keyvalue(entId, "g_e", "1") set_keyvalue(entId, "g_a", "1") } } return FMRES_SUPERCEDE; }
stock set_keyvalue(ent, key[], value[]) { new classname[32]; pev(ent, pev_classname, classname, 31); set_kvd(0, KV_ClassName, classname); set_kvd(0, KV_KeyName, key); set_kvd(0, KV_Value, value); set_kvd(0, KV_fHandled, 0); dllfunc(DLLFunc_KeyValue, ent, 0); }
okay, my code works pretty well, it can find the packs, and it can update SOME of the keys, but not all of them, some all of them were missing the wait time, some were missing the noise..
edit: if its possible, id be okay with re-creating the entity, but I need to get the origin and angles of the entity before removing it
|