Hello AlliedModders
Sometimes when you have Auto BunnyHop installed in your server and a player gets stuck in func_rotating (or some other entities)
the console gets spammed with the following message and finally it crashes.
Code:
PM Got a NaN velocity 1
PM Got a NaN velocity 0
I saw this in HLSDK.
PHP Code:
extern int nanmask;
#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
void PM_CheckVelocity ()
{
int i;
for (i=0 ; i<3 ; i++)
{
// See if it's bogus.
if (IS_NAN(pmove->velocity[i]))
{
pmove->Con_Printf ("PM Got a NaN velocity %i\n", i);
pmove->velocity[i] = 0;
}
if (IS_NAN(pmove->origin[i]))
{
pmove->Con_Printf ("PM Got a NaN origin on %i\n", i);
pmove->origin[i] = 0;
}
// Bound it.
if (pmove->velocity[i] > pmove->movevars->maxvelocity)
{
pmove->Con_DPrintf ("PM Got a velocity too high on %i\n", i);
pmove->velocity[i] = pmove->movevars->maxvelocity;
}
else if (pmove->velocity[i] < -pmove->movevars->maxvelocity)
{
pmove->Con_DPrintf ("PM Got a velocity too low on %i\n", i);
pmove->velocity[i] = -pmove->movevars->maxvelocity;
}
}
}
What i wanted to do is catch this event with Orpheu and respawn the player if velocity is NaN.
The problem is that i don't understand orpheu neither that #define, that's why i'm posting
this as a request and not in scripting section.
I tried the following code from metalicross (found in alliedmodders) and also some that i wrote to test,
but the function never got called. I'm also posting the files (i don't know if they are correct, i used the ones
joaquimandrades posted but they are old)
PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < orpheu >
#include < orpheu_stocks >
#include < orpheu_memory >
#include < orpheu_advanced >
new OrpheuStruct:g_pPMove;
public plugin_init( )
{
OrpheuRegisterHook( OrpheuGetDLLFunction( "pfnPM_Move", "PM_Move" ), "PM_Move" );
OrpheuRegisterHook( OrpheuGetFunction( "PM_CheckVelocity" ), "PM_CheckVelocity" );
//OrpheuRegisterHook( OrpheuGetFunction( "PM_CheckVelocity" ), "PM_CheckVelocity" );
}
public PM_Move( OrpheuStruct:ppmove, server )
{
g_pPMove = ppmove;
console_print( 0, "PM MOVE" );
}
public PM_CheckVelocity( )
{
//new OrpheuStruct:ppmove = OrpheuGetStructFromAddress( OrpheuStructPlayerMove, OrpheuMemoryGet( "ppmove" ) );
new iPlayer = OrpheuGetStructMember( g_pPMove, "player_index" ) + 1;
//new iPlayer = OrpheuGetStructMember( ppmove, "player_index" ) + 1;
console_print( iPlayer, "PM CHECK VELOCITY" );
}
/*public OrpheuHookReturn:PM_CheckVelocity( )
{
new OrpheuStruct:ppmove = OrpheuGetStructFromAddress( OrpheuStructPlayerMove, OrpheuMemoryGet( "ppmove" ) );
//new iPlayer = OrpheuGetStructMember( ppmove, "player_index" ) + 1;
console_print( iPlayer, "PM CHECK VELOCITY" );
}*/
Code:
{
"name" : "PM_Move",
"library" : "mod",
"arguments" :
[
{
"type" : "playermove_s *"
},
{
"type" : "qboolean"
}
],
"identifiers" :
[
{
"os" : "windows",
"mod" : "cstrike",
"value" : 0xbffc0
},
{
"os" : "linux",
"mod" : "cstrike",
"value" : "PM_Move"
}
]
}
Code:
{
"name" : "PM_CheckVelocity",
"library" : "mod",
"identifiers" :
[
{
"os" : "windows",
"mod" : "cstrike",
"value" : 0xBB5E0
},
{
"os" : "linux",
"mod" : "cstrike",
"value" : "PM_CheckVelocity"
}
]
}
Thanks in advance.
__________________