Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#define VERSION "1.0"
new content_what[64][100]
new content_with[64][100]
public plugin_init()
{
register_plugin("Entity Replacer",VERSION,"Silencer")
}
public plugin_precache()
{
{
new path[128]
get_configsdir(path,127)
add(path,127,"/ent_replace.txt")
switch(file_exists(path))
{
case 1:
{
new howlong
new result[128]
for(new i=0;i<100;i++)
{
read_file(path,i,result,127,howlong)
parse(result,content_what[i],63,content_with[i],63)
}
register_forward(FM_Spawn,"ER_Spawn")
}
case 0:
{
set_fail_state("NO FILE")
}
}
}
}
public ER_Spawn(entid)
{
new classname[64]
pev(entid,pev_classname,classname,63)
new curpos
while(curpos<100&&!equali(content_what[curpos],classname))
{
curpos++
}
if(curpos<100)
{
engfunc(EngFunc_RemoveEntity,entid)
if(!equali(content_with[curpos],"NOTHING"))
{
new Float:origin[3]
pev(entid,pev_origin,origin)
new alt_ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,content_with[curpos]))
engfunc(EngFunc_SetOrigin,alt_ent,origin)
dllfunc(DLLFunc_Spawn,alt_ent)
return alt_ent
}
}
return PLUGIN_HANDLED
}