AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_Blocked and setting origins (https://forums.alliedmods.net/showthread.php?t=316193)

marcelowzd 05-11-2019 22:47

Ham_Blocked and setting origins
 
Hello guys, i'm trying to respawn a player when he gets stuck in a func_rotating.

For now i have the following code
PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < engine >
#include < hamsandwich >

new Float:g_fSpawnLocations32 ][ ];

new 
g_iSpawnCount;

public 
plugin_init( )
{
    new const 
szPlugin[ ] = "Maps Fixer";
    new const 
szVersion[ ] = "0.0.1";
    new const 
szAuthor[ ] = "Me";

    
register_pluginszPluginszVersionszAuthor );

    new 
szMapName32 ]; get_mapnameszMapNamecharsmaxszMapName ) );

    if( 
equaliszMapName"bhop_corrida3" ) )
    {
        
RegisterHamHam_Blocked"func_rotating""OnRotatingBlocked"/*Also tried with 1*/ );

        
register_forwardFM_SetOrigin"OnSetOrigin"); // Debug
    
}
}

public 
OnRotatingBlockediEntiPlayer )
{
    if( !
pev_validiEnt ) || !IsEntityPlayeriPlayer ) || !is_user_aliveiPlayer ) )
        return 
HAM_IGNORED;

    new 
iRandom random_num0g_iSpawnCount );

    
engfuncEngFunc_SetOriginiPlayerg_fSpawnLocationsiRandom ] ); // THIS

    
log_amx"Logging positions for iClient %i: %f --> %f --> %f"iPlayerg_fSpawnLocationsiRandom ][ ], g_fSpawnLocationsiRandom ][ ], g_fSpawnLocationsiRandom ][ ] );

    
//ExecuteHamB( Ham_CS_RoundRespawn, iPlayer );

    
return HAM_IGNORED;
}

public 
OnSetOriginiEntFloat:fOrigin] )
{
    new 
szClassname32 ];

    
peviEntpev_classnameszClassnamecharsmaxszClassname ) );

    
log_amx"SetOrigin on iEnt %i classname %s--> %f --> %f --> %f"iEntszClassnamefOrigin], fOrigin], fOrigin] );
}

public 
plugin_precache( )
{
    
register_forwardFM_Spawn"OnEntitySpawn" );
}

public 
OnEntitySpawniEnt )
{
    if( !
pev_validiEnt ) )
        return 
FMRES_IGNORED;

    new 
szClassname32 ];

    
peviEntpev_classnameszClassnamecharsmaxszClassname ) );
    
    if( 
equaliszClassname"info_player_start" ) ) // CT Spawn
    
{
        new 
Float:fOrigin];

        
peviEntpev_originfOrigin );

        
g_fSpawnLocationsg_iSpawnCount ] = fOrigin;

        
g_iSpawnCount++;
    }

    return 
FMRES_IGNORED;
}

stock bool:IsEntityPlayeriEnt )
{
    if( 
iEnt && iEnt 33 )
        return 
true;

    return 
false;


And the output from the logs are the following (much bigger than this actually, but always the same)
Code:

L 05/12/2019 - 00:10:35: [BhopMapsFixer.amxx] SetOrigin on iEnt 2 classname player--> 0.000000 --> 0.000000 --> 1.000000
L 05/12/2019 - 00:10:35: [BhopMapsFixer.amxx] SetOrigin on iEnt 2 classname player--> 2944.000000 --> -3072.000000 --> -127.000000
L 05/12/2019 - 00:10:35: [BhopMapsFixer.amxx] SetOrigin on iEnt 322 classname weapon_knife--> 2944.000000 --> -3072.000000 --> -127.000000
L 05/12/2019 - 00:10:35: [BhopMapsFixer.amxx] SetOrigin on iEnt 3 classname player--> 0.000000 --> 0.000000 --> 1.000000
L 05/12/2019 - 00:10:35: [BhopMapsFixer.amxx] SetOrigin on iEnt 3 classname player--> 2560.000000 --> -3072.000000 --> -127.000000
L 05/12/2019 - 00:10:36: [BhopMapsFixer.amxx] SetOrigin on iEnt 1 classname player--> 0.000000 --> 0.000000 --> 1.000000
L 05/12/2019 - 00:10:37: [BhopMapsFixer.amxx] SetOrigin on iEnt 324 classname weapon_knife--> 2176.000000 --> -3072.000000 --> -127.000000
L 05/12/2019 - 00:10:37: [BhopMapsFixer.amxx] SetOrigin on iEnt 325 classname weapon_usp--> 2176.000000 --> -3072.000000 --> -127.000000
L 05/12/2019 - 00:10:37: [BhopMapsFixer.amxx] SetOrigin on iEnt 1 classname player--> 2176.000000 --> -3072.000000 --> -127.000000
L 05/12/2019 - 00:11:01: [BhopMapsFixer.amxx] SetOrigin on iEnt 11 classname func_door--> -0.000025 --> 0.000000 --> -576.000061
L 05/12/2019 - 00:11:04: [BhopMapsFixer.amxx] Logging positions for iClient 3: 2528.000000 --> -2272.000000 --> -128.000000
L 05/12/2019 - 00:11:04: [BhopMapsFixer.amxx] Logging positions for iClient 3: 2560.000000 --> -3072.000000 --> -128.000000
L 05/12/2019 - 00:11:04: [BhopMapsFixer.amxx] Logging positions for iClient 3: 2528.000000 --> -2656.000000 --> -128.000000
L 05/12/2019 - 00:11:04: [BhopMapsFixer.amxx] Logging positions for iClient 3: 2912.000000 --> -2848.000000 --> -128.000000
L 05/12/2019 - 00:11:04: [BhopMapsFixer.amxx] Logging positions for iClient 3: 2336.000000 --> -2272.000000 --> -128.000000
L 05/12/2019 - 00:11:04: [BhopMapsFixer.amxx] Logging positions for iClient 3: 2368.000000 --> -3072.000000 --> -128.000000
L 05/12/2019 - 00:11:04: [BhopMapsFixer.amxx] Logging positions for iClient 3: 2720.000000 --> -2848.000000 --> -128.000000
L 05/12/2019 - 00:11:04: [BhopMapsFixer.amxx] Logging positions for iClient 3: 3104.000000 --> -2464.000000 --> -128.000000

The problem is that my origin never gets changed even though the function is called
and engfunc( EngFunc_SetOrigin, iPlayer, g_fSpawnLocations[ iRandom ] ) is there.
What am i doing wrong?
I also tried using ExecuteHamB( Ham_CS_RoundRespawn, iPlayer ), but then i get stuck behind a
wall. The map i'm using to test this is bhop_corrida3, as shown in the code

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_fSpawnLocations32 ][ ];

new 
g_iSpawnCount;

public 
plugin_init( )
{
    new const 
szPlugin[ ] = "Maps Fixer";
    new const 
szVersion[ ] = "0.0.1";
    new const 
szAuthor[ ] = "Me";

    
register_pluginszPluginszVersionszAuthor );

    new 
iEnt = -1Float:fOrigin];

    while( ( 
iEnt engfuncEngFunc_FindEntityByStringiEnt"classname""info_player_start" ) ) )
    {
        
peviEntpev_originfOrigin );

        
g_fSpawnLocationsg_iSpawnCount ] = fOrigin;

        
g_iSpawnCount++;
    }

    new 
szMapName32 ]; get_mapnameszMapNamecharsmaxszMapName ) );

    if( 
equaliszMapName"bhop_corrida3" ) )
    {
        
RegisterHamHam_Blocked"func_rotating""OnRotatingBlocked");

        
RegisterHamHam_TakeDamage"player""OnPlayerTakeDamage"); // Stop damage by door and trigger_hurt
    
}
}

public 
OnRotatingBlockediEntiPlayer )
{
    if( !
pev_validiEnt ) || !IsEntityPlayeriPlayer ) || !is_user_aliveiPlayer ) )
        return 
HAM_IGNORED;

    new 
iRandom random_num0g_iSpawnCount );

    
engfuncEngFunc_SetOriginiPlayerg_fSpawnLocationsiRandom ] );

    
log_amx"Logging positions for iClient %i: %f --> %f --> %f"iPlayerg_fSpawnLocationsiRandom ][ ], g_fSpawnLocationsiRandom ][ ], g_fSpawnLocationsiRandom ][ ] );

    
//ExecuteHamB( Ham_CS_RoundRespawn, iPlayer );

    
return HAM_IGNORED;
}

public 
OnPlayerTakeDamageiVictimiInflictoriAttackerFloat:fDamagebiDmg )
{
    if( !
IsEntityPlayeriVictim ) )
        return 
HAM_IGNORED;
    
    new 
szClassname32 ];

    
peviAttackerpev_classnameszClassnamecharsmaxszClassname ) );

    if( !
equalszClassname"func_door" ) && !equalszClassname"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_num0g_iSpawnCount );

    
engfuncEngFunc_SetOriginiVictimg_fSpawnLocationsiRandom ] );

    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.


All times are GMT -4. The time now is 22:26.

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