AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Change Map Entity (https://forums.alliedmods.net/showthread.php?t=217552)

dias 06-04-2013 08:58

[Help] Change Map Entity
 
Well, i got a map from CSO.
But the problem is:

Round 1: The main door auto break so player can move out from the room
But from Round 2 until.... The main door doesn't auto break. -> Player can't move out and stuck in the room

My friend said: "we need to change trigger_once to trigger_multiple".
So how to change with amxx ?

I tried and nothing. Here is my code:
PHP Code:

public pfn_keyvalue(ent)
{
    new 
classname[32], key[32], value[32]
    
copy_keyvalue(classname31key31value31)

    if(
equal(classname"trigger_once"))
    {
        if(
equal(key"target") && equal(value"start"))
        {
            
DispatchKeyValue("classname""trigger_multiple")
            
DispatchSpawn(ent)
        }
    }



TheDS1337 06-04-2013 09:41

Re: [Help] Change Map Entity
 
Maybe using, pev and set_pev ? with pev_classname :O

dias 06-04-2013 09:45

Re: [Help] Change Map Entity
 
i tried and nothing..

TheDS1337 06-04-2013 10:07

Re: [Help] Change Map Entity
 
I really don't know, but maybe you can delete it, and make new entity have the same origin, size ... of it
Code:

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >

public plugin_init( )
        register_forward( FM_Spawn, "OnEntitySpawn" );
       
public OnEntitySpawn( Entity )
{
        if( pev_valid( Entity ) ) // Not a NULL Entity
        {
                static ClassName[ 32 ];
                pev( Entity, pev_classname, ClassName, charsmax( ClassName ) );
                if( equal( ClassName, "trigger_once" ) )
                {                       
                        static NewEntity;
                        NewEntity = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "trigger_multiple" ) );
                       
                        set_pev( NewEntity, pev_origin, pev( Entity, pev_origin ) );                       
                        engfunc( EngFunc_SetSize, NewEntity, pev( Entity, pev_mins ), pev( Entity, pev_maxs ) );
                        engfunc( EngFunc_RemoveEntity, Entity );
                        return FMRES_SUPERCEDE;
                }
        }
        return FMRES_IGNORED;
}


hornet 06-04-2013 10:28

Re: [Help] Change Map Entity
 
Changing the entity's classname should work but you woud need to hook spawn in plugin precache.

.Dare Devil. 06-04-2013 12:38

Re: [Help] Change Map Entity
 
if you create trigger entity then its need:
target; if player touch, then which entity will be triggered
model; this is for hull, because without model or mins/maxs you cant touch it
you can copy those from trigger_once

dias 06-04-2013 20:11

Re: [Help] Change Map Entity
 
So we can do like DeagLe.Studio did in the Post #4 ?

dias 06-05-2013 03:03

Re: [Help] Change Map Entity
 
Ok. Now i got a new problem. The door exploses continously... (even round 1)
Here is my code. Is there anything wrong ?
PHP Code:

public plugin_precache()
{
    
register_forward(FM_Spawn"fw_Spawn")
}

public 
fw_Spawn(ent)
{
    if(!
pev_valid(ent))
        return 
FMRES_IGNORED

    
static ClassName[32], Target[64]
    
pev(entpev_classnameClassNamecharsmax(ClassName))
    
pev(entpev_targetTargetsizeof(Target))
    
    if(
equal(ClassName"trigger_once") && equal(Target"start"))
    {
        static 
NewEntityFloat:Origin[3], String[64]
        
NewEntity engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"trigger_multiple"))
        
        
fm_set_kvd(NewEntity"model""*101")
        
fm_set_kvd(NewEntity"target""start")
        
fm_set_kvd(NewEntity"style""32")
        
        
dllfunc(DLLFunc_SpawnNewEntity)
        
        
Big 1
        
        
return FMRES_SUPERCEDE
    
}
    
    return 
FMRES_IGNORED



TheDS1337 06-05-2013 03:16

Re: [Help] Change Map Entity
 
Quote:

Originally Posted by dias (Post 1964909)
Ok. Now i got a new problem. The door exploses continously... (even round 1)
Here is my code. Is there anything wrong ?
PHP Code:

public plugin_precache()
{
    
register_forward(FM_Spawn"fw_Spawn")
}

public 
fw_Spawn(ent)
{
    if(!
pev_valid(ent))
        return 
FMRES_IGNORED

    
static ClassName[32], Target[64]
    
pev(entpev_classnameClassNamecharsmax(ClassName))
    
pev(entpev_targetTargetsizeof(Target))
    
    if(
equal(ClassName"trigger_once") && equal(Target"start"))
    {
        static 
NewEntityFloat:Origin[3], String[64]
        
NewEntity engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"trigger_multiple"))
        
        
fm_set_kvd(NewEntity"model""*101")
        
fm_set_kvd(NewEntity"target""start")
        
fm_set_kvd(NewEntity"style""32")
        
        
dllfunc(DLLFunc_SpawnNewEntity)
        
        
Big 1
        
        
return FMRES_SUPERCEDE
    
}
    
    return 
FMRES_IGNORED



Maybe you need to remove old entity
Code:

engfunc(EngFunc_RemoveEntity, ent)

dias 06-05-2013 03:48

Re: [Help] Change Map Entity
 
^
- No need.
You returned FMRES_SUPERCEDE -> Entity removed


All times are GMT -4. The time now is 16:19.

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