Garry's Mod

Need help with lua (footstep sound)

Submitted by Praindom, , Thread ID: 192690

Praindom
Novice
Level:
0
Reputation:
0
Posts:
45
Likes:
4
Credits:
15
05-01-2021, 12:28 PM
#1
I want to customize a job with a different footstep sound.
The footstep sound is working, but I want to have the sound only when a player is running.

code:

hook.Add( "PlayerFootstep", "CustomFootstep", function( ply, pos, foot, sound, volume, rf )
        if ply:getDarkRPVar("job") == "Trooper" then
    ply:EmitSound( "npc/metropolice/gear5.wav" ) -- Play the footsteps hunter is using
    return true -- Don't allow default footsteps, or other addon footsteps
        end
end )

RE: Need help with lua (footstep sound)

1jeuu
Lurker
Level:
0
Reputation:
0
Posts:
1
Likes:
0
Credits:
1
05-01-2021, 04:18 PM
This post was last modified: 05-01-2021, 04:18 PM by 1jeuu
#2
use this: https://wiki.facepunch.com/gmod/Player:IsSprinting

hook.Add( "PlayerFootstep", "CustomFootstep", function( ply, pos, foot, sound, volume, rf )
if ply:IsSprinting() then
        if ply:getDarkRPVar("job") == "Trooper" then
    ply:EmitSound( "npc/metropolice/gear5.wav" ) -- Play the footsteps hunter is using
    return true -- Don't allow default footsteps, or other addon footsteps
        end
end
end )

Users browsing this thread: 1 Guest(s)