Hey,
This should have been an easy plugin to make but incoporating a file to retrieve data from has been the hardest thing I've come across yet.
What its suppose to do is:
get mapname,
open mapfile associated with mapname,
read all the lines in the mapfile,
remove all the entities listed in the mapfile
What it does:
Compiles fine :p
Crashes on server start
Im guessing the crash is caused by the malformed find_ent_by_model/remove ent because fgets is not supplying the right data I wanted.
I have yet to find a
decent tutorial on file reading, so if you could provide while helping me fix my code.
Code:
#include <amxmodx>
#include <engine>
#define PLUGIN "WepEntityRemover"
#define AUTHOR "Marky_UK"
#define VERSION "1.00"
#define FILEPATH "addons/amxmodx/configs/WepEntityRemover"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
new mapfile[256]
new mapname[256]
get_mapname(mapname, 255)
format(mapfile,255,"%s/%s.txt", FILEPATH, mapname)
new filepointer = fopen(mapfile,"r")
if(filepointer == 0)
{
return PLUGIN_HANDLED;
}
new mapfiledata[681],weapon[19]
while(fgets(filepointer,mapfiledata,680))
{
parse(mapfiledata,weapon,18)
new WeaponEnt[65]
format(WeaponEnt,64,"find_ent_by_model(-1,'armoury_entity','models/%s')", weapon)
while((WeaponEnt[0]) != 0)
{
remove_entity(WeaponEnt[0])
}
}
return PLUGIN_HANDLED;
}
Thanks, +karma