Kamtar Posted July 25, 2014 Share Posted July 25, 2014 (edited) Hello everyone ! I script for my french server but i have a little problem. I want that if a player enter on vehicle, all doors whether automatically closes. I have a bases, but i'm not very good on lua.. So, if u can say me a solution, thanks function enterVehicle ( player, seat, jacked ) local vehicle = getPedOccupiedVehicle ( player ) if vehicle then for i=0,5 do setVehicleDoorOpenRatio ( vehicle, i, 0 - getVehicleDoorOpenRatio ( vehicle, i ), 2500 ) end end end Edited July 26, 2014 by Guest Link to comment
Ab-47 Posted July 26, 2014 Share Posted July 26, 2014 Have you tried triggering your function? addEventHandler Link to comment
Kamtar Posted July 26, 2014 Author Share Posted July 26, 2014 I do not know my. Lua, so how should I do? Thank you. Link to comment
Max+ Posted July 26, 2014 Share Posted July 26, 2014 (edited) --- ServerSide addEventHandler ( 'onVehicleEnter', resourceRoot, function ( player ) local nVehicle = getPedOccupiedVehicle ( player ) if ( nVehicle ) then setVehicleLocked ( nVehicle, true ) outputChatBox ( ' Vehilce is Locked', player, 255, 255, 0 ) end end ) Edited July 26, 2014 by Guest Link to comment
Kamtar Posted July 26, 2014 Author Share Posted July 26, 2014 I have test ur code Max but it don't work for me.. Link to comment
Max+ Posted July 26, 2014 Share Posted July 26, 2014 I have test ur code Max but it don't work for me.. Try Now , i Edited my post , and make sure it's serverSide also /debugscript 3 to see if there is any errors post them here . Link to comment
Kamtar Posted July 26, 2014 Author Share Posted July 26, 2014 I don't want lock all door at car, just closed Link to comment
Max+ Posted July 27, 2014 Share Posted July 27, 2014 I don't want lock all door at car, just closed ؟ I want that if a player enter on vehicle, all doors whether automatically closes. You Said you want them to lock automatically . Link to comment
./BlackBird# Posted July 27, 2014 Share Posted July 27, 2014 addEventHandler ( 'onVehicleEnter', resourceRoot, function enterVehicle ( player ) local vehicle = getPedOccupiedVehicle ( player ) if vehicle then for i=0,5 do setVehicleDoorOpenRatio ( vehicle, i, 0, 2500 ) end end end ) Link to comment
Kamtar Posted July 27, 2014 Author Share Posted July 27, 2014 My bad Max, i just want all door is close, no lock. I have a script for lock, but i have a bug in my server: If player enter on car, the door right is automatically open. So i want, if player enter on car, all doors automatically close. Link to comment
Max+ Posted July 28, 2014 Share Posted July 28, 2014 Well , i tryed to make it work with the vehicles event from server / client but it didn't i think it's some kind of bug , but it worked with command type Max to open it , type max again to close it , you can add check if the doors open then close else / open --ClientSide addCommandHandler ( 'Max', function ( ) local vehicle = getPedOccupiedVehicle ( localPlayer ) if vehicle then for i=0,5 do setVehicleDoorOpenRatio ( vehicle, i, 1 - getVehicleDoorOpenRatio ( vehicle, i ), 2500 ) end end end ) or you cant try using addEvent('Something'), true ) addEventHandler('Something', root, function ( ) local vehicle = getPedOccupiedVehicle ( localPlayer ) if vehicle then for i=0,5 do setVehicleDoorOpenRatio ( vehicle, i, 1 - getVehicleDoorOpenRatio ( vehicle, i ), 2500 ) end end end ) and setTimer to trigger it triggerClientEvent ( 'Something', source, 'Somthing' ) Link to comment
AboShanab Posted July 28, 2014 Share Posted July 28, 2014 -- # Server Side ! addEventHandler ( "onVehicleEnter", root, function ( ) setTimer ( function ( vehicle ) for i = 0, 5 do setVehicleDoorOpenRatio ( vehicle, i, 0 - getVehicleDoorOpenRatio ( vehicle, i ), 2500 ) end end, 250, 1, source ) 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