There's simpler solution:
PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "2.0"
public Plugin myinfo =
{
name = "Sticky ladders",
author = "juice",
description = "Stick to ladders without holding strafe keys",
version = PLUGIN_VERSION,
url = "https://github.com/juicejuicejuice"
};
ConVar sm_sticky_ladders;
public void OnPluginStart()
{
sm_sticky_ladders = CreateConVar("sm_sticky_ladders", "1", "Enable sticky ladders");
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float move[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
{
if (!sm_sticky_ladders.BoolValue || !IsPlayerAlive(client) || GetEntityMoveType(client) != MOVETYPE_WALK)
{
return Plugin_Continue;
}
if (!move[0] && !move[1])
{
float wishdir[3];
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", wishdir);
if (wishdir[0] || wishdir[1] || wishdir[2])
{
NormalizeVector(wishdir, wishdir);
NegateVector(wishdir);
SetEntPropVector(client, Prop_Data, "m_vecLadderNormal", wishdir);
SetEntityMoveType(client, MOVETYPE_LADDER);
}
}
return Plugin_Continue;
}