EW1611 Posted September 17, 2019 Posted September 17, 2019 Olá fiz o seguinte script, para quando o player soltar o acelerador dar play no som, mas não da play e nenhum erro no debugscript, até tentei aumentar o volume, mas ainda não acontece nada: function blowoff(thePlayer) p = getPedOccupiedVehicle(thePlayer) id = getElementModel(p) if id == 562 then pos = getElementPosition(thePlayer) s1 = playSound3D("BlowOff.mp3", pos, true) setSoundVolume(s1, 10) end end function bnd() unbindKey("accelerate","up",blowoff) end addEventHandler("onClientVehicleEnter", root, bnd) function ubnd() unbindKey("accelerate","up",blowoff) end addEventHandler("onClientVehicleExit", root, ubnd) Obs: O áudio tem 1 segundo, não sei se pode ser isso
Other Languages Moderators Lord Henry Posted September 17, 2019 Other Languages Moderators Posted September 17, 2019 Linha 12 deveria ser bindKey. Você está bindando a função ao soltar a tecla, é isso mesmo? Ou deveria ocorrer ao pressionar a tecla?
EW1611 Posted September 17, 2019 Author Posted September 17, 2019 (edited) é, ao soltar a tecla que o player usa para acelerar o veículo Erro na linha 2: Bad argument @ 'getElementPosition' [Expected element at argument 1, got string 'accelerate']; linha 3:Bad argument @ 'playSound3D' [Expected vector 3 at argument 2, got boolean]; linha 4: bad 'sound/player' pointer @ 'setSoundVolume'(1) Edited September 17, 2019 by EW1611
Other Languages Moderators Lord Henry Posted September 17, 2019 Other Languages Moderators Posted September 17, 2019 (edited) Scripts client-side usam localPlayer. Remova o parâmetro de função e troque todos os thePlayer por localPlayer. Se você ler a wiki do bindKey, vai perceber que no client-side, o primeiro parâmetro não é o jogador e sim o nome da tecla/controle. Edited September 17, 2019 by Lord Henry 1
EW1611 Posted September 17, 2019 Author Posted September 17, 2019 function blowoff(localPlayer, accelerate, up) local p = getPedOccupiedVehicle(localPlayer) local id = getElementModel(p) if id == 562 then local x,y,z = getElementPosition(localPlayer) s1 = playSound3D("BlowOff.mp3", x,y,z) setSoundVolume(s1, 1.5) end end function bnd() bindKey("accelerate","up",blowoff) end addEventHandler("onClientVehicleEnter", root, bnd) function ubnd() unbindKey("accelerate","up",blowoff) end addEventHandler("onClientVehicleExit", root, ubnd) Fiz assim e continua dando o mesmo erro na linha 2 e 3
Furzy Posted September 17, 2019 Posted September 17, 2019 (edited) remova o localPlayer do parametro e tente remover a linha 3 e 4 pra ver se o problema está ali getKeyState isso pode te ajudar tambem Edited September 17, 2019 by Furzy 1
EW1611 Posted September 18, 2019 Author Posted September 18, 2019 fiz assim, mas da o mesmo erro " [Expected element at argument 1, got string 'accelerate']" function blowoff(source, localPlayer, accelerate, up) local x,y,z = getElementPosition(localPlayer) playSound3D("BlowOff.mp3", x,y,z) end function bnd() bindKey("accelerate","up",blowoff) end addEventHandler("onClientVehicleEnter", root, bnd) function ubnd() unbindKey("accelerate","up",blowoff) end addEventHandler("onClientVehicleExit", root, ubnd)
EW1611 Posted September 18, 2019 Author Posted September 18, 2019 Fiz assim e agora está funcionando perfeitamente: addEventHandler("onClientVehicleEnter", root, function (key, keystate) bindKey("accelerate", "up", blowoff) end) function blowoff(commandname) p = getPedOccupiedVehicle(localPlayer) id = getElementModel(p) if id == 562 then x,y,z = getElementPosition(localPlayer) playSound3D("BlowOff.mp3", x,y,z) end end 1
Furzy Posted September 18, 2019 Posted September 18, 2019 37 minutes ago, EW1611 said: Fiz assim e agora está funcionando perfeitamente: addEventHandler("onClientVehicleEnter", root, function (key, keystate) bindKey("accelerate", "up", blowoff) end) function blowoff(commandname) p = getPedOccupiedVehicle(localPlayer) id = getElementModel(p) if id == 562 then x,y,z = getElementPosition(localPlayer) playSound3D("BlowOff.mp3", x,y,z) end end Boa 1
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