Trying to get this to work. I've placed it serverside in the autorun folder.
[CODE]function RoleMusic()
for k, ply in pairs(player.GetAll()) do
if ply:GetRole() == ROLE_TRAITOR then
ply:SendLua( 'surface.PlaySound( "traitorbegin.mp3" )' )
elseif ply:GetRole() == ROLE_INNOCENT then
ply:SendLua( 'surface.PlaySound( "innocentbegin.mp3" )' )
elseif ply:GetRole() == ROLE_DETECTIVE then
ply:SendLua( 'surface.PlaySound( "detectivebegin.mp3" )' )
end
end
end
hook.Add( "TTTBeginRound", "TTTRoleMusic", RoleMusic )[/CODE]
The sound is played fine, however I get this error:
[CODE][ERROR] addons/gamemusic-master/lua/autorun/gamemusic_init.lua:34: attempt to call method 'SendLua' (a nil value)
1. fn - addons/gamemusic-master/lua/autorun/gamemusic_init.lua:34
2. Call - addons/ulib/lua/ulib/shared/hook.lua:109
3. RoundStateChange - gamemodes/terrortown/gamemode/cl_init.lua:131
4. func - gamemodes/terrortown/gamemode/cl_init.lua:204
5. unknown - lua/includes/extensions/net.lua:32[/CODE]
Any ideas?
[QUOTE=Ferrumite;51937159]Trying to get this to work. I've placed it serverside in the autorun folder.
[CODE]function RoleMusic()
for k, ply in pairs(player.GetAll()) do
if ply:GetRole() == ROLE_TRAITOR then
ply:SendLua( 'surface.PlaySound( "traitorbegin.mp3" )' )
elseif ply:GetRole() == ROLE_INNOCENT then
ply:SendLua( 'surface.PlaySound( "innocentbegin.mp3" )' )
elseif ply:GetRole() == ROLE_DETECTIVE then
ply:SendLua( 'surface.PlaySound( "detectivebegin.mp3" )' )
end
end
end
hook.Add( "TTTBeginRound", "TTTRoleMusic", RoleMusic )[/CODE]
Once the round begins, I get this error:
[CODE][ERROR] addons/gamemusic-master/lua/autorun/gamemusic_init.lua:34: attempt to call method 'SendLua' (a nil value)
1. fn - addons/gamemusic-master/lua/autorun/gamemusic_init.lua:34
2. Call - addons/ulib/lua/ulib/shared/hook.lua:109
3. RoundStateChange - gamemodes/terrortown/gamemode/cl_init.lua:131
4. func - gamemodes/terrortown/gamemode/cl_init.lua:204
5. unknown - lua/includes/extensions/net.lua:32[/CODE]
Any ideas?[/QUOTE]
You're calling SendLua clientside.
[QUOTE=meharryp;51937208]You're calling SendLua clientside.[/QUOTE]
Oh, how can I fix it?
[QUOTE=Ferrumite;51937236]Oh, how can I fix it?[/QUOTE]
Replace
[code]
ply:SendLua( 'surface.PlaySound( "traitorbegin.mp3" )' )
[/code]
with
[code]
surface.PlaySound( "traitorbegin.mp3" )
[/code]
[QUOTE=Tomvdr;51937419]Replace
[code]
ply:SendLua( 'surface.PlaySound( "traitorbegin.mp3" )' )
[/code]
with
[code]
surface.PlaySound( "traitorbegin.mp3" )
[/code][/QUOTE]
Thanks, that fixed it!
Sorry, you need to Log In to post a reply to this thread.