dener189 Posted May 10, 2019 Share Posted May 10, 2019 (edited) Hello, I was doing an experience level script, while you level up would play a sound and appear in the center of the screen as you level up, but it is not working Spoiler local sx,sy = guiGetScreenSize() local px,py = 1366,768 local x,y = (sx/px),(sy/py) ----------------------------------------------------------------------------------------------- function drawLevel () local levelProgress = (getElementData(localPlayer,"minutes") or 0) dxDrawRectangle(x*803, y*743, x*160/58*levelProgress, y*19, tocolor(0, 0, 0, 130), false) dxDrawRectangle(x*800, y*740, x*170, y*25, tocolor(0, 0, 0, 120), false) dxDrawText("LEVEL: "..(getElementData(localPlayer,"Level") or 0), x*854, y*746, x*10, y*10, tocolor(255, 255, 255, 255), x*0.9, "default", "left", "top", false, false, false, false, false) end addEventHandler("onClientRender",getRootElement(),drawLevel) ----------------------------------------------------------------------------------------------- setElementData ( localPlayer, "Mensagem", "true" ) local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local dxfont0_fonte = dxCreateFont("font/ds-digital.ttf", x*22) local screenW, screenH = guiGetScreenSize() ----------------------------------------------------------------------------------------------- function Mensagem_Ativacao () if getElementData ( localPlayer,"Mensagem" ) == "true" then dxDrawText("NOVO NIVEL DESBLOQUEADO"..getElementData(localPlayer,"Level"), x*0 + 1, y*0 + 1, x*1366 + 1, y*768 + 1, tocolor(0, 0, 0, 255), x*1.00, dxfont0_fonte, "center", "center", false, false, false, true, false) end end addEventHandler ( "onClientRender", getRootElement ( ), Mensagem_Ativacao ) ----------------------------------------------------------------------------------------------- function Ativador_Musica ( Musica_Selecionada ) setElementData ( localPlayer, "Mensagem", "Sim" ) setTimer ( function() setElementData ( localPlayer, "Mensagem", "true" ) end, 14000, 1 ) if music_select == 1 then Musica = playSound ( "sounds/lvl.mp3" ) end end addEvent( "PlaySound", true ) addEventHandler( "PlaySound", root, start_music ) Edited May 10, 2019 by dener189 Link to comment
Investor Posted May 10, 2019 Share Posted May 10, 2019 Sound isn't working because you expect music_select to be 1 to play a sound but it's never defined, so it's nil, not 1. function Ativador_Musica(Musica_Selecionada) setElementData ( localPlayer, "Mensagem", "Sim ") setTimer ( function() setElementData ( localPlayer, "Mensagem", "true" ) end, 14000, 1 ) if music_select == 1 then -- where is music_select defined? did you mean Musica_Selecionada? Musica = playSound ( "sounds/lvl.mp3" ) end end addEvent( "PlaySound", true ) addEventHandler( "PlaySound", root, start_music ) Link to comment
dener189 Posted May 12, 2019 Author Share Posted May 12, 2019 On 5/10/2019 at 2:57 PM, Investor said: Sound isn't working because you expect music_select to be 1 to play a sound but it's never defined, so it's nil, not 1. function Ativador_Musica(Musica_Selecionada) setElementData ( localPlayer, "Mensagem", "Sim ") setTimer ( function() setElementData ( localPlayer, "Mensagem", "true" ) end, 14000, 1 ) if music_select == 1 then -- where is music_select defined? did you mean Musica_Selecionada? Musica = playSound ( "sounds/lvl.mp3" ) end end addEvent( "PlaySound", true ) addEventHandler( "PlaySound", root, start_music ) could you do the final script for me? if not ask too much '-' Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now