Jump to content

Ajuda com playSound3D


Recommended Posts

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

 

Link to comment

é, 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 by EW1611
Link to comment
  • Other Languages Moderators

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 by Lord Henry
  • Thanks 1
Link to comment
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

Link to comment

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)

 

Link to comment

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

 

  • Like 1
Link to comment
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 xD

  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...