I'm trying to force clients to jump right before they fall off an edge. I'm able to detect falls but by the time I do, it's already too late.
I tried teleporting clients to their latest safe position but that didn't seem to work either, plus it probably messes up client prediction.
PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
// Ignore lack of arrays, just testing
int buttons_old;
int flags_old;
float origin_old[3];
public Action OnPlayerRunCmd(int client,int &buttons,int &impulse, float vel[3], float angles[3],int &weapon)
{
if (!IsClientInGame(client) || !IsPlayerAlive(client))
return Plugin_Continue;
int flags = GetEntityFlags(client);
// Player is falling wasn't previously didn't jump
if( !(flags & FL_ONGROUND) && (flags_old & FL_ONGROUND) && !(buttons_old & IN_JUMP) )
{
TeleportEntity(client, origin_old, NULL_VECTOR, NULL_VECTOR);
buttons &= ~IN_JUMP;
PrintToChatAll("[Debug] Edge drop");
}
buttons_old = buttons;
flags_old = flags;
GetClientAbsOrigin(client, origin_old);
return Plugin_Continue;
}
Does anyone know how I'd go about doing this sort of thing? Thanks