jingzhi Posted November 20, 2015 Share Posted November 20, 2015 Hello everybody, I have been working on a script recently and got a problem which seems like 2 variables on the Client side overwriting each other (on two different clients) local_sound = playSound3D(sound, x, y, z, true) When I try to play this sound for 2 players at the same time the local_sound variable gets overwrited so only the player who played sound second will hear the sound and the first player won't be able to hear it anymore. Any thought / help ? Link to comment
Addlibs Posted November 20, 2015 Share Posted November 20, 2015 Surely two clients aren't connected between each other (only through the server), so the problem could only be in the script, for example, where you somehow delete the variable from all clients and redefine it on a specific client. Link to comment
jingzhi Posted November 20, 2015 Author Share Posted November 20, 2015 Then it's very strange, this shouldn't be happening, here is the related scripts function engine_func() local veh = getPedOccupiedVehicle (localPlayer) local RPM = getVehicleRPM(veh) setElementData(veh,"RPM",RPM) if veh then if getVehicleEngineState (veh) == true then setSoundVolume(local_sound,1) setSoundSpeed(local_sound, RPM * 2.5 / 10000) else if getSoundVolume(local_sound) == 1 then setSoundVolume(local_sound,0) end end else destroyElement(local_sound) removeEventHandler("onClientRender",root,engine_func) end end addEventHandler ( "onClientVehicleEnter", getRootElement(), function() if getElementModel ( source ) == 411 then setWorldSoundEnabled(40,false) local x,y,z = getElementPosition(source) if vehicles[source] then vehicles[source] = nil end local_sound = playSound3D(engine_sound, x, y, z, true) setSoundVolume(local_sound,0) attachElements(local_sound,source) addEventHandler ( "onClientRender", getRootElement(), engine_func ) end end) addEventHandler ( "onClientVehicleExit", getRootElement(), function() if getElementModel(source) == 411 then setWorldSoundEnabled(40,true) destroyElement(local_sound) removeEventHandler ( "onClientRender", getRootElement(), engine_func ) end end) 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