I need an easy way to 1) get the 'origin', 'team_no' and 'angles' keys from an entity, save them temporarily, delete the entity, then rebuild it with specific keys?
I have made an attempt of just editing the entity as-is but all of the keys are not applied, so it wont always work as intended
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_OVERRIDE;
}
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);
}
this is the code it used, some maps all the keys are set, other times, only the top X are set, can someone tell me how id store those keys and "recreate" the entity?
heres an example of one of the entities im working with:
Code:
{
"origin" "-1960 -2864 72"
"armorvalue" "300"
"health" "100"
"message" "Restocking Explosives."
"no_grenades_2" "4"
"ammo_medikit" "20"
"noise" "items/r_item1.wav"
"team_no" "2"
"no_grenades_1" "4"
"ammo_nails" "200"
"ammo_rockets" "100"
"ammo_cells" "200"
"ammo_shells" "200"
"wait" "1"
"mdl" "models/en/grenpack.mdl"
"g_e" "1"
"g_a" "1"
"classname" "info_tfgoal"
}
__________________