I started work on a gamemode last year, then stopped working on it. I started back working on it again now, but one of the main functions that the gamemode needs to work isn't working anymore. It seems the hook OnPlayerHitGround isn't working. I won't post my code for it, since my code isn't the problem no matter what I put within the function. Anyone have an idea of what's going on here?
It doesn't work in the current gmod, garry already fixed it in the beta though.
Thanks for the response Jvs. Is there an alternative method I could use in the mean time?
[QUOTE=DreBly;35012975]Thanks for the response Jvs. Is there an alternative method I could use in the mean time?[/QUOTE]
Think hook and using [b][url=http://bananatree.im/wiki/wiki.garrysmod.com/index8c6a.html?title=Entity.GetGroundEntity]Entity.GetGroundEntity[img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Try to see if [b][url=http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index8c6a.html?title=Entity.GetGroundEntity]Entity.GetGroundEntity [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] still works.
[b]edit:[/b] Someone rate me late.
Thanks, but now i'm having trouble with that...I have this hook:
[lua]
hook.Add("Think","Player:DoorTime", function()
if !LocalPlayer():IsOnGround() then return end
local tra = {}
tra.start = LocalPlayer():GetPos()
tra.endpos = LocalPlayer():GetGroundEntity():GetPos()
tra.filter = LocalPlayer()
tr = util.TraceLine(tra)
if tr.Entity:IsValid() then
if tr.Entity:GetClass() == "func_door" and !DestroyTimer then
timer.Create(tonumber(LocalPlayer():UniqueID()).."myDoorTime", tonumber(LocalBlockTime), 1, function()
DestroyTimer = true
LocalPlayer():ConCommand("Kill")
timer.Destroy(tonumber(LocalPlayer():UniqueID()).."myDoorTime")
end)
if DestroyTimer then
timer.Destroy(tonumber(LocalPlayer():UniqueID()).."myDoorTime")
DestroyTimer = false
end
end
end
end)
[/lua]
It only runs through once, and i'm trying to get it to run only when the player is standing on a func_door. I only want to Think to go through to the timer.create when the timer: 1. specified time to run has run out, and 2. when the timer doesn't exist. Can anyone help me out please? :/
Also, this is in cl_init.
Maybe I'm missing something, but the hook is working perfectly for me in 12.
[lua]function GM:OnPlayerHitGround( ply, inWater, onFloating, vel )
print( "OnPlayerHitGround", ply, inWater, onFloating, vel )
end[/lua]
[code]OnPlayerHitGround Player [1][BlackAwps] false false 1737.1636962891[/code]
[QUOTE=BlackAwps;35042081]Maybe I'm missing something, but the hook is working perfectly for me in 12.
[lua]function GM:OnPlayerHitGround( ply, inWater, onFloating, vel )
print( "OnPlayerHitGround", ply, inWater, onFloating, vel )
end[/lua]
[code]OnPlayerHitGround Player [1][BlackAwps] false false 1737.1636962891[/code][/QUOTE]
Doesn't work for me. Atleast not on my server that I have setup through SRCDS.
Working on my server, with the latest updates.
[code]> hook.Add( "OnPlayerHitGround", "pebus", function( ply, inWater, onFloating, vel ) ServerLog( "OnPlayerHitGround\t" .. tostring( ply ) .. "\t" .. tostring( inWater ) .. "\t" .. tostring( onFloating ) .. "\t" .. vel ) end )...
L 03/07/2012 - 19:26:59: OnPlayerHitGround Player [1][PLHH] false false 454.54556274414
L 03/07/2012 - 19:27:01: OnPlayerHitGround Player [4][Atomic Doughnut] false false 309.09097290039
L 03/07/2012 - 19:27:02: OnPlayerHitGround Player [6][flagalstan] false false 369.69705200195[/code]
[QUOTE=BlackAwps;35042990]Working on my server, with the latest updates.
[code]> hook.Add( "OnPlayerHitGround", "pebus", function( ply, inWater, onFloating, vel ) ServerLog( "OnPlayerHitGround\t" .. tostring( ply ) .. "\t" .. tostring( inWater ) .. "\t" .. tostring( onFloating ) .. "\t" .. vel ) end )...
L 03/07/2012 - 19:26:59: OnPlayerHitGround Player [1][PLHH] false false 454.54556274414
L 03/07/2012 - 19:27:01: OnPlayerHitGround Player [4][Atomic Doughnut] false false 309.09097290039
L 03/07/2012 - 19:27:02: OnPlayerHitGround Player [6][flagalstan] false false 369.69705200195[/code][/QUOTE]
Hmm, odd. It doesn't work for me, I guess i'll have to try updating everything again.
Update: Here's a look at what's happening to me. [url]http://www.youtube.com/watch?v=GicAstCn0js[/url]
OnPlayerHitGround only works when I jump long distances / high places, but when it's a short jump, it doesn't register. I have no idea how you have it working, I assume it's not working like that for you BlackAwps.
This frustrates me.
I don't use it for short distances, so yeah that's probably why.
Sorry, you need to Log In to post a reply to this thread.