Alright, so I'm pretty new to this.
I would like it so when people enter the server successfully, a short audio clip is played.
This is what I have:
[lua]function GM:PlayerConnect( ply )
ply:SendLua(surface.PlaySound('surface.PlaySound("spaghetti.mp3")'))
end[/lua]
In my gamemode's init.lua
I'm not sure what to do now
[lua]function GM:PlayerConnect( ply )
ply:SendLua('surface.PlaySound("spaghetti.mp3")')
end[/lua]
I don't see your problem.
Don't do this.
To help you help yourself, I would recommend using MsgAll() or Print or something like those to debug.
Eg.
[CODE]
function GM:PlayerConnect( ply )
ply:SendLua(surface.PlaySound('surface.PlaySound("spaghetti.mp3")'))
MsgAll("Player Joined")
end
[/CODE]
Then look in your client console / server to see if you see that message. If not, then that functions not running. If it is, then we know its a problem with your code.
[CODE]if SERVER then
hook.Add( "PlayerSpawn", "SoundsPlox", function( ply )
ply:Surface.PlaySound( "soundofdoom.mp3" ) end )
end[/CODE]
Maybe this could work?
[QUOTE=Lemmie;41764063][CODE]if SERVER then
hook.Add( "PlayerSpawn", "SoundsPlox", function( ply )
ply:Surface.PlaySound( "soundofdoom.mp3" ) end )
end[/CODE]
Maybe this could work?[/QUOTE]
He wants it to play when the player connects, not when the player spawns.
You're not going about it the right way. If you really want music to play upon the player joining, you need to add it to your loading screen.
Ah i see, wouldn't PlayerIntialSpawn hook work if it sound was broadcasted?
Just realised... ¬¬
The only issue with that is, the player spawns before they are fully connected. So, they may not be able to hear the music. Try to figure a way to detect when they're fully connected ( Hint: What happens when they are fully connected? What can they do? ).
Place anywhere in autorun, music will only play once the player has fully loaded.
[lua]
local music = "music/HL2_song17.mp3";
if SERVER then
AddCSLuaFile();
-- Just incase they don't have your song
resource.AddSingleFile( "sound/".. music );
else
hook.Add( "InitPostEntity", "PlaySomeMusic", function()
surface.PlaySound( music );
end );
end
[/lua]
[QUOTE=incognitocob;41757878]Alright, so I'm pretty new to this.
I would like it so when people enter the server successfully, a short audio clip is played.
This is what I have:
[lua]function GM:PlayerConnect( ply )
ply:SendLua(surface.PlaySound('surface.PlaySound("spaghetti.mp3")'))
end[/lua]
In my gamemode's init.lua
I'm not sure what to do now[/QUOTE]
You have [lua] ply:SendLua(surface.PlaySound('surface.PlaySound("spaghetti.mp3")'))[/lua]
Should just be..
[lua]
ply:SendLua('surface.PlaySound("spaghetti.mp3")')
[/lua]
You were calling the client side function serverside. (and also twice)
Sorry, you need to Log In to post a reply to this thread.