xeon17 Posted June 26, 2014 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 A unique GangWar gamemode waiting for you!Click here for more information.
Dealman Posted June 26, 2014 Posted June 26, 2014 Source of onVehicleExit is the vehicle, not the player. A vehicle is not a player/ped. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
xeon17 Posted June 26, 2014 Author Posted June 26, 2014 I edited the code , the code should work now? A unique GangWar gamemode waiting for you!Click here for more information.
xeon17 Posted June 26, 2014 Author Posted June 26, 2014 I tested the code no work. A unique GangWar gamemode waiting for you!Click here for more information.
PaulDK Posted June 27, 2014 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
Dealman Posted June 27, 2014 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. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
xeon17 Posted June 29, 2014 Author Posted June 29, 2014 No work.. A unique GangWar gamemode waiting for you!Click here for more information.
_DrXenon Posted June 29, 2014 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) ●●● Rage Gaming Society Coming Soon ●●●
Et-win Posted June 29, 2014 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 ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Et-win Posted June 29, 2014 Posted June 29, 2014 Edited my post, last one was wrong ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
xeon17 Posted June 29, 2014 Author Posted June 29, 2014 Working good , thanks A unique GangWar gamemode waiting for you!Click here for more information.
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