• Print

Author Topic: Anyone have experience with the PlayerFootstep hook?  (Read 4610 times)

0 Members and 1 Guest are viewing this topic.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Anyone have experience with the PlayerFootstep hook?
« on: May 04, 2014, 11:05:15 am »
In a gamemode I'm writing, I'm trying to give players the ability to sneak. I have it working all except for the hiding footstep sounds.

Code: [Select]
function footsteps( ply )
print("STEP")
if ply.sneaking then
print( "SNEAKING" )
return true
end
end
hook.Add("PlayerFootstep", "footsteps", footsteps )

All of the debug messages are printing so I know the logic and the hook are being called, but I still hear the footsteps.
Any ideas?

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: Anyone have experience with the PlayerFootstep hook?
« Reply #1 on: May 04, 2014, 01:14:19 pm »
I came across this in the ttt code, may or may not help you.
Code: Lua
  1. -- Kill footsteps on player and client
  2. function GM:PlayerFootstep(ply, pos, foot, sound, volume, rf)
  3.    if IsValid(ply) and (ply:Crouching() or ply:GetMaxSpeed() < 150) then
  4.       -- do not play anything, just prevent normal sounds from playing
  5.       return true
  6.    end
  7. end

Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Anyone have experience with the PlayerFootstep hook?
« Reply #2 on: May 04, 2014, 04:42:28 pm »
Tried, just to see if it's one of those things where something is supposed to be reverse of how it's listed in the wiki, to try returning nil or false?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Anyone have experience with the PlayerFootstep hook?
« Reply #3 on: May 05, 2014, 12:08:06 am »
bender, that's essentially the same as what I'm doing except in hook form. I will try overriding the function entirely instead of hooking to see if that helps.

Jam, of course I did.  :) What am I, an amateur?  :P

  • Print