tim260 Posted November 4, 2011 Posted November 4, 2011 i was searching for a script but i couldnt get it to work, i found this (©solidsnake14) --client function startSirene ( vehicle ) local x,y,z = getElementPosition( vehicle ) sound = playSound3D( "sons\\sirene1.wav", x, y, z, true) attachElements ( sound, vehicle) end addEvent( "startSirene", true ) addEventHandler("startSirene", getRootElement(), startSirene) function stopSirene() destroyElement(sound) end addEvent( "stopSirene", true ) addEventHandler("stopSirene", getRootElement(), stopSirene) --server function startSirene( player, cmd ) local commandant = createVehicle ( 554, 1227.746, -1422.281, 13.5432, 0, 0, 0, "COMM1" ) triggerClientEvent ( player, "startSirene", getRootElement(), commandant ) end addCommandHandler ( "sireneon", startSirene) function stopSirene( player, cmd ) triggerClientEvent ( player, "stopSirene", getRootElement() ) end addCommandHandler ( "sireneoff", stopSirene) but cant get it to work ;/ EDIT: and dont understand it fully
Jaysds1 Posted November 5, 2011 Posted November 5, 2011 try this: addEventHandler("onVehicleEnter",getRootElement(), function(player,seat,jacked) if (player) then if (seat == 0) then veh = getPedOccupiedVehicle(player) bindKey(player,"l","down",sirens,veh) end end end) addEventHandler("onVehicleStartExit",getRootElement(), function(player,seat,jacked) if (player) then if (seat == 0) then unbindKey(player,"l","down",sirens) end end end) function sirens(keyPresser,key,keyState,veh) if (keyPresser) then if (key == "l") and (keyState == "down") then if not getVehicleSirensOn ( veh ) then setVehicleSirensOn ( veh, true ) --Turn it on else setVehicleSirensOn ( veh, false ) --Turn it off 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/
myonlake Posted November 5, 2011 Posted November 5, 2011 try this: addEventHandler("onVehicleEnter",getRootElement(), function(player,seat,jacked) if (player) then if (seat == 0) then veh = getPedOccupiedVehicle(player) bindKey(player,"l","down",sirens,veh) end end end) addEventHandler("onVehicleStartExit",getRootElement(), function(player,seat,jacked) if (player) then if (seat == 0) then unbindKey(player,"l","down",sirens) end end end) function sirens(keyPresser,key,keyState,veh) if (keyPresser) then if (key == "l") and (keyState == "down") then if not getVehicleSirensOn ( veh ) then setVehicleSirensOn ( veh, true ) --Turn it on else setVehicleSirensOn ( veh, false ) --Turn it off end end end end @ Jaysds1: I know he could easily modify your script, but just to remind you, civilian vehicles cannot play the siren sound, so it means you need to attach a playSound3D function for the car. Your script was like another script, nothing from the original one. @ tim260: Remember to add setSoundVolume and setSoundMaxDistance for the sound. Otherwise if you don't have the volume, you can't hear it. If I helped you, please click the like button on the right Thanks!
tim260 Posted November 5, 2011 Author Posted November 5, 2011 try this: addEventHandler("onVehicleEnter",getRootElement(), function(player,seat,jacked) if (player) then if (seat == 0) then veh = getPedOccupiedVehicle(player) bindKey(player,"l","down",sirens,veh) end end end) addEventHandler("onVehicleStartExit",getRootElement(), function(player,seat,jacked) if (player) then if (seat == 0) then unbindKey(player,"l","down",sirens) end end end) function sirens(keyPresser,key,keyState,veh) if (keyPresser) then if (key == "l") and (keyState == "down") then if not getVehicleSirensOn ( veh ) then setVehicleSirensOn ( veh, true ) --Turn it on else setVehicleSirensOn ( veh, false ) --Turn it off end end end end still i cant get it to work
bandi94 Posted November 5, 2011 Posted November 5, 2011 try this or use /debugscript 3 to find where is the problem addEventHandler("onVehicleEnter",getRootElement(), function(player,seat,jacked) if (player) then if (seat == 0) then veh = getPedOccupiedVehicle(player) bindKey(player,"l","down",sirens) end end end) addEventHandler("onVehicleStartExit",getRootElement(), function(player,seat,jacked) if (player) then if (seat == 0) then unbindKey(player,"l","down") end end end) function sirens() if not getVehicleSirensOn ( veh ) then setVehicleSirensOn ( veh, true ) --Turn it on else setVehicleSirensOn ( veh, false ) --Turn it off end end Ingame Name : |DGT|Puma DGT Clan Server 24/7 Owner/Scripter MultiGameMode in progress :
Jaysds1 Posted November 5, 2011 Posted November 5, 2011 I've just finish making a resource for this, here: https://community.multitheftauto.com/index.php?p=resources&s=details&id=3185 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