Hey everyone, I have a plugin that is supposed to create an entity "info_tfdetect". This entity controls settings for the maps in the game Team Fortress Classic. With this plugin I am trying to remove a current "info_tfdetect" if there is one, then make a new one. After it is created it should set the values to it.
All the plugin seems to do at the moment is spawn every entity in the map at 0,0,0 origin.
Code:
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
new ent = find_ent_by_class(-1, "info_tfdetect");
if(ent)
{
remove_entity_name("info_tfdetect");
}
create_entity("info_tfdetect");
entity_set_string(ent, EV_SZ_classname, "info_tfdetect");
DispatchKeyValue(ent, "origin", "0 0 0");
DispatchKeyValue(ent, "maxammo_shells", "1006");
DispatchKeyValue(ent, "team1_name", "SuRf3rs!");
DispatchKeyValue(ent, "hook_out", "0");
DispatchKeyValue(ent, "ex_skill_max", "3");
DispatchKeyValue(ent, "ex_skill_min", "1");
}
public plugin_precache()
{
register_forward(FM_KeyValue, "forward_keyvalue")
}
public forward_keyvalue(ent, kvdid) {
if(ent)
{
new keyname[128];
get_kvd(kvdid, KV_KeyName, keyname, 127);
if(equal(keyname, "origin"))
{
set_kvd(kvdid, KV_Value, "0 0 0");
}
else if(equal(keyname, "maxammo_shells"))
{
set_kvd(kvdid, KV_Value, "1006");
}
else if(equal(keyname, "team1_name"))
{
set_kvd(kvdid, KV_Value, "SuRf3rs!");
}
else if(equal(keyname, "hook_out"))
{
set_kvd(kvdid, KV_Value, "0");
}
else if(equal(keyname, "ex_skill_max"))
{
set_kvd(kvdid, KV_Value, "3");
}
else if(equal(keyname, "ex_skill_min"))
{
set_kvd(kvdid, KV_Value, "1");
}
}
return FMRES_IGNORED
}