xeon17 Posted June 26, 2014 Share Posted June 26, 2014 (edited) I wanted to create a script that respawn vehicles when they explode , and that respawn when are unused i mean. If 2 minutes nobody use the car , should respawn. function before (vehicle) if_used = getPedOccupiedVehicle (vehicle) if ( if_used ) then outputChatBox("",vehicle,255,255,255,true) else respawnVehicle ( vehicle ) end end function respawnMoveVehicle() setTimer(before, 100000, 1, source) end addEventHandler("onVehicleExit", getRootElement(), respawnMoveVehicle) function respawnExplodedVehicle() setTimer(respawnVehicle, 5000, 1, source) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) The part with un-used vehicles no work , bug on line 2 > bad ''ped'' pointer Edited June 26, 2014 by Guest Link to comment
Dealman Posted June 26, 2014 Share Posted June 26, 2014 Source of onVehicleExit is the vehicle, not the player. A vehicle is not a player/ped. Link to comment
xeon17 Posted June 26, 2014 Author Share Posted June 26, 2014 I edited the code , the code should work now? Link to comment
xeon17 Posted June 26, 2014 Author Share Posted June 26, 2014 I tested the code no work. Link to comment
PaulDK Posted June 27, 2014 Share Posted June 27, 2014 I wanted to create a script that respawn vehicles when they explode , and that respawn when are unused i mean.If 2 minutes nobody use the car , should respawn. function before (vehicle) if_used = getPedOccupiedVehicle (vehicle) if ( if_used ) then outputChatBox("",vehicle,255,255,255,true) else respawnVehicle ( vehicle ) end end function respawnMoveVehicle() setTimer(before, 100000, 1, source) end addEventHandler("onVehicleExit", getRootElement(), respawnMoveVehicle) function respawnExplodedVehicle() setTimer(respawnVehicle, 5000, 1, source) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) The part with un-used vehicles no work , bug on line 2 > bad ''ped'' pointer function before (vehicle,thePlayer) if_used = isPedInVehicle (thePlayer) if ( if_used ) then outputChatBox("",vehicle,255,255,255,true) else respawnVehicle ( vehicle ) end end function respawnMoveVehicle() setTimer(before, 100000, 1, source) end addEventHandler("onVehicleExit", getRootElement(), respawnMoveVehicle) function respawnExplodedVehicle() setTimer(respawnVehicle, 5000, 1, source) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle Link to comment
Dealman Posted June 27, 2014 Share Posted June 27, 2014 getPedOccupiedVehicle requires a player element, not a vehicle element. Read about the functions your script is using, and read about how they work - and what they return. Link to comment
_DrXenon Posted June 29, 2014 Share Posted June 29, 2014 Well, for f,v in ipairs(getElementsByType("vehicle"))do Then check if all seats are empty with: getVehicleOccupant(v, seat number) If all seats are empty (false) Then respawnVehicle(v) Link to comment
Et-win Posted June 29, 2014 Share Posted June 29, 2014 (edited) function before (tVehicle) if_used = getVehicleOccupant(tVehicle) if ( if_used ) then outputChatBox("",vehicle,255,255,255,true) else respawnVehicle ( tVehicle) end end function respawnMoveVehicle() setTimer(before, 100000, 1, source) end addEventHandler("onVehicleExit", getRootElement(), respawnMoveVehicle) function respawnExplodedVehicle() setTimer(respawnVehicle, 5000, 1, source) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) Changed 'getPedOccupiedVehicle' to 'getVehicleOccupant' Edited June 29, 2014 by Guest Link to comment
Et-win Posted June 29, 2014 Share Posted June 29, 2014 Edited my post, last one was wrong 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