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_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 szMapName[ 32 ]; get_mapname( szMapName, charsmax( szMapName ) );
if( equali( szMapName, "bhop_corrida3" ) )
{
RegisterHam( Ham_Blocked, "func_rotating", "OnRotatingBlocked", 0 /*Also tried with 1*/ );
register_forward( FM_SetOrigin, "OnSetOrigin", 1 ); // Debug
}
}
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 ] ); // THIS
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 OnSetOrigin( iEnt, Float:fOrigin[ 3 ] )
{
new szClassname[ 32 ];
pev( iEnt, pev_classname, szClassname, charsmax( szClassname ) );
log_amx( "SetOrigin on iEnt %i classname %s--> %f --> %f --> %f", iEnt, szClassname, fOrigin[ 0 ], fOrigin[ 1 ], fOrigin[ 2 ] );
}
public plugin_precache( )
{
register_forward( FM_Spawn, "OnEntitySpawn" );
}
public OnEntitySpawn( iEnt )
{
if( !pev_valid( iEnt ) )
return FMRES_IGNORED;
new szClassname[ 32 ];
pev( iEnt, pev_classname, szClassname, charsmax( szClassname ) );
if( equali( szClassname, "info_player_start" ) ) // CT Spawn
{
new Float:fOrigin[ 3 ];
pev( iEnt, pev_origin, fOrigin );
g_fSpawnLocations[ g_iSpawnCount ] = fOrigin;
g_iSpawnCount++;
}
return FMRES_IGNORED;
}
stock bool:IsEntityPlayer( iEnt )
{
if( iEnt > 0 && 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
__________________