pa3ck Posted October 11, 2013 Share Posted October 11, 2013 Good evening folks, I found a problem / bug in my script which is the following: If I'm using the function alone, its working well, no problem, but if 2 clients use it at the same time then it will get buggy. Sometimes it wont switch on sometimes its just blinks... Here is the code I was using: --Client function lights() local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then triggerServerEvent('lightS', getRootElement(), veh) end end addEventHandler('onClientVehicleEnter',getRootElement(),function() bindKey( 'l', 'down', lights ) end ) --Server addEvent('lightS', true) addEventHandler('lightS', root, function( veh ) if ( getVehicleOverrideLights(veh) ~= 2 ) then setVehicleOverrideLights(veh, 2) elseif ( getVehicleOverrideLights(veh) == 2) then setVehicleOverrideLights(veh, 1) end end ) Any idea / solutions? Link to comment
myonlake Posted October 11, 2013 Share Posted October 11, 2013 On triggerServerEvent switch getRootElement() to localPlayer. I also suggest using onClientPlayerVehicleEnter instead of onClientVehicleEnter, because the latter's source is a vehicle and the other's one is the local player - might have something to do with it. Link to comment
pa3ck Posted October 11, 2013 Author Share Posted October 11, 2013 I'm such a noob! Thanks a mill man! It's not the first time you helped me ( would not bet if it was the last tho ), I really appreciate it! 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