AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_Spawn - bad; FM_Spawn - good; Why? (https://forums.alliedmods.net/showthread.php?t=102400)

Exolent[jNr] 09-01-2009 23:39

Ham_Spawn - bad; FM_Spawn - good; Why?
 
Ham_Spawn:
PHP Code:

#include < amxmodx >
#include < amxmisc >
#include < engine >
#include < hamsandwich >

public plugin_precache()
{
    new 
iEntity create_entity"player_weaponstrip" );
    
DispatchKeyValueiEntity"targetname""stripper" );
    
DispatchSpawniEntity );
    
    
iEntity create_entity"game_player_equip" );
    
DispatchKeyValueiEntity"weapon_knife""1" );
    
DispatchKeyValueiEntity"targetname""equipment" );
    
    
iEntity create_entity"multi_manager" );
    
DispatchKeyValueiEntity"stripper""0" );
    
DispatchKeyValueiEntity"equipment""0.5" );
    
DispatchKeyValueiEntity"targetname""game_playerspawn" );
    
DispatchKeyValueiEntity"spawnflags""1" );
    
DispatchSpawniEntity );
    
    
iEntity create_entity"info_map_parameters" );
    
DispatchKeyValueiEntity"buying""3" );
    
DispatchSpawniEntity );
    
    new const 
sRemoveEntities[][] =
    {
        
"func_bomb_target",
        
"info_bomb_target",
        
"hostage_entity",
        
"monster_scientist",
        
"func_hostage_rescue",
        
"info_hostage_rescue",
        
"info_vip_start",
        
"func_vip_safetyzone",
        
"func_escapezone",
        
"armoury_entity",
        
"info_map_parameters",
        
"player_weaponstrip",
        
"game_player_equip",
        
"func_buyzone"
    
};
    
    for( new 
0sizeofsRemoveEntities ); i++ )
    {
        
RegisterHamHam_SpawnsRemoveEntities], "FwdSpawn" );
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
pfn_keyvalueiEntity )
{
    static 
szClassname32 ], szKey32 ], szValue32 ];
    
copy_keyvalueszClassname31szKey31szValue31 );
    
    if( 
equalszClassname"multi_manager" )
    && 
equalszKey"targetname" )
    && 
equalszValue"game_playerspawn" ) )
    {
        
remove_entityiEntity );
        
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
FwdSpawniEntity )
{
    
remove_entityiEntity );
    
    return 
HAM_SUPERCEDE;


FM_Spawn:
PHP Code:

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

new Trie:g_tRemoveEntities;

public 
plugin_precache()
{
    new 
iEntity create_entity"player_weaponstrip" );
    
DispatchKeyValueiEntity"targetname""stripper" );
    
DispatchSpawniEntity );
    
    
iEntity create_entity"game_player_equip" );
    
DispatchKeyValueiEntity"weapon_knife""1" );
    
DispatchKeyValueiEntity"targetname""equipment" );
    
    
iEntity create_entity"multi_manager" );
    
DispatchKeyValueiEntity"stripper""0" );
    
DispatchKeyValueiEntity"equipment""0.5" );
    
DispatchKeyValueiEntity"targetname""game_playerspawn" );
    
DispatchKeyValueiEntity"spawnflags""1" );
    
DispatchSpawniEntity );
    
    
iEntity create_entity"info_map_parameters" );
    
DispatchKeyValueiEntity"buying""3" );
    
DispatchSpawniEntity );
    
    new const 
sRemoveEntities[][] =
    {
        
"func_bomb_target",
        
"info_bomb_target",
        
"hostage_entity",
        
"monster_scientist",
        
"func_hostage_rescue",
        
"info_hostage_rescue",
        
"info_vip_start",
        
"func_vip_safetyzone",
        
"func_escapezone",
        
"armoury_entity",
        
"info_map_parameters",
        
"player_weaponstrip",
        
"game_player_equip",
        
"func_buyzone"
    
};
    
    
g_tRemoveEntities TrieCreate( );
    
    for( new 
0sizeofsRemoveEntities ); i++ )
    {
        
TrieSetCellg_tRemoveEntitiessRemoveEntities], );
    }
    
    
register_forwardFM_Spawn"FwdSpawn" );
    
    return 
PLUGIN_CONTINUE;
}

public 
plugin_end()
{
    
TrieDestroyg_tRemoveEntities );
}

public 
pfn_keyvalueiEntity )
{
    static 
szClassname32 ], szKey32 ], szValue32 ];
    
copy_keyvalueszClassname31szKey31szValue31 );
    
    if( 
equalszClassname"multi_manager" )
    && 
equalszKey"targetname" )
    && 
equalszValue"game_playerspawn" ) )
    {
        
remove_entityiEntity );
        
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
FwdSpawniEntity )
{
    static 
szClassname32 ];
    
entity_get_stringiEntityEV_SZ_classnameszClassname31 );
    
    if( 
TrieKeyExistsg_tRemoveEntitiesszClassname ) )
    {
        
remove_entityiEntity );
        
        return 
FMRES_SUPERCEDE;
    }
    
    return 
FMRES_IGNORED;


The problem is that when I use Ham_Spawn version, it deletes the spawn points or something because there are none anymore and when you join the server, you can't choose a team because they are full, even though there are no players. Also, your camera when you join is somewhere in the wall or random in the map. But, when I use FM_Spawn, everything works perfectly.

xPaw 09-02-2009 00:32

Re: Ham_Spawn - bad; FM_Spawn - good; Why?
 
This happened with me for some other ents, heres my topic http://forums.alliedmods.net/showthread.php?t=93624

Arkshine 09-02-2009 04:25

Re: Ham_Spawn - bad; FM_Spawn - good; Why?
 
I don't know how Ham works exactly, but like func_door and func_water which have the same class CBaseDoor ;

CPointEntity : info_player_start, func_bomb_target, info_bomb_target, func_hostage_rescue, info_hostage_rescue
CBaseDMStart : info_player_deathmatch, info_vip_start, func_vip_safetyzone

It seems that Ham_Spawn spawns all entities of the same internal class. I think it's a bug because RegisterHamFromEntity is supposed to do that and not RegisterHam.


All times are GMT -4. The time now is 15:13.

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