Raised This Month: $32 Target: $400
 8% 

Make admin only please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ricksfishin
Senior Member
Join Date: Oct 2017
Old 10-01-2021 , 21:32   Make admin only please
Reply With Quote #1

PHP Code:
#pragma newdecls required
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdktools_functions>
#include <sdkhooks>

#define Pie 3.14159265358979323846

#define State_None 0
#define State_Climb 1
#define State_OnAir 2

#define ACT_CLIMB_UP "ACT_CLIMB_UP"

#define ZOMBIECLASS_SURVIVOR 9
#define ZOMBIECLASS_SMOKER 1
#define ZOMBIECLASS_BOOMER 2
#define ZOMBIECLASS_HUNTER 3
#define ZOMBIECLASS_SPITTER 4
#define ZOMBIECLASS_JOCKEY 5
#define ZOMBIECLASS_CHARGER 6

static int ZOMBIECLASS_TANK;

#define model_zoey 1
#define model_bill 2
#define model_louis 3
#define model_francis 4
#define model_coach 5
#define model_nick 6
#define model_ellis 7
#define model_rochelle 8

#define model_tank 9
#define model_boomer 10
#define model_smoker 11
#define model_hunter 12
#define model_spitter 13
#define model_jockey 14
#define model_charger 15
#define model_boomer_female 16

#define JumpSpeed 300.0 
#define gbodywidth 20.0 
#define bodylength 70.0

Handle l4d_climb_enable;  
Handle l4d_climb_team
Handle l4d_climb_glow
Handle l4d_climb_msg;
Handle l4d_climb_speed[10]; 
Handle l4d_climb_infected[10];

static 
int GameMode;
static 
bool L4D2Version;

static 
int Clone[MAXPLAYERS+1] = -1;

static 
bool FirstRun[MAXPLAYERS+1];

static 
float BodyNormal[MAXPLAYERS+1][3];
static 
float Angle[MAXPLAYERS+1];

static 
int State[MAXPLAYERS+1];

static 
float BodyPos[MAXPLAYERS+1][3];
static 
float LastPos[MAXPLAYERS+1][3];
static 
float SafePos[MAXPLAYERS+1][3];

static 
float BodyWidth[MAXPLAYERS+1];

static 
float JumpTime[MAXPLAYERS+1];
static 
float LastTime[MAXPLAYERS+1];

static 
float Interval[MAXPLAYERS+1];

static 
float GlowTime[MAXPLAYERS+1];
static 
bool GlowIndicator[MAXPLAYERS+1];

static 
float ClimbSpeed[MAXPLAYERS+1];
static 
float PlayBackRate[MAXPLAYERS+1];
static 
float StuckIndicator[MAXPLAYERS+1];  

static 
int ShowMsg[MAXPLAYERS+1];

public 
Plugin myinfo 
{
    
name "Climb Everywhere",
    
author "Pan Xiaohai, Shadowysn (New syntax)",
    
description "Makes Everyone Climb On Surfaces.",
    
version "1.05",
}
 
public 
void OnPluginStart()
{
    
GameCheck();
    
     
l4d_climb_enable CreateConVar("climb_everywhere_enable""1""Enable Mode: 1=Co-op Only, 2=All Game Modes"FCVAR_ARCHIVE);
    
l4d_climb_team CreateConVar("climb_everywhere_team""2""Enable Mode: 1=Both Teams, 2=Survivors Team Only, 3=Infected Team Only"FCVAR_ARCHIVE);    
    
l4d_climb_msg CreateConVar("climb_everywhere_msg""0""Limit Of Messages Shown"FCVAR_ARCHIVE);    
    
l4d_climb_glow CreateConVar("climb_everywhere_glow""0""Enable/Disable Glow"FCVAR_ARCHIVE);
    
    
l4d_climb_infected[ZOMBIECLASS_HUNTER] = CreateConVar("climb_everywhere_hunter""0""Hunter Enable Mode: 1=On, 2=Only Alive"FCVAR_ARCHIVE);    
    
l4d_climb_infected[ZOMBIECLASS_SMOKER] = CreateConVar("climb_everywhere_smoker""0""Smoker Enable Mode: 1=On, 2=Only Alive"FCVAR_ARCHIVE);    
    
l4d_climb_infected[ZOMBIECLASS_TANK] = CreateConVar("climb_everywhere_tank""0""Tank Enable Mode: 1=On, 2=Only Alive"FCVAR_ARCHIVE);    
    
l4d_climb_infected[ZOMBIECLASS_BOOMER] = CreateConVar("climb_everywhere_boomer""0""Boomer Enable Mode: 1=On, 2=Only Alive"FCVAR_ARCHIVE);    
    
l4d_climb_infected[ZOMBIECLASS_JOCKEY] = CreateConVar("climb_everywhere_jockey""0""Jockey Enable Mode: 1=On, 2=Only Alive"FCVAR_ARCHIVE);    
    
l4d_climb_infected[ZOMBIECLASS_SPITTER] = CreateConVar("climb_everywhere_spitter""0""Spitter Enable Mode: 1=On, 2=Only Alive"FCVAR_ARCHIVE);    
    
l4d_climb_infected[ZOMBIECLASS_CHARGER] = CreateConVar("climb_everywhere_charger""0""Charger Enable Mode: 1=On, 2=Only Alive"FCVAR_ARCHIVE);    
    
    
l4d_climb_speed[0] = CreateConVar("climb_everywhere_speed""80""Speed Applied When Climbing"FCVAR_ARCHIVE);
    
l4d_climb_speed[ZOMBIECLASS_SURVIVOR] = CreateConVar("climb_everywhere_speed_survivor""1.1""Speed Applied For Survivors"FCVAR_ARCHIVE);
    
l4d_climb_speed[ZOMBIECLASS_HUNTER] = CreateConVar("climb_everywhere_speed_hunter""0""Speed Applied For Hunters"FCVAR_ARCHIVE);    
    
l4d_climb_speed[ZOMBIECLASS_SMOKER] = CreateConVar("climb_everywhere_speed_smoker""0""Speed Applied For Smokers"FCVAR_ARCHIVE);    
    
l4d_climb_speed[ZOMBIECLASS_TANK] = CreateConVar("climb_everywhere_speed_tank""0""Speed Applied For Tanks"FCVAR_ARCHIVE);    
    
l4d_climb_speed[ZOMBIECLASS_BOOMER] = CreateConVar("climb_everywhere_speed_boomer""0""Speed Applied For Boomers"FCVAR_ARCHIVE);    
    
l4d_climb_speed[ZOMBIECLASS_JOCKEY] = CreateConVar("climb_everywhere_speed_jockey""0""Speed Applied For Jockeys"FCVAR_ARCHIVE);    
    
l4d_climb_speed[ZOMBIECLASS_SPITTER] = CreateConVar("climb_everywhere_speed_spitter""0""Speed Applied For Spitters"FCVAR_ARCHIVE);    
    
l4d_climb_speed[ZOMBIECLASS_CHARGER] = CreateConVar("climb_everywhere_speed_charger""0""Speed Applied For Chargers"FCVAR_ARCHIVE);
    
    
AutoExecConfig(true"climb_everywhere");
    
    
HookEvent("player_bot_replace"player_bot_replace);     
    
HookEvent("player_jump"player_jump);
    if(
L4D2Version)
    {
        
HookEvent("jockey_ride"events_to_interrupt);
        
HookEvent("charger_carry_start"events_to_interrupt);
        
HookEvent("charger_pummel_start"events_to_interrupt);
    }
    
HookEvent("tongue_grab"events_to_interrupt);
    
HookEvent("player_ledge_grab"events_to_interrupt);
    
HookEvent("lunge_pounce"events_to_interrupt);
    
HookEvent("player_incapacitated_start"events_to_interrupt);     
    
HookEvent("player_death"player_death);
    
HookEvent("player_spawn"player_spawn);
    
    
HookEvent("round_start"on_round_reset);
    
HookEvent("round_end"on_round_reset);
    
HookEvent("finale_win"on_round_reset);
    
HookEvent("mission_lost"on_round_reset);
    
HookEvent("map_transition"on_round_reset);    
    
    
RegConsoleCmd("sm_anim"GetAnimation);
    
    
ResetAllState();
}

Action GetAnimation(int clientany args)
{
    if(
IsValidClient(client) && IsPlayerAlive(client))
    {
        
int m GetEntProp(clientProp_Send"m_nSequence");    
        
PrintToChat(client"Current Animation: %d"m);
    }
    
    return 
Plugin_Handled;
}

Action on_round_reset(Handle event, const char[] namebool dontBroadcast)
{
    
ResetAllState();
}

void ResetAllState()
{
    for(
int i=1i<=MaxClientsi++)
    {
        
Stop(i);
        
ShowMsg[i] = 0;
    }
}

/*Action OnHeld(Handle event, const char[] name, bool dontBroadcast)
{ EventInterrupt(event, "victim"); }

Action OnPlayerLedgeGrab(Handle event, const char[] name, bool dontBroadcast)
{ EventInterrupt(event); }

Action OnPlayerIncapacitatedStart(Handle event, const char[] name, bool dontBroadcast)
{ EventInterrupt(event); }*/

Action events_to_interrupt(Handle event, const char[] namebool dontBroadcast)
{
    if (
StrEqual(name"jockey_ride"false) || StrEqual(name"charger_carry_start"false) ||
    
StrEqual(name"charger_pummel_start"false) || StrEqual(name"tongue_grab"false) ||
    
StrEqual(name"lunge_pounce"false))
    { 
EventInterrupt(event"victim"); }
    else
    { 
EventInterrupt(event); }
}

void EventInterrupt(Handle event, const char[] name "userid")
{
    if(
GetConVarInt(l4d_climb_enable) <= 0) return;
    
    
int victim GetClientOfUserId(GetEventInt(eventname)); 
    
Interrupt(victim);
}

Action player_bot_replace(Handle event, const char[] namebool dontBroadcast)
{
    if(
GetConVarInt(l4d_climb_enable) <= 0) return;
    
    
int client GetClientOfUserId(GetEventInt(event"player"));
    
int bot GetClientOfUserId(GetEventInt(event"bot")); 
    
Stop(client);
    
Stop(bot); 
}

Action player_jump(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
IsValidClient(client) || IsFakeClient(client)) return;
    
    
bool isGhost false;
    if(
IsInfected(client) && GetEntProp(clientProp_Send"m_isGhost"))
    { 
isGhost true; }
    
    if(!
CanUse(clientisGhost)) return;
    
    
SDKUnhook(clientSDKHook_PostThinkPostPreThink); 
    
SDKUnhook(clientSDKHook_SetTransmitOnSetTransmitClient);
    
    
State[client] = State_OnAir;
    
    
SDKHook(clientSDKHook_PostThinkPostPreThink);
    
    
float pos[3];
    
GetClientAbsOrigin(clientpos);
    
CopyVector(posSafePos[client]);
    
    
LastTime[client] = GetEngineTime();
    
JumpTime[client] = LastTime[client];
    
    return;
}

Action player_death(Handle event, const char[] namebool dontBroadcast)
{
    if(
GetConVarInt(l4d_climb_enable) <= 0) return;
    
    
int victim GetClientOfUserId(GetEventInt(event"userid")); 
    
Stop(victim); 
    
ShowMsg[victim] = 0;
}

Action player_spawn(Handle event, const char[] namebool dontBroadcast)
{
    if(
GetConVarInt(l4d_climb_enable) <= 0) return;
    
    
int victim GetClientOfUserId(GetEventInt(event"userid"));
    
ShowMsg[victim] = 0;
    
Stop(victim);
    
    if(
ShowMsg[victim] < GetConVarInt(l4d_climb_msg))
    {
        
ShowMsg[victim]++;
        if(
CanUse(victim))
        {
            
CreateTimer(1.0ShowInfovictim);
        }
    }
}

bool CanUse(int clientbool isGhost false)
{
     
int mode GetConVarInt(l4d_climb_enable);
    if(
mode <= 0) return false;
    
    if(
mode == && GameMode == 2) return false;
    
    if(
IsValidClient(client))
    {
        if(
IsPlayerAlive(client))
        {
            
int teammode GetConVarInt(l4d_climb_team);
            if (
IsSurvivor(client))
            {
                if(
teammode == || teammode == 2)
                { return 
true; }
                else
                { return 
false; }
            }
            else if (
IsInfected(client))
            {
                if(
teammode == || teammode == 3)
                {
                    
int c GetEntProp(clientProp_Send"m_zombieClass");
                    
int m GetConVarInt(l4d_climb_infected[c]);
                    if(
== 1)
                    { return 
true; }
                    else if(
== && !isGhost)
                    { return 
true; }
                    else
                    { return 
false; }
                }
                else
                { return 
false; }
            }
            return 
true;
        }
        return 
true;
    }
    else
    { return 
true; }
}

void Interrupt(int client)
{
    if(
State[client] == State_Climb)
    {
        
Jump(clientfalse50.0);
        
Stop(client);
    }
    else if(
State[client] == State_OnAir)
    {
        
Stop(client);
    }
}

void Stop(int client)
{
    if(
State[client] == State_None) return;
    
    
State[client] = State_None;
    if(
IsValidEntityAndNotWorld(Clone[client]))
    {
        
AcceptEntityInput(Clone[client], "kill");
        Clone[
client] = 0;
    }
    
    if(
IsValidClient(client))
    {
        
GotoFirstPerson(client);
        
VisiblePlayer(clienttrue);
        
        if (!
GetEntProp(clientProp_Send"m_isHangingFromLedge"))
        { 
SetEntityMoveType(clientMOVETYPE_WALK); }
        
        
SetEntProp(clientProp_Send"m_bDrawViewmodel"1);
    }
    
    
SDKUnhook(clientSDKHook_PostThinkPostPreThink);
    
SDKUnhook(clientSDKHook_SetTransmitOnSetTransmitClient);
}

void Start(int client)
{
    
float vAngles[3];
    
float vOrigin[3];
    
float hit[3];
    
float normal[3];
    
float up[3];
    
    
GetClientEyePosition(clientvOrigin);
    
GetClientEyeAngles(clientvAngles);     
    
    
GetRay(clientvOriginvAngleshitnormal0.0 gbodywidth); 
    if(
GetVectorDistance(hitvOrigin) < gbodywidth 2.0)
    {
        
SetVector(up0.00.01.0);
        
float f GetAngle(normalup) * 180 Pie;
        if(
10.0 || 170.0)
        { return; }
        
        
CopyVector(normalBodyNormal[client]); 
        
CopyVector(hitBodyPos[client]);
        
        
Angle[client] = 0.0;
        
CopyVector(normalBodyNormal[3]);
        
        
int clone = CreateClone(client);
        if(
IsValidEntity(clone))
        {
            Clone[
client] = clone; 
            
            
SetEntityMoveType(clientMOVETYPE_NONE);
            
            
GotoThirdPerson(client);
            
VisiblePlayer(clientfalse);
            
            
SDKUnhook(clientSDKHook_SetTransmitOnSetTransmitClient);
            
SDKHook(clientSDKHook_SetTransmitOnSetTransmitClient);
            
            
bool isGhost false;
            if(
IsInfected(client) && GetEntProp(clientProp_Send"m_isGhost"))
            {
                
isGhost true;
            }
            
            if (
isGhost)
            {
                
SDKUnhook(clone, SDKHook_SetTransmitOnSetTransmitClient); 
                
SDKHook(clone, SDKHook_SetTransmitOnSetTransmitClient);
            }
            
            
SDKUnhook(clientSDKHook_PostThinkPostPreThink); 
            
SDKHook(clientSDKHook_PostThinkPostPreThink);
            
            
SaveWeapon(client);
            
            
State[client] = State_Climb;
            
FirstRun[client] = true;
            
            
GlowIndicator[client] = false;
            
GlowTime[client] = 0.0;
        }
        else
        { 
PrintToChat(client"Unknown model!"); }
    }
}

void Jump(int clientbool check truefloat jump_speed JumpSpeed)
{
    
float time GetEngineTime(); 
    if(
check)
    {
        if(
time JumpTime[client] < 2.0)
        {
            
PrintCenterText(client"Too Quick To Jump!");
            return;
        }
    }
    
     if(Clone[
client] > 0)
    {
        
AcceptEntityInput(Clone[client], "kill");
        Clone[
client] = 0;
        if(
IsValidClient(client))
        { 
RestoreWeapon(client); }
    }
    
    
SDKUnhook(clientSDKHook_SetTransmitOnSetTransmitClient);
    
    if(!
IsValidClient(client)) return;
    
    
GotoFirstPerson(client);
    
VisiblePlayer(clienttrue);
    
    
SetEntityMoveType(clientMOVETYPE_WALK);
    
    
float vAngles[3];
    
float vOrigin[3];
    
float vec[3];
    
float pos[3];
    
    
GetClientEyePosition(clientvOrigin);
    
CopyVector(BodyNormal[client], vec);
    
NormalizeVector(vecvec);
    
ScaleVector(vecBodyWidth[client]);
    
AddVectors(vOriginvecpos);
    
    
GetClientEyeAngles(clientvAngles);
    
GetAngleVectors(vAnglesvecNULL_VECTORNULL_VECTOR);
    
NormalizeVector(vecvec);
    
ScaleVector(vecjump_speed);
    
TeleportEntity(clientposNULL_VECTORvec);
    
CopyVector(posLastPos[client]);
    
SetEntPropFloat(clientProp_Send"m_flFallVelocity"0.0);
    
    
JumpTime[client] = time;
    
StuckIndicator[client] = 0.0;
    
State[client] = State_OnAir;
}

Action OnSetTransmitClient(int climberint client)
{
    if(!
IsValidClient(climber) || !IsValidClient(client))
    { return 
Plugin_Handled; }
    
    if(
climber != client)
    {
        if(
IsSurvivor(climber))
        { return 
Plugin_Handled; }
        
        if(
IsSurvivor(client) || IsInfected(client))
        { return 
Plugin_Handled; }
        
        if(
GlowIndicator[climber])
        { return 
Plugin_Continue; }
        
        return 
Plugin_Handled;
    }
    else
    { return 
Plugin_Continue; }
}

void PreThink(int client)
{
    if(
IsValidClient(client) && IsPlayerAlive(client))
    {
        if (
IsValidEntityAndNotWorld(Clone[client]))
        {
            
SetEntPropFloat(Clone[client], Prop_Send"m_flPoseParameter"GetEntPropFloat(clientProp_Send"m_flPoseParameter"0), 0); // body_pitch
            
SetEntPropFloat(Clone[client], Prop_Send"m_flPoseParameter"GetEntPropFloat(clientProp_Send"m_flPoseParameter"1), 1); // body_yaw
        
}
        
// Modified lines taken from https://forums.alliedmods.net/showthread.php?t=299560 which in turn 
        // had the original line contributed by DeathChaos25
        
        
float time GetEngineTime();
        
float interval time LastTime[client]; 
        
Interval[client] = interval;
        
        if(
State[client] == State_OnAir)
        { 
OnAir(client); }
        else if(
State[client] == State_Climb)
        { 
Climb(clientinterval); }
        
        
LastTime[client] = time;
        
        if(
GetConVarInt(l4d_climb_glow) == 1)
        {
            
GlowTime[client] += interval;
            if(
GlowTime[client] > 4.0)
            {
                
GlowIndicator[client] = false;
                
GlowTime[client] = 0.0;  
            }
            else if(
GlowTime[client] > 3.5)
            { 
GlowIndicator[client] = true; }
        }
    }
    else
    { 
Stop(client); }
}

void OnAir(int client)
{
    
int flag GetEntityFlags(client);
    if(
flag FL_ONGROUND)
    {
        
Stop(client);
        return;
    }
    
    
int button GetClientButtons(client);
    if((!
GetEntProp(clientProp_Send"m_isGhost") && (button IN_USE)) || (GetEntProp(clientProp_Send"m_isGhost"1) && (button IN_DUCK)))
    { 
        
Start(client); 
    }
    
    
float time GetEngineTime();
    if(
time JumpTime[client] + 1.0)
    { return; }
    
    
float pos[3];
    
GetClientAbsOrigin(clientpos);
    
StuckIndicator[client] += GetVectorDistance(posLastPos[client]);
    
    
CopyVector(posLastPos[client]);
    if(
time JumpTime[client] + 0.5 && StuckIndicator[client] < 10.0)
    {
        
TeleportEntity(clientSafePos[client], NULL_VECTORNULL_VECTOR); 
        
PrintHintText(client"You were stuck!");
        
Stop(client);
    } 
}

void Climb(int clientfloat interval)
{
    
int clone = Clone[client];
    if(
IsValidEntityAndNotWorld(clone))
    {
        
SetEntProp(clientProp_Send"m_iAddonBits"0);
        
SetEntProp(clientProp_Send"m_bDrawViewmodel"0);
        
        
float colonPos[3];
        
float clientPos[3];
        
float bodyPos[3]; 
        
float headOffset[3]; 
        
float footOffset[3];
        
float bodyTouchPos[3];
        
float headTouchPos[3];
        
float footTouchPos[3];            
        
float moveDir[3];    
        
float cloneAnge[3];
        
float bodyNormal[3];
        
float eyeNormal[3];
        
float footNormal[3];
        
float normal[3];
        
float temp[3];
        
float up[3];
        
        
SetVector(up0.00.01.0); 
        
int button GetClientButtons(client);
        
SetEntityMoveType(clientMOVETYPE_NONE); 
        
        
float playrate 0.0;    
        
bool needprocess false;
        
bool moveforward;
        
bool moveback;
        
        if(
button IN_FORWARD)
        {
            
needprocess true
            
moveforward true;
        }
        else if(
button IN_BACK)
        {
            
needprocess true
            
moveback true;
        }
        
        if(
button IN_MOVELEFT)
        {
            
Angle[client] += interval 90.0;
            
playrate PlayBackRate[client] * 0.5;
            
needprocess true;
        }
        else if(
button IN_MOVERIGHT)
        {
            
Angle[client] -= interval 90.0;
            
playrate PlayBackRate[client] * 0.5;
            
needprocess true;
        }
        
        if(
button IN_JUMP || button IN_ATTACK || button IN_ATTACK2)
        {
            
Jump(client);
            return;
        }
 
        while(
needprocess || FirstRun[client])
        {
            
FirstRun[client] = false;
            
            
CopyVector(BodyPos[client], bodyPos);  
            
CopyVector(BodyNormal[client], normal);
            
CopyVector(normalcloneAnge);
            
            
ScaleVector(cloneAnge, -1.0);
            
GetVectorAngles(cloneAngecloneAnge);
            
            
cloneAnge[2] = 0.0 Angle[client]; 
            
            
float f GetAngle(BodyNormal[client], up) * 180 Pie;
            if(
10.0 || 170.0)
            {
                
Jump(clientfalse0.0);
                return;
            }
            
            
SetVector(headOffset0.00.01.0); 
            
GetProjection(normalupheadOffset);
            
            
RotateVector(normalheadOffsetAngleCovert(Angle[client]), headOffset); 
            
CopyVector(headOffsetfootOffset);
            
            
NormalizeVector(headOffsetheadOffset);
            
NormalizeVector(footOffsetfootOffset);
            
            
ScaleVector(footOffset0.0 bodylength 0.5);
            
ScaleVector(headOffsetbodylength 0.5);
            
            
AddVectors(bodyPosheadOffsetheadTouchPos);
            
AddVectors(bodyPosfootOffsetfootTouchPos);
            
            
bool b GetRaySimple(clientheadTouchPosfootTouchPostemp);
            if(
b)
            {
                break;
            }
            
            
CopyVector(footTouchPoscolonPos);
            
            
float disBody GetRay(clientbodyPoscloneAngebodyTouchPosbodyNormal0.0 BodyWidth[client]);  
            
float disHead GetRay(clientheadTouchPoscloneAngeheadTouchPoseyeNormal0.0 BodyWidth[client]);  
            
float disFoot GetRay(clientfootTouchPoscloneAngefootTouchPosfootNormal0.0 BodyWidth[client]);  
            if(
disBody BodyWidth[client] * 2.0)
            {
                
Jump(clientfalse50.0);                 
                return;
            }
            
            
bool needrotatenormal false;
            if(
disHead BodyWidth[client])
            {
                
disHead BodyWidth[client];
                
needrotatenormal true;
            }
            
            if(
disFoot BodyWidth[client])
            {
                
disFoot BodyWidth[client];
                
needrotatenormal true;
            }
            
            
float ft disHead disFoot;
            if(
needrotatenormal)
            {
                
ft ArcSine(ft/SquareRoot(ft ft bodylength 0.5 bodylength 0.5));
                
GetVectorCrossProduct(bodyNormalheadOffsettemp); 
                
RotateVector(tempnormalft 0.5normal); 
                
CopyVector(normalnormal);
            }
            else
            {
                
CopyVector(bodyNormalnormal);
            }
            
            
CopyVector(headOffset ,moveDir);
            
NormalizeVector(moveDirmoveDir); 
            
ScaleVector(moveDirClimbSpeed[client] * interval);  
            
            
CopyVector(bodyTouchPosbodyPos); 
            
            if(
moveforward)
            {
                
playrate=PlayBackRate[client]; 
                
AddVectors(colonPosmoveDircolonPos);
                
AddVectors(bodyPosmoveDirbodyPos);
            }
            else if(
moveback)
            {
                
playrate 0.0 PlayBackRate[client];
                
                
SubtractVectors(colonPosmoveDircolonPos);
                
SubtractVectors(bodyPosmoveDirbodyPos);
            }
            
            
CopyVector(bodyPosclientPos);
            
clientPos[2] -= bodylength 0.5;
            
            
TeleportEntity(clientclientPosNULL_VECTORNULL_VECTOR); 
            
TeleportEntity(clone, colonPoscloneAngeNULL_VECTOR);
            
            
CopyVector(bodyPosBodyPos[client]);  
            
CopyVector(normalBodyNormal[client]);
            
            break;
        }
        if (
IsValidEntityAndNotWorld(clone))
        
SetEntPropFloat(clone, Prop_Send"m_flPlaybackRate"playrate);
    }
    else
    {
        
Stop(client);
    }
}

void GetModelInfo(const char[] modelfloatspeedvaluefloatplaybackratefloatbodywidth)
{    
    
int speed 0;
    
float S 0.0;
    
bodywidth gbodywidth;
    if(
StrContains(model"survivor_teenangst") != -1)
    {
        
speed ZOMBIECLASS_SURVIVOR
        
30.0;
    }
    else if(
StrContains(model"survivor_manager") != -1)
    {
        
speed ZOMBIECLASS_SURVIVOR
        
30.0;
    }
    else if(
StrContains(model"survivor_namvet") != -1)
    {
        
speed ZOMBIECLASS_SURVIVOR
        
30.0;
    }
    else if(
StrContains(model"survivor_biker") != -1)
    {
        
speed ZOMBIECLASS_SURVIVOR;
        
30.0;
    }
    else if(
StrContains(model"gambler") != -1)
    {
        
speed ZOMBIECLASS_SURVIVOR;
        
30.0;
    }
     else if(
StrContains(model"producer") != -1)
    {
        
speed ZOMBIECLASS_SURVIVOR;
        
30.0;
    }
    else if(
StrContains(model"coach") != -1)
    {
        
speed ZOMBIECLASS_SURVIVOR;
        
30.0;
    }
     else if(
StrContains(model"mechanic") != -1)
    {
        
speed ZOMBIECLASS_SURVIVOR;
        
30.0;
    }
    else if(
StrContains(model"hulk") != -|| StrContains(model"fs_glowtank") != -1)
    {
        
speed ZOMBIECLASS_TANK
        if(
L4D2Version)
        { 
50.0; }
        else
        { 
70.0; }
    }
    else if(
StrContains(model"hunter") != -1)
    {
        
speed ZOMBIECLASS_HUNTER;
        
70.0;
    }
    else if(
StrContains(model"smoker") != -1)
    {
        
speed ZOMBIECLASS_SMOKER;
        
70.0;
        
bodywidth 25.0;
    }
    else if(
StrContains(model"boomette") != -1)
    {
        
speed ZOMBIECLASS_BOOMER;
        
50.0;
    }
    else if(
StrContains(model"boomer") != -1
    {
        
speed ZOMBIECLASS_BOOMER
        
60.0;
    }
     else if(
StrContains(model"jockey") != -1)
    {
        
speed ZOMBIECLASS_JOCKEY;
        
60.0;
    }
    else if(
StrContains(model"spitter") != -1)
    {
        
speed ZOMBIECLASS_SPITTER;
        
70.0;
    }
    else if(
StrContains(model"charger") != -1)
    {
        
speed ZOMBIECLASS_CHARGER;
        
70.0;
        
bodywidth 25.0;
    }
    
    
speedvalue GetConVarFloat(l4d_climb_speed[speed]) * GetConVarFloat(l4d_climb_speed[0]);
    
playbackrate 1.0 + (speedvalue S) / S;
}

int CreateClone(int client)
{
    
float vAngles[3];
    
float vOrigin[3];
    
GetClientAbsOrigin(clientvOrigin);
    
GetClientEyeAngles(clientvAngles);
    
    
char playerModel[42]; 
    
GetEntPropString(clientProp_Data"m_ModelName"playerModelsizeof(playerModel));
    if (!
IsModelPrecached(playerModel))
    { 
PrecacheModel(playerModel); }
    
    
GetModelInfo(playerModelClimbSpeed[client], PlayBackRate[client], BodyWidth[client]);
    
int clone = 0;
    if (
IsSurvivor(client))
    {
        clone = 
CreateEntityByName("commentary_dummy");
    }
    else
    { clone = 
CreateEntityByName("prop_dynamic_override"); }
    if(
IsValidEntity(clone))
    {
        
SetEntityModel(clone, playerModel);
        
        
float vPos[3]; float vAng[3];
        
vPos[0] = -0.0
        
vPos[1] = -0.0;
        
vPos[2] = -30.0;
        
        
vAng[2] = -90.0;
        
vAng[0] = -90.0;
        
vAng[1] = 0.0;
        
        
TeleportEntity(clone,  vOriginvAnglesNULL_VECTOR);
        
        
DispatchKeyValue(clone, "solid""0");
        if (
IsSurvivor(client))
        { 
SetEntProp(clone, Prop_Send"m_bClientSideAnimation"1); }
        
DispatchSpawn(clone);
        
ActivateEntity(clone);
        
        
SetVariantString(ACT_CLIMB_UP);
        
AcceptEntityInput(clone, "SetDefaultAnimation");
        
SetVariantString(ACT_CLIMB_UP);
        
AcceptEntityInput(clone, "SetAnimation");
        
        
SetEntPropFloat(clone, Prop_Send"m_flPlaybackRate"1.0);
        
SetEntPropFloat(clone, Prop_Send"m_fadeMinDist"10000.0); 
        
SetEntPropFloat(clone, Prop_Send"m_fadeMaxDist"20000.0); 
        
        if(
L4D2Version && IsSurvivor(client))
        {
            
SetEntProp(clone, Prop_Send"m_iGlowType"3);
            
SetEntProp(clone, Prop_Send"m_nGlowRange"0);
            
SetEntProp(clone, Prop_Send"m_nGlowRangeMin"600);
            
            
int red 0;
            
int gree 151;
            
int blue 0;
            
            
SetEntProp(clone, Prop_Send"m_glowColorOverride"red + (gree 256) + (blue 65536)); 
        }
    }
    return clone;
}

void SaveWeapon(int client)

    
client client 1;
}

void RestoreWeapon(int client)

    
client client 1;
}

bool IsInfected(int client)
{
    if (!
IsValidClient(client)) return false;
    if (
GetClientTeam(client) == 3) return true;
    return 
false;
}

bool IsSurvivor(int client)
{
    if (!
IsValidClient(client)) return false;
    if (
GetClientTeam(client) == || (L4D2Version && GetClientTeam(client) == 4)) return true;
    return 
false;
}

bool IsValidClient(int clientbool replaycheck true)
{
    
//if (!IsValidEntity(client)) return false;
    
if (client <= || client MaxClients) return false;
    if (!
IsClientInGame(client)) return false;
    
//if (GetEntProp(client, Prop_Send, "m_bIsCoaching")) return false;
    
if (replaycheck)
    {
        if (
IsClientSourceTV(client) || IsClientReplay(client)) return false;
    }
    return 
true;
}

void VisiblePlayer(int clientbool visible true)
{
    if(
visible)
    {
        
SetEntityRenderMode(clientRENDER_NORMAL);
        
SetEntityRenderColor(client255255255255);         
    }
    else
    {
        
SetEntityRenderMode(clientRENDER_TRANSCOLOR);
        
SetEntityRenderColor(client0000);
    } 
}

float RayVec[3];

bool GetRaySimple(int clientfloat pos1[3], float pos2[3], float hitpos[3])
{
    
Handle trace;
    
bool hit false;  
    
trace TR_TraceRayFilterEx(pos1pos2MASK_SOLIDRayType_EndPointDontHitCloneAndOxygenTankclient); 
    if(
TR_DidHit(trace))
    {
        
TR_GetEndPosition(hitpostrace); 
        
hit true;
    }
    
CloseHandle(trace); 
    return 
hit;
}

float GetRay(int clientfloat pos[3], float angle[3], float hitpos[3], float normal[3], float offset 0.0)
{
    
Handle trace;
    
float ret 9999.0;
    
trace TR_TraceRayFilterEx(posangleMASK_SOLIDRayType_InfiniteTraceRayDontHitSelfAndCloneclient); 
    if(
TR_DidHit(trace))
    {            
        
CopyVector(posRayVec);
        
TR_GetEndPosition(hitpostrace);
        
TR_GetPlaneNormal(tracenormal);
        
NormalizeVector(normalnormal); 
        if(
offset != 0.0)
        {
            
float t[3];
            
GetAngleVectors(angletNULL_VECTORNULL_VECTOR);
            
NormalizeVector(tt);
            
ScaleVector(toffset);
            
AddVectors(hitposthitpos); 
        }
        
ret GetVectorDistance(RayVechitpos);
    }
    
CloseHandle(trace); 
    return 
ret;
}

void CopyVector(float source[3], float target[3])
{
    
target[0] = source[0];
    
target[1] = source[1];
    
target[2] = source[2];
}

void SetVector(float target[3], float xfloat yfloat z)
{
    
target[0] = x;
    
target[1] = y;
    
target[2] = z;
}

/*bool DontHitSelf(int entity, int mask, any data)
{
    if(entity == data) 
    {
        return false; 
    }
    return true;
}*/

float AngleCovert(float angle)
{
    return 
angle 180.0 Pie;
}

float GetAngle(float x1[3], float x2[3])
{
    return 
ArcCosine(GetVectorDotProduct(x1x2) / (GetVectorLength(x1) * GetVectorLength(x2)));
}

void GetProjection(float n[3], float t[3], float r[3])
{
    
float A n[0];
    
float B n[1];
    
float C n[2];
    
    
float a t[0];
    
float b t[1];
    
float c t[2];
    
    
float p = -1.0 * (c) / (C);
    
r[0] = a;
    
r[1] = b;
    
r[2] = c;
}

void RotateVector(float direction[3], float vec[3], float alfafloat result[3])
{
       
float v[3];
    
CopyVector(vecv);
    
    
float u[3];
    
CopyVector(directionu);
    
NormalizeVector(uu);
    
    
float uv[3];
    
GetVectorCrossProduct(uvuv);
    
    
float sinuv[3];
    
CopyVector(uvsinuv);
    
ScaleVector(sinuvSine(alfa));
    
    
float uuv[3];
    
GetVectorCrossProduct(uuvuuv);
    
ScaleVector(uuv2.0 Pow(Sine(alfa 0.5), 2.0));    
    
    
AddVectors(vsinuvresult);
    
AddVectors(resultuuvresult);
}

void GameCheck()
{
    
char GameName[16];
    
GetConVarString(FindConVar("mp_gamemode"), GameNamesizeof(GameName));
    if (
StrEqual(GameName"survival"false))
    {
        
GameMode 3;
    }
    else if (
StrEqual(GameName"versus"false) || StrEqual(GameName"teamversus"false) || StrEqual(GameName"scavenge"false) || StrEqual(GameName"teamscavenge"false))
    {
        
GameMode 2;
    }
    else if (
StrEqual(GameName"coop"false) || StrEqual(GameName"realism"false))
    {
        
GameMode 1;
    }
    else
    {
        
GameMode 0;
     }
    
    
GetGameFolderName(GameNamesizeof(GameName));
    if (
StrEqual(GameName"left4dead2"false))
    {
        
ZOMBIECLASS_TANK 8;
        
L4D2Version true;
    }    
    else
    {
        
ZOMBIECLASS_TANK 5;
        
L4D2Version false;
    }
}
 
bool TraceRayDontHitSelfAndClone(int entityint maskany data)
{
    if(
entity == data
    {
        return 
false
    }
    else if(
data >= && data <= MaxClients)
    {
        if(
entity == Clone[data])
        {
            return 
false
        }
    }
    
    return 
true;
}

char g_classname[64];

bool DontHitCloneAndOxygenTank(int entityint maskany data)
{
    if(
entity == data
    {
        return 
false
    }
    else if(
data >= && data <= MaxClients)
    {
        if(
entity == Clone[data])
        {
            return 
false
        }
    }
    
    if(
IsValidEdict(entity))
    {
        
GetEdictClassname(entityg_classnamesizeof(g_classname));
        if(
StrEqual(g_classname"prop_physics"))
        {
            
GetEntPropString(entityProp_Data"m_ModelName"g_classnamesizeof(g_classname));            
            if(
StrEqual(g_classname"models/props_equipment/oxygentank01.mdl"))
            {
                return 
false;
            }
        }
    }
    
    return 
true;
}

Action ShowInfo(Handle timerint client)
{
    if (!
IsValidClient(client)) return Plugin_Handled;
    if(
L4D2Version)
    { 
DisplayHint(client); }
    else
    { 
PrintToChat(client"\x03Press \x04E \x0To \x04Climb \x03On A Surface!"); }
    
    return 
Plugin_Stop;
}

Action DisplayHint(int client)
{
    
ClientCommand(client"gameinstructor_enable 1");
    
    
CreateTimer(1.0DelayDisplayHintclient);
    
    return 
Plugin_Stop;
}

Action DelayDisplayHint(Handle timerint client)
{
    
DisplayInstructorHint(client"while jumping toward a wall to climb!""+use");
    return 
Plugin_Stop;
}

void DisplayInstructorHint(int clientchar s_Message[256], char[] s_Bind)
{
    
char s_TargetName[32];
    
    
int hint CreateEntityByName("env_instructor_hint");
    
FormatEx(s_TargetNamesizeof(s_TargetName), "hint%d"client);
    
ReplaceString(s_Messagesizeof(s_Message), "\n"" ");
    if (
IsValidClient(client))
    { 
DispatchKeyValue(client"targetname"s_TargetName); }
    
DispatchKeyValue(hint"hint_target"s_TargetName);
    
DispatchKeyValue(hint"hint_timeout""5");
    
DispatchKeyValue(hint"hint_range""0.01");
    
DispatchKeyValue(hint"hint_color""255 255 255");
    
DispatchKeyValue(hint"hint_icon_onscreen""use_binding");
    
DispatchKeyValue(hint"hint_caption"s_Message);
    
DispatchKeyValue(hint"hint_binding"s_Bind);
    
DispatchSpawn(hint);
    
AcceptEntityInput(hint"ShowHint");
    
    
Handle pack CreateDataPack();
    
WritePackCell(packclient);
    
WritePackCell(packhint);
    
CreateTimer(5.0RemoveInstructorHintpack);
}
    
Action RemoveInstructorHint(Handle timerDataPack pack)
{
    
ResetPack(packfalse);
    
int client ReadPackCell(pack);
    
int hint ReadPackCell(pack);
    if (
pack != null)
    { 
CloseHandle(pack); }
    
    if (!
client || !IsValidClient(client))
    { return 
Plugin_Stop; }
    
    if (
IsValidEntity(hint))
    { 
AcceptEntityInput(hint"kill"); }
    
    
ClientCommand(client"gameinstructor_enable 0");
    
    
DispatchKeyValue(client"targetname""");
    
    return 
Plugin_Stop;
}

bool IsValidEntityAndNotWorld(int entity)
{
    if (!
IsValidEntity(entity)) return false;
    if (
entity <= 0) return false;
    return 
true;
}

void GotoThirdPerson(int client)
{
    
SetEntPropEnt(clientProp_Send"m_hObserverTarget"0);
    
SetEntProp(clientProp_Send"m_iObserverMode"1);
    
SetEntProp(clientProp_Send"m_bDrawViewmodel"0);
}

void GotoFirstPerson(int client)
{
    
SetEntPropEnt(clientProp_Send"m_hObserverTarget", -1);
    
SetEntProp(clientProp_Send"m_iObserverMode"0);
    
SetEntProp(clientProp_Send"m_bDrawViewmodel"1);


Last edited by ricksfishin; 10-01-2021 at 21:55.
ricksfishin is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 10-02-2021 , 00:19   Re: Make admin only please
Reply With Quote #2

You just need a small edit to some code that exists in OnPluginStart()

RegConsoleCmd means anyone can use the command.
RegAdminCmd means that only people with a certain flag can use the command.

Here's a link to a good reference: https://sm.alliedmods.net/new-api/console/RegAdminCmd

Change this:
PHP Code:
RegConsoleCmd("sm_anim"GetAnimation); 
To this:
PHP Code:
RegAdminCmd("sm_anim"GetAnimationADMFLAG_SLAY"Makes Player Climb On Surfaces"); 
PC Gamer is offline
ricksfishin
Senior Member
Join Date: Oct 2017
Old 10-02-2021 , 10:58   Re: Make admin only please
Reply With Quote #3

Sorry as non admin can still climb
thanks
ricksfishin is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 10-02-2021 , 13:28   Re: Make admin only please
Reply With Quote #4

Oh. I thought you just wanted to limit the command to Admins only.

Limiting the climbing to Admins only should also be easy. Just follow the instructions you were given in this post:
https://forums.alliedmods.net/showthread.php?t=307068
PC Gamer is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode