Electrosumm Posted August 17, 2015 Share Posted August 17, 2015 function radiobekapcsol () local jatekosautoban = getPlayerName ( localPlayer ) radiomegy = not radiomegy if radiomegy then mozgat = true if (jatekosautoban) then if isPedInVehicle (jatekosautoban) then setSoundVolume(stream, 1) outputChatBox("#00FF00Bekapcsoltad/Kikapcsoltad a rádiót!#00FF00", 255, 255, 255, true) else mozgat = false setSoundVolume(stream, 0) outputChatBox("#8B1A1ANem vagy autóban!#8B1A1A", 255, 255, 255, true) end end end end its from my radio script but i have problem with it...i can only switch off the radio but cant swtich on. and debugscript said it : lua 16 bad argument 'isPedInVehicle (expected ped at argument 1 got string myname. help me and the last question is how can i do it ? : the radio switch on only keybind cause when i join the radio turn on...i use keybind + addEventHandler("onClientRender" Link to comment
Electrosumm Posted August 17, 2015 Author Share Posted August 17, 2015 ahh i did the problem..but now the problem is when i turn on the radio is still play when i go out from my car how to fix it ? Link to comment
Moderators Citizen Posted August 17, 2015 Moderators Share Posted August 17, 2015 You need to setSoundVolume(stream, 0) When the OnClientPlayerVehicleExit is triggered on the localPlayer. By the way I would turn off the stream instead of just setting its volume to 0. Link to comment
Electrosumm Posted August 17, 2015 Author Share Posted August 17, 2015 damn now i tested but i cant turn off in car... and i dont know how to do "When the OnClientPlayerVehicleExit is triggered on the localPlayer." can anyone write it for me Link to comment
Moderators Citizen Posted August 17, 2015 Moderators Share Posted August 17, 2015 Here is how your code should look like (read the comments): local radiomegy = false -- radio isn't playing function radiobekapcsol () if not radiomegy then -- if the radio is not playing then if isPedInVehicle (localPlayer) then -- if the local player is in a vehicle then playRadio() -- start the radio else outputChatBox("#8B1A1ANem vagy autóban!#8B1A1A", localPlayer, 255, 255, 255, true) end else -- if the radio is playing then stopRadio() -- stop the radio end end function playRadio() setSoundVolume(stream, 1) -- set the volume to 1 outputChatBox("#00FF00Bekapcsoltad a rádiót !#00FF00", localPlayer, 255, 255, 255, true) radiomegy = true -- the radio is started end function stopRadio() setSoundVolume(stream, 0) -- set the volume to 0 outputChatBox("#00FF00Kikapcsoltad a rádiót !#00FF00", localPlayer, 255, 255, 255, true) radiomegy = false -- the radio is stopped end addEventHandler("onClientPlayerVehicleExit", localPlayer, stopRadio) -- calls stopRadio after the local player exited a vehicle Link to comment
Electrosumm Posted August 18, 2015 Author Share Posted August 18, 2015 Very very thanks ...my script didnt work 100% it had some bug Link to comment
Moderators Citizen Posted August 18, 2015 Moderators Share Posted August 18, 2015 Yeah, the logic was not really clear so I kinda wrote down exactly when the radio should be turned on and when it should be turned off. I wrote two seperate functions to turn it on and off, and then I just had to call them exactly when I wanted to. Very very thanks No problem 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