• [minigame]how to add win or lose music in minigame gamemode
    13 replies, posted
for _, v in pairs(players) do if v:Team() == winner then if CurrentMapSettings["WinPoints"] != 0 then if v:Alive() then SendPoints(v, math.Round(CurrentMapSettings["WinPoints"] * 1.25)) else SendPoints(v, CurrentMapSettings["WinPoints"]) Entity( 1 ):EmitSound("win/win"..math.random(1,7)..".mp3") end end elseif CurrentMapSettings["LossPoints"] != 0 then SendPoints(v, CurrentMapSettings["LossPoints"]) Entity( 1 ):EmitSound("lose/sad"..math.random(1,5)..".mp3") end end end end }
If you mean they overlap each other then I think the best solution is to run stopsounds before playing a new sound and also attaching a simple 2s timer or something.
Why would you use an elseif? If they aren't on the winning team they must be on the losing team?
I haven't really looked into it, at first glance I thought he means that both of them play at the same time and he just wants to make only one play without any conditions or anything, my apologies.
if CurrentMapSettings["TeamType"] == 2 or CurrentMapSettings["TeamType"] == 3 then local str if winner == TEAM_RED then str = "RedWon" elseif winner == TEAM_BLUE then str = "BlueWon" end if str then SendNotification(str) end for _, v in pairs(players) do if v:Team() == winner then if CurrentMapSettings["WinPoints"] != 0 then if v:Alive() then SendPoints(v, math.Round(CurrentMapSettings["WinPoints"] * 1.25)) else SendPoints(v, CurrentMapSettings["WinPoints"]) sound.Play( "win/win"..math.random(1,7)..".mp3", Vector( 0, 0, 0 ) ) end end elseif CurrentMapSettings["LossPoints"] != 0 then SendPoints(v, CurrentMapSettings["LossPoints"]) sound.Play( "lose/sad"..math.random(1,5)..".mp3", Vector( 0, 0, 0 ) ) end end end end } this way error too because no win sound and no lose sound just silent
Are you sure that you have the sounds downloaded? Can you open console and do play <sound_name>
I hear a sound.
Your code works but you are creating the sound at position 0, 0, 0. Enable cheats on your server and run setpos 0 0 0 (don't forget to force endround so code will run)
no sound too
Do you understand that you are playing sound only for dead winners? Btw, surface.PlaySound is a client-side function and your code is probably server-sided.
how change to client side? im lua super noob
You need to network it Net Library Usage e.g. -- Server util.AddNetworkString( "MahAwesomeNetwork" ) -- Make new network local function SendMessage(ply,msg) net.Start("MahAwesomeNetwork") -- Start the 'letter' net.WriteString(msg) -- Write in the message net.Send(ply) -- Send it to given player end -- Client net.Receive( "my_MahAwesomeNetwork", function( len) -- Setup mailbox local msg = net.ReadString() -- Read the message print(msg) -- Print it end)
Sorry, you need to Log In to post a reply to this thread.