Raised This Month: $ Target: $400
 0% 

Make/remove end every round.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-12-2009 , 02:01   Make/remove end every round.
Reply With Quote #1

I'm trying load my ent as well as remove it on a new round.
It removes the ents but doesn't load them but it prints both messages.

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_FindEntityByStringiEnt"classname""sabotage_t")))
    {
        
engfunc(EngFunc_RemoveEntityiEnt)
    }
    while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname""sabotage_ct")))
    {
        
engfunc(EngFunc_RemoveEntityiEnt)
    }        
    
client_print(0print_chat"OMGLOLOLOLOLOL")

}

public 
event_new_round()
{
    
client_print(0print_chat"OMGWTFBBQ")
    
load_objective()
}

public 
Showmenu_1(id
{
    new 
len formatex(menu511"\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(idKeysmenu_1menu, -1"menu_press")
}

public 
Pressedmenu_1(idkey) {
    
/* 
    *     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_FindEntityByStringiEnt"classname""sabotage_t")))
            {
                
engfunc(EngFunc_RemoveEntityiEnt)
            }
            
//client_print(id, print_chat, "First selection")
            
create_objective(1id)
        }
        case 
1
        {
            while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname""sabotage_ct")))
            {
                
engfunc(EngFunc_RemoveEntityiEnt)
            }
            
//client_print(id, print_chat, "Second selection")
            
create_objective(2id)
        } 
        case 
4
        { 
// 5
            
client_print(idprint_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(teamidFloat:origin[3]= { 0.00.00.0 }, Float:angle[3]= { 0.00.00.0 })
{
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));

    if( 
id ){
        
pev(idpev_originorigin);
        
engfunc(EngFunc_SetOriginentorigin );
        
origin[2] += 80.0;
        
engfunc(EngFunc_SetOriginidorigin);

        
pev(id,pev_v_angle,angle);
        
angle[0] = 0.0;
        
set_pev(ent,pev_angles,angle);
    }
    else {
        
engfunc(EngFunc_SetOriginentorigin );
        
set_pev(entpev_anglesangle);
    }

    
set_pev(entpev_takedamage1.0);
    
set_pev(entpev_health100.0);

    switch( 
team )
    {
        case 
1set_pev(entpev_classname"sabotage_t");
        case 
2set_pev(entpev_classname"sabotage_ct");
        default: 
set_pev(entpev_classname"sabotage_box");
    }
    
set_pev(entpev_teamteam);

    
engfunc(EngFunc_SetModelent"models/w_isotopebox.mdl");
    
set_pev(entpev_movetypeMOVETYPE_PUSHSTEP);
    
set_pev(entpev_solidSOLID_BBOX);
    
    new 
Float:mins[3] = { -19.340000, -16.5499990.000000 };
    new 
Float:maxs[3] = { 19.34000015.28000026.180000 };
    
engfunc(EngFunc_SetSizeentminsmaxs);
    
    
engfunc(EngFunc_DropToFloorent);
}

load_objective()
{
    static 
sConfigsDir[256], sFile[256], SabDir[256];
    
    
get_configsdir(sConfigsDirsizeof sConfigsDir 1);
    
    static 
sMapName[32];
    
get_mapname(sMapNamesizeof sMapName 1);
    
    
formatex(SabDirsizeof SabDir 1,"%s/Sabotage",sConfigsDir);
    
formatex(sFilesizeof 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 
fTeamFloat:fOrigin[3], Float:fAngles[3];
    static 
iLineiLengthsBuffer[256];
    
    while(
read_file(sFileiLine++, sBuffersizeof sBuffer 1iLength))
    {
        if((
sBuffer[0]== ';') || !iLength)
            continue;
        
        
strtok(sBuffersOriginsizeof sOrigin 1sAnglesizeof sAngle 1'|'0);
        
        
strtok(sOriginsTeamsizeof sTeam 1sOriginsizeof sOrigin -1'~'0);
        
        
parse(sOriginsFileOrigin[0], sizeof sFileOrigin[] - 1sFileOrigin[1], sizeof sFileOrigin[] - 1sFileOrigin[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(fTeam0fOriginfAngles)
    }
}

save_objective()
{
    static 
sConfigsDir[256], sFile[256], SabDir[256];
    
    
get_configsdir(sConfigsDirsizeof sConfigsDir 1);
    
    static 
sMapName[32];
    
get_mapname(sMapNamesizeof sMapName 1);
    
    
formatex(SabDirsizeof SabDir 1,"%s/Sabotage",sConfigsDir);
    
formatex(sFilesizeof sFile 1"%s/%s.cfg",SabDir,sMapName);
        
    if(
file_exists(sFile))
        
delete_file(sFile);
    
    new 
iEnt = -1Float:fEntTeamFloat:fEntOrigin[3], Float:fEntAngles[3];
    static 
sBuffer[256];
    
    while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname""sabotage_t")))
    {
        
pev(iEntpev_teamfEntTeam);
        
pev(iEntpev_originfEntOrigin);
        
pev(iEntpev_anglesfEntAngles);
        
        
formatex(sBuffersizeof sBuffer 1"%d ~ %d %d %d | %d"floatround(fEntTeam), floatround(fEntOrigin[0]), floatround(fEntOrigin[1]), floatround(fEntOrigin[2]), floatround(fEntAngles[1]));
        
        
write_file(sFilesBuffer, -1);
    }
    
    while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname""sabotage_ct")))
    {
        
pev(iEntpev_teamfEntTeam);
        
pev(iEntpev_originfEntOrigin);
        
pev(iEntpev_anglesfEntAngles);
        
        
formatex(sBuffersizeof sBuffer 1"%d ~ %d %d %d | %d"floatround(fEntTeam), floatround(fEntOrigin[0]), floatround(fEntOrigin[1]), floatround(fEntOrigin[2]), floatround(fEntAngles[1]));
        
        
write_file(sFilesBuffer, -1);
    } 

__________________
It's a mystery.
Mini_Midget is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 01-12-2009 , 05:49   Re: Make/remove end every round.
Reply With Quote #2

Well i only looked on this 2 sec and i dont know anything about cs, but try

PHP Code:
set_pev(entpev_solidSOLID_TRIGGER); 
insted of

PHP Code:
set_pev(entpev_solidSOLID_BBOX); 
I assume its some kinda "zone" u wanna create....
__________________
Dr.G is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-12-2009 , 18:51   Re: Make/remove end every round.
Reply With Quote #3

No...

I'm trying to make my ent(s) be removed at the end of the round then made again on the start of the next round. But for some reason. I can't get it made again.
__________________
It's a mystery.
Mini_Midget is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 01-12-2009 , 19:23   Re: Make/remove end every round.
Reply With Quote #4

Oh so its the "create_objective" part?.. if i read it right u need targetname and the DLLFunc..

PHP Code:
set_pev(iEntpev_targetnameszTargetName);
 
 
dllfunc(DLLFunc_SpawniEnt); 
__________________
Dr.G is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-13-2009 , 01:05   Re: Make/remove end every round.
Reply With Quote #5

No no....

The ents spawn fine on map load (first time) and spawn fine when I made them with the menu. I'm just having trouble making them on a new round.
__________________
It's a mystery.
Mini_Midget is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-13-2009 , 01:18   Re: Make/remove end every round.
Reply With Quote #6

If they spawn fine at mapload, then i have no idea was thinking there was somewhere an error in load_objective function.

What i saw :

in round end function, you must reset ent to -1 before the second loop (may be not needed as 1rst loop should reset ent to 0)
in load_objective : use "new" file system that is faster, especiallly if you read it each new round, also, if you don't plain to add more than 2 objecives, just save them into global vars so you don't have to read the file each new round.

For your problem, put debugs in other places, event new round will obviously be called so a debug there is useless.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 01-14-2009 , 21:48   Re: Make/remove end every round.
Reply With Quote #7

Hmm... Weird...
I just changed all the "static" in load_objective to "new" and it works.
Reseting ent to -1 before the 2nd loop in logevent_round_ent doesn't make a difference (as expected).

Could you go in detail on what variables I should put as global variables for my load_objective function?
__________________
It's a mystery.
Mini_Midget is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-15-2009 , 00:23   Re: Make/remove end every round.
Reply With Quote #8

Something like :

#define OBJ_NUMS 2

enum Obj {
objTeam,
Float: objOrigin[3],
Float: objAngle[3]
}

new g_iObjectives[Obj][OBJ_NUMS]



Even better, don't remove objectives, just set them EF_NODRAW + SOLID_NOT.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode