I was wondering if someone could please create me a snippet for checking if a player is currently surfing, possibly with comments aswell.
I was checking around and found that you can do that with TraceFilters, but I have no experience in using them in Source.Python.
Maybe this could be useful:
Code: Select all
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
if(g_bSlopeFixEnable == true)
{
g_bLastOnGround[client] = g_bOnGround[client];
if (GetEntityFlags(client) & FL_ONGROUND)
g_bOnGround[client] = true;
else
g_bOnGround[client] = false;
g_vLast[client][0] = g_vCurrent[client][0];
g_vLast[client][1] = g_vCurrent[client][1];
g_vLast[client][2] = g_vCurrent[client][2];
g_vCurrent[client][0] = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[0]");
g_vCurrent[client][1] = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[1]");
g_vCurrent[client][2] = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[2]");
// Check if player landed on the ground
if (g_bOnGround[client] == true && g_bLastOnGround[client] == false)
{
// Set up and do tracehull to find out if the player landed on a slope
float vPos[3];
GetEntPropVector(client, Prop_Data, "m_vecOrigin", vPos);
float vMins[3];
GetEntPropVector(client, Prop_Send, "m_vecMins", vMins);
float vMaxs[3];
GetEntPropVector(client, Prop_Send, "m_vecMaxs", vMaxs);
float vEndPos[3];
vEndPos[0] = vPos[0];
vEndPos[1] = vPos[1];
vEndPos[2] = vPos[2] - FindConVar("sv_maxvelocity").FloatValue;
TR_TraceHullFilter(vPos, vEndPos, vMins, vMaxs, MASK_PLAYERSOLID_BRUSHONLY, TraceRayDontHitSelf, client);
if(TR_DidHit())
{
// Gets the normal vector of the surface under the player
float vPlane[3], vLast[3];
TR_GetPlaneNormal(INVALID_HANDLE, vPlane);
// Make sure it's not flat ground and not a surf ramp (1.0 = flat ground, < 0.7 = surf ramp)
if(0.7 <= vPlane[2] < 1.0)
{
[...]
}
}
}
}
}
Thanks in advice.