goofie88 Posted December 2, 2012 Posted December 2, 2012 (edited) hello guys I've made a voice thing but for some reason it shows the voice but when I press 1 theres no souns Client voice = nil addCommandHandler("voice", function() if not voice then voice = 1 else voice = nil end end ) addEventHandler("onClientPlayerWasted", getLocalPlayer(), function() voice = nil end) local width,height = guiGetScreenSize() addEventHandler("onClientRender", getRootElement(), function() if voice then tab1 = nil tab2 = nil dxDrawText("Radio Machine ",1,(height/2)-80,width,height,tocolor(255,255,255,255),0.6,"bankgothic" ) if not isPedInVehicle(getLocalPlayer()) then tab1 = 1 dxDrawRectangle(0,(height/2)-80,220,200,tocolor(0,0,0,70)) if not disabled then dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,150,240,255),0.6,"bankgothic" ) one = true else dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,100,100,255),0.6,"bankgothic" ) one = false end end end end) function pressed1() if voice then if one == true then local x, y, z = getElementPosition(getLocalPlayer()) if tab1 then triggerEvent("sendSound", getLocalPlayer(), "1.1", x, y, z) end end disableAll() end end function disableAll() disabled = 1 setTimer(enableAll, 5000, 1) end function enableAll() disabled = nil end bindKey("1", "down", pressed1) function sendSound (sound, nX, nY, nZ) local pX, pY, pZ = getElementPosition(getLocalPlayer()) local dist = getDistanceBetweenPoints3D(pX, pY, pZ, nX, nY, nZ) if dist < 40 then if sound == "1.1" then playSound("sounds/roger.mp3", false) end end end addEventHandler("sendSound", getRootElement(), sendSound) addEvent("sendSound", true) Edited December 2, 2012 by Guest
Castillo Posted December 2, 2012 Posted December 2, 2012 Any error on the debugscript? ( /debugscript 3 in-game ). San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
50p Posted December 2, 2012 Posted December 2, 2012 You have to close the function "pressed1" and "if" statements with an "end". Checked your code with MTASE, showed error message. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
goofie88 Posted December 2, 2012 Author Posted December 2, 2012 Still the same theres no sound function pressed1() if voice then if one == true then local x, y, z = getElementPosition(getLocalPlayer()) if tab1 then triggerEvent("sendSound", getLocalPlayer(), "1.1", x, y, z) end end disableAll() end end
Jaysds1 Posted December 2, 2012 Posted December 2, 2012 try this: voice = false addCommandHandler("voice", function() voice = not voice end) addEventHandler("onClientPlayerWasted", getLocalPlayer(), function() voice = false end) local width,height = guiGetScreenSize() addEventHandler("onClientRender", getRootElement(), function() if voice then tab1 = nil tab2 = nil dxDrawText("Radio Machine ",1,(height/2)-80,width,height,tocolor(255,255,255,255),0.6,"bankgothic" ) if not isPedInVehicle(getLocalPlayer()) then tab1 = 1 dxDrawRectangle(0,(height/2)-80,220,200,tocolor(0,0,0,70)) if not disabled then dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,150,240,255),0.6,"bankgothic" ) one = true else dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,100,100,255),0.6,"bankgothic" ) one = false end end end end) function disableAll() disabled = true setTimer(enableAll, 5000, 1) end function enableAll() disabled = false end function pressed1() if voice then if one == true then if tab1 then local x, y, z = getElementPosition(getLocalPlayer()) triggerEvent("sendSound", getLocalPlayer(), "1.1", x, y, z) end end disableAll() end end bindKey("1", "down", pressed1) function sendSound (sound, nX, nY, nZ) local pX, pY, pZ = getElementPosition(getLocalPlayer()) local dist = getDistanceBetweenPoints3D(pX, pY, pZ, nX, nY, nZ) if dist < 40 then if sound == "1.1" then playSound("sounds/roger.mp3", false) end end end addEventHandler("sendSound", getRootElement(), sendSound) addEvent("sendSound", true) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
goofie88 Posted December 3, 2012 Author Posted December 3, 2012 Thank you for trying to help Jaysds1 but unfortunately it still doesn't make the sound and no errors in /debugscript 3
goofie88 Posted December 3, 2012 Author Posted December 3, 2012 <meta> <info author="goofie88" name="Sound Panel" version="1.3r" type="script" />> <script src="sounds_client.lua" type="client"/> <file src="sounds/roger.mp3"/> </meta>
AhmadQTR Posted December 3, 2012 Posted December 3, 2012 <meta> <info author="goofie88" name="Sound Panel" version="1.3r" type="script" />[color=#FF0000]>[/color] <script src="sounds_client.lua" type="client"/> <file src="sounds/roger.mp3"/> </meta> Extra '>' ? Nobody is perfect , I'm nobody. Skype : ahmad.nasser37
Blaawee Posted December 3, 2012 Posted December 3, 2012 "goofie88" name="Sound Panel" version="1.3r" type="script" />
AhmadQTR Posted December 3, 2012 Posted December 3, 2012 <meta> <info author="goofie88" name="Sound Panel" version="1.3r" type="script" />[color=#FF0000]>[/color] <script src="sounds_client.lua" type="client"/> <file src="sounds/roger.mp3"/> </meta> Extra '>' ? "goofie88" name="Sound Panel" version="1.3r" type="script" /> No need to increase your posts Nobody is perfect , I'm nobody. Skype : ahmad.nasser37
Baseplate Posted December 3, 2012 Posted December 3, 2012 No need to be a cunt, he just wanted to help.
AhmadQTR Posted December 3, 2012 Posted December 3, 2012 No need to be a , he just wanted to help. Lol , okay Btw , did it work goofie88? Nobody is perfect , I'm nobody. Skype : ahmad.nasser37
Jaysds1 Posted December 3, 2012 Posted December 3, 2012 try this: voice = false disabled = true one = false tab1 = false tab2 = false addCommandHandler("voice",function() voice = not voice end) addEventHandler("onClientPlayerWasted",localPlayer, function() voice = false end) addEventHandler("onClientRender",root, function() local width,height = guiGetScreenSize() if voice then dxDrawText("Radio Machine ",1,(height/2)-80,width,height,tocolor(255,255,255,255),0.6,"bankgothic" ) if isPedInVehicle(localPlayer) then return end tab1 = true dxDrawRectangle(0,(height/2)-80,220,200,tocolor(0,0,0,70)) if not disabled then dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,150,240,255),0.6,"bankgothic" ) one = true else dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,100,100,255),0.6,"bankgothic" ) one = false end end end) function enableAll() disabled = false end function disableAll() disabled = true setTimer(enableAll, 5000, 1) end bindKey("1", "down",function() if voice then if one then local x, y, z = getElementPosition(localPlayer) if tab1 then sendSound("1.1", x, y, z) end end disableAll() end end) function sendSound (sound, nX, nY, nZ) local pX, pY, pZ = getElementPosition(getLocalPlayer()) local dist = getDistanceBetweenPoints3D(pX, pY, pZ, nX, nY, nZ) if dist < 40 then if sound == "1.1" then playSound("sounds/roger.mp3", false) end end end My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
goofie88 Posted December 4, 2012 Author Posted December 4, 2012 Thank you I hear the sound now but others dont hear, is that bcz its client side? if yes then how should I do so others car hear? Thank you again
AhmadQTR Posted December 4, 2012 Posted December 4, 2012 Thank you I hear the sound now but others dont hear, is that bcz its client side? if yes then how should I do so others car hear? Thank you again Maybe like this? voice = false disabled = true one = false tab1 = false tab2 = false addCommandHandler("voice",function() voice = not voice end) addEventHandler("onClientPlayerWasted",root, function() voice = false end) addEventHandler("onClientRender",root, function() local width,height = guiGetScreenSize() if voice then dxDrawText("Radio Machine ",1,(height/2)-80,width,height,tocolor(255,255,255,255),0.6,"bankgothic" ) if isPedInVehicle(localPlayer) then return end tab1 = true dxDrawRectangle(0,(height/2)-80,220,200,tocolor(0,0,0,70)) if not disabled then dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,150,240,255),0.6,"bankgothic" ) one = true else dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,100,100,255),0.6,"bankgothic" ) one = false end end end) function enableAll() disabled = false end function disableAll() disabled = true setTimer(enableAll, 5000, 1) end bindKey("1", "down",function() if voice then if one then local x, y, z = getElementPosition(localPlayer) if tab1 then sendSound("1.1", x, y, z) end end disableAll() end end) function sendSound (sound, nX, nY, nZ) local pX, pY, pZ = getElementPosition(getLocalPlayer()) local dist = getDistanceBetweenPoints3D(pX, pY, pZ, nX, nY, nZ) if dist < 40 then if sound == "1.1" then playSound("sounds/roger.mp3", false) end end end Nobody is perfect , I'm nobody. Skype : ahmad.nasser37
Castillo Posted December 4, 2012 Posted December 4, 2012 Thank you I hear the sound now but others dont hear, is that bcz its client side? if yes then how should I do so others car hear? Thank you again You need to trigger a server event and then back to all clients, then start the sound on every client and attach it to the vehicle. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted December 5, 2012 Posted December 5, 2012 here, try this: client-side: voice = false disabled = true one = false tab1 = false tab2 = false addCommandHandler("voice",function() voice = not voice end) addEventHandler("onClientPlayerWasted",localPlayer, function() voice = false end) addEventHandler("onClientRender",root, function() local width,height = guiGetScreenSize() if voice then dxDrawText("Radio Machine ",1,(height/2)-80,width,height,tocolor(255,255,255,255),0.6,"bankgothic" ) if isPedInVehicle(localPlayer) then return end tab1 = true dxDrawRectangle(0,(height/2)-80,220,200,tocolor(0,0,0,70)) if not disabled then dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,150,240,255),0.6,"bankgothic" ) one = true else dxDrawText("(1) Roger",1,(height/2)-60,width,height,tocolor(100,100,100,255),0.6,"bankgothic" ) one = false end end end) function enableAll() disabled = false end function disableAll() disabled = true setTimer(enableAll, 5000, 1) end bindKey("1", "down",function() if voice then if one then local x, y, z = getElementPosition(localPlayer) if tab1 then triggerServerEvent("sendSound",localPlayer,1.1,x,y,z)--sendSound("1.1", x, y, z) end end disableAll() end end) addEvent("receiveSound",true) addEventHandler("receiveSound",root,function(sPath,sLoop) playSound(sPath,sLoop) end) server-side: addEvent("sendSound",true) addEventHandler("sendSound",root,function(sound, nX, nY, nZ) for i,_ in ipairs(getElementsByType("player"))do local pX, pY, pZ = getElementPosition(i) local dist = getDistanceBetweenPoints3D(pX, pY, pZ, nX, nY, nZ) if dist < 40 then if sound == "1.1" then triggerClientEvent("receiveSound","sounds/roger.mp3", false) end end end end) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
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