Hi, I'm using this to change the footstep sounds for a job. However I would like to have two diffrent sounds, one for walking and this for running. How would I do this?
[CODE]local Team = ply:Team()
if Team == TEAM_CP then
ply:EmitSound( "NPC_MetroPolice.RunFootstepLeft" )
return true[/CODE]
Walking sound.
[CODE]NPC_MetroPolice.FootstepLeft[/CODE]
I got this error.
[CODE][ERROR] addons/darkrpmodification-master/lua/darkrp_customthings/jobs.lua:92: attempt to compare userdata with number
1. unknown - addons/darkrpmodification-master/lua/darkrp_customthings/jobs.lua:92[/CODE]
This is how I did.
[CODE]local Team = ply:Team()
if Team == TEAM_CP and ply:GetVelocity() <= 100 then
ply:EmitSound( "NPC_MetroPolice.FootstepLeft" )
return true -- Don't allow default footsteps
elseif Team == TEAM_CP and ply:GetVelocity() >= 100 then
ply:EmitSound( "NPC_MetroPolice.RunFootstepLeft" )
return true -- Don't allow default footsteps[/CODE]
[QUOTE=emmelolz;52863117][CODE][ERROR] addons/darkrpmodification-master/lua/darkrp_customthings/jobs.lua:92: attempt to compare userdata with number
1. unknown - addons/darkrpmodification-master/lua/darkrp_customthings/jobs.lua:92[/CODE][/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetVelocity]Entity:GetVelocity[/url] returns a Vector, not a number. Thus the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/Length2D]Vector:Length2D[/url], which returns the vector's length (in this case, should be the player's speed ignoring up/down speed).
[QUOTE=Ljgoombruh;52863147][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetVelocity]Entity:GetVelocity[/url] returns a Vector, not a number. Thus the [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/Length2D]Vector:Length2D[/url], which returns the vector's length (in this case, should be the player's speed ignoring up/down speed).[/QUOTE]
Alright, this is new right here is new to me :s: How would I go about writing this?
Thank you!
This works.
[CODE]function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
local speed = ply:GetVelocity():Length2D()
local Team = ply:Team()
if (speed > 150) then
if Team == TEAM_CP then
-- sprinting..
ply:EmitSound( "NPC_MetroPolice.RunFootstepLeft" )
elseif Team == TEAM_CP then
-- walking..
ply:EmitSound( "NPC_MetroPolice.FootstepLeft" )
end
end
end[/CODE]
Sorry, you need to Log In to post a reply to this thread.