I'm trying load my ent as well as remove it on a new round.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
new menu[512]
new Keysmenu_1 = MENU_KEY_1|MENU_KEY_2|MENU_KEY_5|MENU_KEY_0
public plugin_init() {
register_plugin("Sabotage","1.0","Mazza")
register_logevent("logevent_round_end", 2, "1=Round_End")
register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
register_clcmd("say /menu","Showmenu_1")
register_menucmd(register_menuid("menu_press"), Keysmenu_1, "Pressedmenu_1")
}
public plugin_precache()
{
precache_model("models/w_isotopebox.mdl");
}
public plugin_cfg()
{
load_objective()
}
public logevent_round_end()
{
new iEnt = -1
while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "sabotage_t")))
{
engfunc(EngFunc_RemoveEntity, iEnt)
}
while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "sabotage_ct")))
{
engfunc(EngFunc_RemoveEntity, iEnt)
}
client_print(0, print_chat, "OMGLOLOLOLOLOL")
}
public event_new_round()
{
client_print(0, print_chat, "OMGWTFBBQ")
load_objective()
}
public Showmenu_1(id)
{
new len = formatex(menu, 511, "\rSabotage Menu^n^n")
len += formatex(menu[len], 511-len, "\y1. \wCreate T bombsite ^n")
len += formatex(menu[len], 511-len, "\y2. \wCreate CT bombsite ^n^n")
len += formatex(menu[len], 511-len, "\y5. \wSave bombsites ^n^n")
len += formatex(menu[len], 511-len, "\y0. \wExit")
show_menu(id, Keysmenu_1, menu, -1, "menu_press")
}
public Pressedmenu_1(id, key) {
/*
* Sabotage Menu
* 1: Create T bombsite
* 2: Create CT bombsite
* 4: SomeThing
* 6: SomeThing
* 0: Exit
*/
new iEnt = -1
switch (key)
{
case 0:
{
while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "sabotage_t")))
{
engfunc(EngFunc_RemoveEntity, iEnt)
}
//client_print(id, print_chat, "First selection")
create_objective(1, id)
}
case 1:
{
while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "sabotage_ct")))
{
engfunc(EngFunc_RemoveEntity, iEnt)
}
//client_print(id, print_chat, "Second selection")
create_objective(2, id)
}
case 4:
{ // 5
client_print(id, print_chat, "[AMXX] Saved objective(s)")
save_objective()
return PLUGIN_HANDLED
}
case 9:
{
//client_print(id, print_chat, "Last selection")
return PLUGIN_HANDLED
}
}
Showmenu_1(id)
return PLUGIN_HANDLED
}
create_objective(team, id, Float:origin[3]= { 0.0, 0.0, 0.0 }, Float:angle[3]= { 0.0, 0.0, 0.0 })
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
if( id ){
pev(id, pev_origin, origin);
engfunc(EngFunc_SetOrigin, ent, origin );
origin[2] += 80.0;
engfunc(EngFunc_SetOrigin, id, origin);
pev(id,pev_v_angle,angle);
angle[0] = 0.0;
set_pev(ent,pev_angles,angle);
}
else {
engfunc(EngFunc_SetOrigin, ent, origin );
set_pev(ent, pev_angles, angle);
}
set_pev(ent, pev_takedamage, 1.0);
set_pev(ent, pev_health, 100.0);
switch( team )
{
case 1: set_pev(ent, pev_classname, "sabotage_t");
case 2: set_pev(ent, pev_classname, "sabotage_ct");
default: set_pev(ent, pev_classname, "sabotage_box");
}
set_pev(ent, pev_team, team);
engfunc(EngFunc_SetModel, ent, "models/w_isotopebox.mdl");
set_pev(ent, pev_movetype, MOVETYPE_PUSHSTEP);
set_pev(ent, pev_solid, SOLID_BBOX);
new Float:mins[3] = { -19.340000, -16.549999, 0.000000 };
new Float:maxs[3] = { 19.340000, 15.280000, 26.180000 };
engfunc(EngFunc_SetSize, ent, mins, maxs);
engfunc(EngFunc_DropToFloor, ent);
}
load_objective()
{
static sConfigsDir[256], sFile[256], SabDir[256];
get_configsdir(sConfigsDir, sizeof sConfigsDir - 1);
static sMapName[32];
get_mapname(sMapName, sizeof sMapName - 1);
formatex(SabDir, sizeof SabDir - 1,"%s/Sabotage",sConfigsDir);
formatex(sFile, sizeof sFile - 1, "%s/%s.cfg",SabDir,sMapName);
if(!dir_exists(SabDir))
{
mkdir(SabDir);
}
if(!file_exists(sFile))
{
write_file(sFile,"");
}
static sFileOrigin[3][32]
static sTeam[128], sOrigin[128], sAngle[128];
static fTeam, Float:fOrigin[3], Float:fAngles[3];
static iLine, iLength, sBuffer[256];
while(read_file(sFile, iLine++, sBuffer, sizeof sBuffer - 1, iLength))
{
if((sBuffer[0]== ';') || !iLength)
continue;
strtok(sBuffer, sOrigin, sizeof sOrigin - 1, sAngle, sizeof sAngle - 1, '|', 0);
strtok(sOrigin, sTeam, sizeof sTeam - 1, sOrigin, sizeof sOrigin -1, '~', 0);
parse(sOrigin, sFileOrigin[0], sizeof sFileOrigin[] - 1, sFileOrigin[1], sizeof sFileOrigin[] - 1, sFileOrigin[2], sizeof sFileOrigin[] - 1);
fOrigin[0] = str_to_float(sFileOrigin[0]);
fOrigin[1] = str_to_float(sFileOrigin[1]);
fOrigin[2] = str_to_float(sFileOrigin[2]);
fTeam = str_to_num(sTeam[0])
fAngles[1] = str_to_float(sAngle[1]);
create_objective(fTeam, 0, fOrigin, fAngles)
}
}
save_objective()
{
static sConfigsDir[256], sFile[256], SabDir[256];
get_configsdir(sConfigsDir, sizeof sConfigsDir - 1);
static sMapName[32];
get_mapname(sMapName, sizeof sMapName - 1);
formatex(SabDir, sizeof SabDir - 1,"%s/Sabotage",sConfigsDir);
formatex(sFile, sizeof sFile - 1, "%s/%s.cfg",SabDir,sMapName);
if(file_exists(sFile))
delete_file(sFile);
new iEnt = -1, Float:fEntTeam, Float:fEntOrigin[3], Float:fEntAngles[3];
static sBuffer[256];
while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "sabotage_t")))
{
pev(iEnt, pev_team, fEntTeam);
pev(iEnt, pev_origin, fEntOrigin);
pev(iEnt, pev_angles, fEntAngles);
formatex(sBuffer, sizeof sBuffer - 1, "%d ~ %d %d %d | %d", floatround(fEntTeam), floatround(fEntOrigin[0]), floatround(fEntOrigin[1]), floatround(fEntOrigin[2]), floatround(fEntAngles[1]));
write_file(sFile, sBuffer, -1);
}
while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "sabotage_ct")))
{
pev(iEnt, pev_team, fEntTeam);
pev(iEnt, pev_origin, fEntOrigin);
pev(iEnt, pev_angles, fEntAngles);
formatex(sBuffer, sizeof sBuffer - 1, "%d ~ %d %d %d | %d", floatround(fEntTeam), floatround(fEntOrigin[0]), floatround(fEntOrigin[1]), floatround(fEntOrigin[2]), floatround(fEntAngles[1]));
write_file(sFile, sBuffer, -1);
}
}