marcelowzd |
05-12-2019 08:04 |
Re: Ham_Blocked and setting origins
There are 2 entities in this map that can cause damage, one of them is func_door and the
other is trigger_hurt. Func_rotating can't kill the player but can get him stuck and cause
overflow.
I tried with another method that also has the same problem as the above code. My Origin never
gets changed.
PHP Code:
#include < amxmodx > #include < fakemeta > #include < engine > #include < hamsandwich >
new Float:g_fSpawnLocations[ 32 ][ 3 ];
new g_iSpawnCount;
public plugin_init( ) { new const szPlugin[ ] = "Maps Fixer"; new const szVersion[ ] = "0.0.1"; new const szAuthor[ ] = "Me";
register_plugin( szPlugin, szVersion, szAuthor );
new iEnt = -1, Float:fOrigin[ 3 ];
while( ( iEnt = engfunc( EngFunc_FindEntityByString, iEnt, "classname", "info_player_start" ) ) ) { pev( iEnt, pev_origin, fOrigin );
g_fSpawnLocations[ g_iSpawnCount ] = fOrigin;
g_iSpawnCount++; }
new szMapName[ 32 ]; get_mapname( szMapName, charsmax( szMapName ) );
if( equali( szMapName, "bhop_corrida3" ) ) { RegisterHam( Ham_Blocked, "func_rotating", "OnRotatingBlocked", 0 );
RegisterHam( Ham_TakeDamage, "player", "OnPlayerTakeDamage", 0 ); // Stop damage by door and trigger_hurt } }
public OnRotatingBlocked( iEnt, iPlayer ) { if( !pev_valid( iEnt ) || !IsEntityPlayer( iPlayer ) || !is_user_alive( iPlayer ) ) return HAM_IGNORED;
new iRandom = random_num( 0, g_iSpawnCount - 1 );
engfunc( EngFunc_SetOrigin, iPlayer, g_fSpawnLocations[ iRandom ] );
log_amx( "Logging positions for iClient %i: %f --> %f --> %f", iPlayer, g_fSpawnLocations[ iRandom ][ 0 ], g_fSpawnLocations[ iRandom ][ 1 ], g_fSpawnLocations[ iRandom ][ 2 ] );
//ExecuteHamB( Ham_CS_RoundRespawn, iPlayer );
return HAM_IGNORED; }
public OnPlayerTakeDamage( iVictim, iInflictor, iAttacker, Float:fDamage, biDmg ) { if( !IsEntityPlayer( iVictim ) ) return HAM_IGNORED; new szClassname[ 32 ];
pev( iAttacker, pev_classname, szClassname, charsmax( szClassname ) );
if( !equal( szClassname, "func_door" ) && !equal( szClassname, "trigger_hurt" ) ) return HAM_IGNORED;
if( !( biDmg & DMG_CRUSH ) && !( biDmg & DMG_BURN ) ) // CRUSH from func_door and BURN from trigger_hurt return HAM_IGNORED;
log_amx( "Damaged by either func_door or trigger_hurt" );
new iRandom = random_num( 0, g_iSpawnCount - 1 );
engfunc( EngFunc_SetOrigin, iVictim, g_fSpawnLocations[ iRandom ] );
return HAM_SUPERCEDE; }
And the output
Code:
L 05/12/2019 - 09:55:38: [BhopMapsFixer.amxx] Damaged by either func_door or trigger_hurt // (func_door is this one)
L 05/12/2019 - 09:55:49: [BhopMapsFixer.amxx] Damaged by either func_door or trigger_hurt // (trigger_hurt is this one)
But, there is a difference here. The function is called for both func_door and trigger_hurt
and the damage done is stopped, but when func_door is the one dealing damage, the same problem
happens, the player origin is not changed. It does work with trigger_hurt but not with func_door.
|