Hook Problem.

What is wrong with this? Whenever this code exists nothing in the script works. No errors to help :confused:



hook.Add("Think","ThisIsAGroundCheck",
function(ply)
    for k, v in pairs(player.GetAll()) do
        if (v.ChuteOpen == true)
            if (v.chuteragdoll:OnGround() == true) then
                chute_make_Normal(v)
            end
        end
    end
end)


what the hell
this is a super messy code, what are you trying to do with this code ?

[editline]09:25PM[/editline]

Here try this
[lua]local ply = LocalPlayer()
function GroundCheck(ply)
for k, v in pairs(player.GetAll()) do
if (v.ChuteOpen == true) then
–your then should be here
–[[ if (v.chuteragdoll:OnGround() == true) then || after you put the then
(the one on the non commented line above) i think you can just do an else here ]]–
else
chute_make_Normal(v)
end
end

hook.Add( “Think”, “ThisIsAGroundCheck”, GroundCheck )[/lua]

sorry if i messed some things up I’m still a newb :3

also please use the tab button instead of spaces
and you definitely don’t need an end for every line of your code

Well I GUESS I could go about that way… I was trying to mimic this:
[lua]
hook.Add(“Think”,“Addforcetoragdoll”,
function()
for k, v in pairs(player.GetAll()) do
if v.chuteragdoll then
if v:KeyDown( 8 ) then
local angle=v:EyeAngles():Forward( )
local phys=v.chuteragdoll:GetPhysicsObject()
phys:ApplyForceCenter(Vector(angle.x,angle.y,0)800)
end
if v:KeyDown( 16 ) then
local angle=v:EyeAngles():Forward( )
local phys=v.chuteragdoll:GetPhysicsObject()
phys:ApplyForceCenter(Vector(angle.x,angle.y,0)
-800)
end
end
end
end)
[/lua]

not too experienced with hooks… as you can probably see. And its not messy at all. only possible way to clean that up is combine the 2 If statements
(v.ChuteOpen == true)
and
(v.chuteragdoll:OnGround() == true)

And the only reason I didn’t was because I forgot what to use to combine them. Its something like & i think. I dont remember.

[editline]07:34PM[/editline]

Dammit… even yours isn’t working!

there was a fill in the blank part on mine (line 5)

I know. but its not that its not doing what I want it to… its that the script isn’t being compiled (an error that I cant seem to find)
Doing This, the script runs fine:
[lua]
function GroundCheck()
for k, v in pairs(player.GetAll()) do
–[[if (v.ChuteOpen == true)
if (v.chuteragdoll:OnGround() == true) then
chute_make_Normal(v)
end
end ]]–
end
end
hook.Add(“Think”,“ThisIsAGroundCheck”, GroundCheck)
[/lua]
Doing This, The script has no error shown, but does not compile:
[lua] function GroundCheck()
for k, v in pairs(player.GetAll()) do
if (v.ChuteOpen == true)
if (v.chuteragdoll:OnGround() == true) then
chute_make_Normal(v)
end
end
end
end
hook.Add(“Think”,“ThisIsAGroundCheck”, GroundCheck)
[/lua]
What the hell?

FP and their goddamn Edit functions screwing up [ lua] tags…

Well i would wait for someone who is more experienced with lua to give their input, i can’t help you with much at this point : /

Meh. fuck it. Ill just force the players to press a key instead of automatically spawning when they hit the ground.

Why not just do if ply:OnGround()?

[editline]11:55PM[/editline]

What exactly are you wanting to do?

[lua]
function GroundCheck()
for k, v in pairs(player.GetAll()) do
if (v.ChuteOpen == true) then – you were missing this then :stuck_out_tongue: you can also make these two if’s one by using and but you can do that yourself
if (v.chuteragdoll:OnGround() == true) then
chute_make_Normal(v)
end
end
end
end
hook.Add(“Think”,“ThisIsAGroundCheck”, GroundCheck)
[/lua]

You would have known this if you checked the server console for errors.

Edit:

Because he isnt checking if the player is on the ground, he is checking if theyre ragdoll created by the parachute is.

In your if statements you don’t need to check for equality with true (== true). In an if statement everything but nil and false is already equated to true so you are actually checking if true == true (which is pointless)

[lua]local a = true
if a == true then – this is like doing if true == true then

end

if a then – This is better

end[/lua]

Oh and Newbrict, you wrote your function for client side when i believe its supposed to be serverside.

completely forgot to check this thread.
Because its not a player first of all… and when I did that with a ragdoll, it did not work.