AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get a forward that give me "ent" (like FM_spawn) every round (https://forums.alliedmods.net/showthread.php?t=88732)

ScHrAnZ DiNgEnS 03-28-2009 15:00

get a forward that give me "ent" (like FM_spawn) every round
 
I am a beginner on coding plugins, so i hope someone can help me.

I make a little plugin that destroy some "func_breakable" ents on FM_spawn.
Here is the code that destroy the ents on FM_spawn:

PHP Code:

register_forward(FM_Spawn"fwd_Spawn")

public 
fwd_Spawn(ent) {
    
    
///if(enable == false)
    //    return FMRES_IGNORED
    
    
if(!pev_valid(ent))
        return 
FMRES_IGNORED
    
    
static ClassName[32], isize
    pev
(entpev_classnameClassName31)
    
size sizeof(g_RemovedEntities)
    for(
i=0sizei++)
    {
        if(
equali(ClassNameg_RemovedEntities[i]))
        {
            
//check for bomb explosion entity like boxes and dont remove them
            
if(pev(entpev_spawnflags) != 1)
            {
                
entity_set_float(entEV_FL_takedamage0.0)
                
//engfunc(EngFunc_RemoveEntity, ent);
                
return FMRES_SUPERCEDE
            
}
        }
    }
    return 
FMRES_IGNORED


The code works for me, but how can i get working it on roundstart? roundstart never give me an "ent" like FM_spawn. Can someone help me pls to make it possible?

I know that i can remove the ents on FM_spawn and there will never come back, but thats not that what i want. I need to remove ents only for some rounds.

Greetz,
ScHrAnZ DiNgEnS

PS: Sorry for my bad english, i hope you can understand me =)

Dores 03-28-2009 15:15

Re: get a forward that give me "ent" (like FM_spawn) every round
 
Not tested, but should work. Modify it to make it work on specific rounds' start.

PHP Code:

#include <amxmodx>
#include <fakemeta>

new const g_RemovedEntities[][] =
{
    
"entity1.classname",
    
"entity2.classname",
    
"entity3.classname"
};

public 
plugin_init()
{
    
register_plugin("Remove Wanted Entites on Round Start""1.0""Dores");
    
    
register_logevent("logev_RoundStart"2"1=Round_Start");
}

public 
logev_RoundStart()
{
    
// A delay is needed.
    
set_task(0.1"Task_RoundStartDelay");
}

public 
Task_RoundStartDelay()
{
    static 
iiEnt;
    for(
sizeof(g_RemovedEntities) ; i++)
    {
        
iEnt = -1;
        while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"g_RemovedEntities[i])))
        {
            
engfunc(EngFunc_RemoveEntityiEnt);
        }
    }



ConnorMcLeod 03-28-2009 15:51

Re: get a forward that give me "ent" (like FM_spawn) every round
 
SOLID_NOT and EF_NODRAW should be enough.

PHP Code:

#include <amxmodx>
#include <fakemeta>

#define PLUGIN "func_breakable"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"

#define SF_BREAK_TRIGGER_ONLY           1           // May only be broken by trigger
//#define    SF_BREAK_TOUCH                  2           // Can be 'crashed through' by running player (plate glass)
//#define SF_BREAK_PRESSURE               4           // Can be broken by a player standing on it
//#define SF_BREAK_CROWBAR                256         // Instant break if hit with crowbar

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_logevent("LogEvent_Round_Start"2"1=Round_Start")
}

public 
LogEvent_Round_Start()
{
    new 
iEnt FM_NULLENT
    
while( (iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname""func_breakable")) > )
    {
        if( 
pev(iEntpev_spawnflags) != SF_BREAK_TRIGGER_ONLY )
        {
            
set_pev(iEntpev_ltime0.1)
            
set_pev(iEntpev_solidSOLID_NOT)
            
set_pev(iEntpev_effectsEF_NODRAW)
            
set_pev(iEntpev_health, -10.0)
            
set_pev(iEntpev_takedamageDAMAGE_NO)
            
set_pev(iEntpev_deadflagDEAD_DEAD)
        }
    }



ScHrAnZ DiNgEnS 03-28-2009 17:03

Re: get a forward that give me "ent" (like FM_spawn) every round
 
@Dores
if u remove an ent it will never com back

@ConnorMcLeod
never seen something like this before...i will try it out =)

Dores 03-28-2009 17:14

Re: get a forward that give me "ent" (like FM_spawn) every round
 
Oh, sorry. I guess I've misunderstood you. Connor's code should work by your needs then.

ScHrAnZ DiNgEnS 03-28-2009 17:15

Re: get a forward that give me "ent" (like FM_spawn) every round
 
no problem...and thanks to you

ScHrAnZ DiNgEnS 03-28-2009 17:25

Re: get a forward that give me "ent" (like FM_spawn) every round
 
@ ConnorMcLeod

Works perfect...is exactly that what i need =)
THAAAAAAAAANKS


All times are GMT -4. The time now is 08:51.

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