Skip to content

Instantly share code, notes, and snippets.

@ExtReMLapin
Created September 4, 2018 16:16
Show Gist options
  • Save ExtReMLapin/81cb11daf8997b230e571acfbfae4526 to your computer and use it in GitHub Desktop.
Save ExtReMLapin/81cb11daf8997b230e571acfbfae4526 to your computer and use it in GitHub Desktop.
custom footstep by playermodel gmod
if SERVER then return end
local data = {}
local function newplayermodelfootsteps(playermodel, material, tblsounds)
if not data[playermodel] then
data[playermodel] = {}
end
if not data[playermodel][material] then
data[playermodel][material] = tblsounds
else
table.Add(data[playermodel][material], tblsounds)
end
end
--[[
material list : https://wiki.garrysmod.com/page/Enums/MAT
EXAMPLE :
newplayermodelfootsteps("models/player/group01/male_08.mdl", MAT_CONCRETE, {"ghome/doorbell.wav"})
]]
hook.Add("PlayerFootstep", "customfootsteplapin", function(ply, pos, foot, s, volume, rf)
--if SERVER then return end
if not ply:IsOnGround() then
return
end
if not data[ply:GetModel()] then
return
end
local tr = util.TraceLine({
start = pos,
endpos = pos - Vector(0,0,1),
})
if not tr.Hit then return false end
if not data[ply:GetModel()][tr.MatType] then return end
sound.Play(table.Random(data[ply:GetModel()][tr.MatType] ), pos)
return true
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment