Help fixing a rappel addon

My friend has a rappel that’s broken because it hasn’t been updated for 4 years. From what I understand it was created by someone on here who has since then left. Anyways, I was able to fix 1 of the easy errors, but I don’t really understand what is wrong with it now.

I would appreciate help with fixing it along with the reason why the fix works if possible.



[ERROR] addons/rappel/lua/autorun/rappel.lua:50: Tried to use a NULL entity!
  1. EyeAngles - [C]:-1
   2. Function - addons/rappel/lua/autorun/rappel.lua:50
    3. unknown - lua/includes/modules/usermessage.lua:87


[LUA]
– This addon was created by Zoey Artyom, If you have any decency, please do not reupload this file and call it your own.

AddCSLuaFile(“Rappel.lua”)

if CLIENT then

function RappelHelpCross()
local Yourself = LocalPlayer()
local Trace1 = util.QuickTrace( Yourself:GetShootPos(), Yourself:GetAimVector() * 500, { Yourself } )
local Trace2 = util.QuickTrace( Trace1.HitPos + Vector(0,0,15), Yourself:GetForward()*20, { Yourself } )
if Yourself.RappelCross then
if Trace1 and Trace2 and Trace1.Hit and not Trace2.Hit and Yourself:EyeAngles().p <= -60 and (not Trace1.HitSky and not Trace1.Entity:IsPlayer() and not Trace1.Entity:IsNPC()) then
surface.SetDrawColor( 0, 200, 0, 200 )
else
surface.SetDrawColor( 200, 0, 0, 200 )
end
surface.SetTexture( surface.GetTextureID( “sprites/hud/v_crosshair2” ) )
surface.DrawTexturedRect( ScrW()*0.49, ScrH()*0.4825, ScreenScale(13) , ScreenScale(13))
end
end
hook.Add(“HUDPaint”,“RappelHelpCrossHK”,RappelHelpCross)

function RappelHolsterBinds( ply, bind, pressed )
if not pressed then return false end
if ply:Alive() then
if (bind == “+attack”) and ply.Climbing then
return true end
if (bind == “+attack2”) and ply.Climbing then
return true end
if (bind == “+reload”) and ply.Climbing then
return true end
end
end
hook.Add( “PlayerBindPress”, “RappelHolsterBinds”, RappelHolsterBinds )

local function RappelClimb( um )
local Yourself = LocalPlayer()
Yourself.Climbing = um:ReadBool()
end
usermessage.Hook( “RappelClimb”, RappelClimb )

local function HookHelp( um )
local Yourself = LocalPlayer()
Yourself.RappelCross = um:ReadBool()
end
usermessage.Hook( “HookHelp”, HookHelp )

local function RappelStart( um )
local Yourself = LocalPlayer()
Yourself.LimitAngle2 = Yourself:EyeAngles().y – Line 50
Yourself.Rappeling = um:ReadBool()
end
usermessage.Hook( “RappelStart”, RappelStart )

local function RappelNewAngle( um )
local Yourself = LocalPlayer()
Yourself.LimitAngle2 = Yourself:EyeAngles().y
end
usermessage.Hook( “RappelNewAngle”, RappelNewAngle )

function LimitRappelAngle(UCMD)
local Yourself = LocalPlayer()
local Weapon = Yourself:GetActiveWeapon()
if Yourself.Rappeling == true and Yourself:GetMoveType() == MOVETYPE_WALK then
local ang = UCMD:GetViewAngles()
if math.AngleDifference(Yourself.LimitAngle2,Yourself:EyeAngles().y) >= 60 then
ang.y = Yourself.LimitAngle2 - 60
UCMD:SetViewAngles(ang)
end
if math.AngleDifference(Yourself.LimitAngle2,Yourself:EyeAngles().y) <= -60 then
ang.y = Yourself.LimitAngle2 + 60
UCMD:SetViewAngles(ang)
end
end
end
hook.Add(“CreateMove”, “LimitRappelAngleHook”, LimitRappelAngle)

end

hook.Add(“Move”, “RappelSlow”, function(pl, move)
if pl.Rappeling == true then
if move:GetForwardSpeed() > 0 then
if move:GetForwardSpeed() > -pl:GetMaxSpeed() * -0 then
move:SetForwardSpeed(-pl:GetMaxSpeed() * -0)
end
end
if move:GetForwardSpeed() < 0 then
if move:GetForwardSpeed() < -pl:GetMaxSpeed() * 0 then
move:SetForwardSpeed(-pl:GetMaxSpeed() * 0)
end
end
if move:GetSideSpeed() > 0 then
if move:GetSideSpeed() > -pl:GetMaxSpeed() * -0 then
move:SetSideSpeed(-pl:GetMaxSpeed() * -0)
end
end
if move:GetSideSpeed() < 0 then
if move:GetSideSpeed() < -pl:GetMaxSpeed() * 0 then
move:SetSideSpeed(-pl:GetMaxSpeed() * 0)
end
end
end
end)
[/LUA]

This is an old ass addon. Instead of user messages you need to use networking and a whole lot of other shit. Would take a lot more work than fixing just a couple errors

UserMessages are still functional.

Make sure LocalPlayer() is valid; it must be getting called to quickly.

Ahh sorry. I was told a while ago that it was deprecated to the point where it was no longer properly functional. My apologies

Here, I fixed up your code a little bit: http://pastebin.com/Wcq4r0pd