[NEED FIX] Can't remove hooks...

Hello , when i attempt to remove hooks , i’ve got : :


 [lua\includes\modules\hook.lua:58] attempt to index field '?' (a nil value)

I want to turn on/off the parachute…

Code :
[lua]
local function ParachuteKey(ply, key)
if key == IN_JUMP and ply:IsValid() and ply:Alive() then
if ply:GetMoveType() == MOVETYPE_NOCLIP or ply:InVehicle() or ply:OnGround() or ply.Parachuting == true or ply:GetVelocity().z > -600 then return end
ply.EndParaTime = nil
ply.Parachuting = true
umsg.Start(“PARAIsIn”,ply)
umsg.Bool(ply.Parachuting)
umsg.End()
ply.FlarePara = 1
ply:ViewPunch(Angle(35,0,0))
ply:EmitSound(“ambient/fire/mtov_flame2.wav”,100,90)
local Para = ents.Create(“parachute_decor”)
Para:SetOwner(ply)
Para:SetPos(ply:GetPos() + ply:GetUp()*100 + ply:GetForward()*10)
Para:SetAngles(ply:GetAngles())
Para:Spawn()
end
end
hook.Add( “KeyPress”, “ParachuteKey”, ParachuteKey )
concommand.Add(“Para_on”, ParachuteKey)

local function ParachuteThink()
for k,v in pairs (player.GetAll()) do
if v.Parachuting == true then
if not v:Alive() then
v.EndParaTime = nil
v.Parachuting = false
umsg.Start(“PARAIsIn”,v)
umsg.Bool(v.Parachuting)
umsg.End()
v.FlarePara = 1
v:ViewPunch(Angle(-18.5,0,0))
v:EmitSound(“npc/combine_soldier/zipline_clip2.wav”)
local ParaAB = ents.Create(“parachute_abandon”)
ParaAB:SetOwner(v)
ParaAB:SetPos(v:GetPos() + v:GetUp()100 + v:GetForward()10)
ParaAB:SetAngles(v:GetAngles())
ParaAB:Spawn()
end
if v.EndParaTime and CurTime() >= v.EndParaTime and v:OnGround() then
v.EndParaTime = nil
v.Parachuting = false
umsg.Start(“PARAIsIn”,v)
umsg.Bool(v.Parachuting)
umsg.End()
v.FlarePara = 1
v:ViewPunch(Angle(-16,0,0))
v:EmitSound(“npc/combine_soldier/zipline_clip2.wav”)
local ParaAB = ents.Create(“parachute_abandon”)
ParaAB:SetOwner(v)
ParaAB:SetPos(v:GetPos() + v:GetUp()115 + v:GetForward()10)
ParaAB:SetAngles(v:GetAngles())
ParaAB:Spawn()
end
if v:KeyDown(IN_USE) and v.FlarePara > 0.4 then
v.FlarePara = v.FlarePara - 0.005
if v.FlarePara < 0.4 then v.FlarePara = 0.4 end
end
if v:KeyDown(IN_FORWARD) then
v:SetLocalVelocity(v:GetForward()240v.FlarePara
1.1 - v:GetUp()320v.FlarePara)
elseif v:KeyDown(IN_MOVELEFT) then
v:SetLocalVelocity(v:GetRight()
-215
v.FlarePara
1.1 - v:GetUp()320v.FlarePara)
elseif v:KeyDown(IN_MOVERIGHT) then
v:SetLocalVelocity(v:GetRight()215v.FlarePara1.1 - v:GetUp()320v.FlarePara)
elseif v:KeyDown(IN_BACK) then
v:SetLocalVelocity(v:GetForward()
-240v.FlarePara1.1 - v:GetUp()320v.FlarePara)
else
v:SetLocalVelocity(v:GetUp()-320v.FlarePara)
end
if ( v:KeyDown(IN_DUCK) and v:KeyDown(IN_WALK) or v:WaterLevel() > 0 ) and v.Parachuting == true then
v.Parachuting = false
umsg.Start(“PARAIsIn”,v)
umsg.Bool(v.Parachuting)
umsg.End()
v.FlarePara = 1
v:ViewPunch(Angle(-15,0,0))
v:EmitSound(“npc/combine_soldier/zipline_clip1.wav”)
local ParaAB = ents.Create(“parachute_abandon”)
ParaAB:SetOwner(v)
ParaAB:SetPos(v:GetPos() + v:GetUp()*115 + v:GetForward()*10)
ParaAB:SetAngles(v:GetAngles())
ParaAB:Spawn()
end
if v:OnGround() and v.Parachuting == true and not v.EndParaTime then
v.EndParaTime = CurTime() + 1
umsg.Start(“PARAIsIn”,v)
umsg.Bool(false)
umsg.End()
v:ViewPunch(Angle(7,0,0))
end
end
end
end
hook.Add(“Think”,“ParachuteThink”,ParachuteThink)
concommand.Add(“Para_on”, ParachuteThink)

local function ParaDisable()
hook.Remove(“KeyPress”, “ParachuteKey”)
end
concommand.Add(“Para_off”, ParaDisable)

local function ParaDisable()
hook.Remove(“Think”,“ParachuteThink”)
end
concommand.Add(“Para_off”, ParaDisable)
[/lua]

Thanks :slight_smile:

Line 58 has a nil value.
Yet line 58 is only end.
This is to messy for me to figure out sorry.

Use Lua tags, please.

[lua]
local function ParachuteKey(ply, key)
if key == IN_JUMP and ply:IsValid() and ply:Alive() then
if ply:GetMoveType() == MOVETYPE_NOCLIP or ply:InVehicle() or ply:OnGround() or ply.Parachuting == true or ply:GetVelocity().z > -600 then return end
ply.EndParaTime = nil
ply.Parachuting = true
umsg.Start(“PARAIsIn”,ply)
umsg.Bool(ply.Parachuting)
umsg.End()
ply.FlarePara = 1
ply:ViewPunch(Angle(35,0,0))
ply:EmitSound(“ambient/fire/mtov_flame2.wav”,100,90)
local Para = ents.Create(“parachute_decor”)
Para:SetOwner(ply)
Para:SetPos(ply:GetPos() + ply:GetUp()*100 + ply:GetForward()*10)
Para:SetAngles(ply:GetAngles())
Para:Spawn()
end
end
hook.Add( “KeyPress”, “ParachuteKey”, ParachuteKey )
concommand.Add(“Para_on”, ParachuteKey)

local function ParachuteThink()
for k,v in pairs (player.GetAll()) do
if v.Parachuting == true then
if not v:Alive() then
v.EndParaTime = nil
v.Parachuting = false
umsg.Start(“PARAIsIn”,v)
umsg.Bool(v.Parachuting)
umsg.End()
v.FlarePara = 1
v:ViewPunch(Angle(-18.5,0,0))
v:EmitSound(“npc/combine_soldier/zipline_clip2.wav”)
local ParaAB = ents.Create(“parachute_abandon”)
ParaAB:SetOwner(v)
ParaAB:SetPos(v:GetPos() + v:GetUp()100 + v:GetForward()10)
ParaAB:SetAngles(v:GetAngles())
ParaAB:Spawn()
end
if v.EndParaTime and CurTime() >= v.EndParaTime and v:OnGround() then
v.EndParaTime = nil
v.Parachuting = false
umsg.Start(“PARAIsIn”,v)
umsg.Bool(v.Parachuting)
umsg.End()
v.FlarePara = 1
v:ViewPunch(Angle(-16,0,0))
v:EmitSound(“npc/combine_soldier/zipline_clip2.wav”)
local ParaAB = ents.Create(“parachute_abandon”)
ParaAB:SetOwner(v)
ParaAB:SetPos(v:GetPos() + v:GetUp()115 + v:GetForward()10)
ParaAB:SetAngles(v:GetAngles())
ParaAB:Spawn()
end
if v:KeyDown(IN_USE) and v.FlarePara > 0.4 then
v.FlarePara = v.FlarePara - 0.005
if v.FlarePara < 0.4 then v.FlarePara = 0.4 end
end
if v:KeyDown(IN_FORWARD) then
v:SetLocalVelocity(v:GetForward()240v.FlarePara
1.1 - v:GetUp()320v.FlarePara)
elseif v:KeyDown(IN_MOVELEFT) then
v:SetLocalVelocity(v:GetRight()
-215
v.FlarePara
1.1 - v:GetUp()320v.FlarePara)
elseif v:KeyDown(IN_MOVERIGHT) then
v:SetLocalVelocity(v:GetRight()215v.FlarePara1. 1 - v:GetUp()320v.FlarePara)
elseif v:KeyDown(IN_BACK) then
v:SetLocalVelocity(v:GetForward()
-240v.FlarePara1.1 - v:GetUp()320v.FlarePara)
else
v:SetLocalVelocity(v:GetUp()-320v.FlarePara)
end
if ( v:KeyDown(IN_DUCK) and v:KeyDown(IN_WALK) or v:WaterLevel() > 0 ) and v.Parachuting == true then
v.Parachuting = false
umsg.Start(“PARAIsIn”,v)
umsg.Bool(v.Parachuting)
umsg.End()
v.FlarePara = 1
v:ViewPunch(Angle(-15,0,0))
v:EmitSound(“npc/combine_soldier/zipline_clip1.wav”)
local ParaAB = ents.Create(“parachute_abandon”)
ParaAB:SetOwner(v)
ParaAB:SetPos(v:GetPos() + v:GetUp()*115 + v:GetForward()*10)
ParaAB:SetAngles(v:GetAngles())
ParaAB:Spawn()
end
if v:OnGround() and v.Parachuting == true and not v.EndParaTime then
v.EndParaTime = CurTime() + 1
umsg.Start(“PARAIsIn”,v)
umsg.Bool(false)
umsg.End()
v:ViewPunch(Angle(7,0,0))
end
end
end
end
hook.Add(“Think”,“ParachuteThink”,ParachuteThink)
concommand.Add(“Para_on”, ParachuteThink)

local function ParaDisable()
hook.Remove(“KeyPress”, “ParachuteKey”)
end
concommand.Add(“Para_off”, ParaDisable)

local function ParaDisable()
hook.Remove(“Think”,“ParachuteThink”)
end
concommand.Add(“Para_off”, ParaDisable)
[/lua]