S.Eagle Posted November 29, 2009 Posted November 29, 2009 I've been searching, but could't find anything. So here's my what I have: I've placed a vehicle. <vehicle id="VehicleS1" paintjob="3" model="411" plate="S EAGLE" interior="0" dimension="0" color="3,126,0,0" posX="1512.2879638672" posY="-1473.4406738281" posZ="12.349999427795" rotX="0" rotY="0" rotZ="246.13220214844" upgrades="1008,1080" /> But how can I make it respawn? I know how to make vehicles respawn that are created using the createVehicle lua function, but not vehicles that are created with the Map Editor. Thanks in advance. S
zorrigas Posted November 29, 2009 Posted November 29, 2009 https://wiki.multitheftauto.com/wiki/CreateVehicle https://wiki.multitheftauto.com/wiki/Tog ... cleRespawn
subenji99 Posted November 30, 2009 Posted November 30, 2009 Extended from mapmanager example: function loadMap(startedMap) mapRoot = getResourceRootElement(startedMap) local mapVehicles = getElementsByType ( "vehicle", mapRoot ) --start at Map Root Element, we're not interested in other vehicles possibly existing for _, veh in pairs ( mapVehicles ) do toggleVehicleRespawn ( veh, true ) setVehicleRespawnDelay ( veh, 30000 ) --delay in milliseconds, this is 30 seconds end end addEventHandler("onGamemodeMapStart", getRootElement(), loadMap)
S.Eagle Posted November 30, 2009 Author Posted November 30, 2009 Extended from mapmanager example: function loadMap(startedMap) mapRoot = getResourceRootElement(startedMap) local mapVehicles = getElementsByType ( "vehicle", mapRoot ) --start at Map Root Element, we're not interested in other vehicles possibly existing for _, veh in pairs ( mapVehicles ) do toggleVehicleRespawn ( veh, true ) setVehicleRespawnDelay ( veh, 30000 ) --delay in milliseconds, this is 30 seconds end end addEventHandler("onGamemodeMapStart", getRootElement(), loadMap) Something is not working yet. Is there anything I should change that I am not seeing?
50p Posted November 30, 2009 Posted November 30, 2009 Extended from mapmanager example: function loadMap(startedMap) mapRoot = getResourceRootElement(startedMap) local mapVehicles = getElementsByType ( "vehicle", mapRoot ) --start at Map Root Element, we're not interested in other vehicles possibly existing for _, veh in pairs ( mapVehicles ) do toggleVehicleRespawn ( veh, true ) setVehicleRespawnDelay ( veh, 30000 ) --delay in milliseconds, this is 30 seconds end end addEventHandler("onGamemodeMapStart", getRootElement(), loadMap) Either toggleVehicleRespawn or setVehicleRespawnDelay doesn't work properly. The best way to respawn vehicle after it explodes is to set a timer which will respawn the vehicle in onVehicleExplode event. https://wiki.multitheftauto.com/wiki/RespawnVehicle (the example shows exactly what I described)
S.Eagle Posted December 3, 2009 Author Posted December 3, 2009 It worked. But it also respawns vehicles that do not belong to the map.
Taalasmaa Posted December 4, 2009 Posted December 4, 2009 addEventHandler( "onVehicleExplode", getRootElement( ), function( ) local parent = getElementParent( source ) if getElementType( parent ) == "map" and getElementID( parent ) ~= "dynamic" then local parentRes = getElementParent( parent ) if parentRes == getResourceRootElement( getThisResource( ) ) then setTimer( respawnVehicle, 5000, 1, source ) else setTimer( destroyElement, 5000, 1, source ) end else setTimer( destroyElement, 5000, 1, source ) end end ) THIS IS NOT WRITTEN BY ME! This is 50p's script and all credits for him. I found this from one topic (cant remember/find) But this is anyway scripted by 50p's It's anyway fully working, dunno why 50p didn't put this into this topic?
50p Posted December 4, 2009 Posted December 4, 2009 ....It's anyway fully working, dunno why 50p didn't put this into this topic? Because there are people like you who know how to use "Search" feature! lol
Taalasmaa Posted December 4, 2009 Posted December 4, 2009 ....It's anyway fully working, dunno why 50p didn't put this into this topic? Because there are people like you who know how to use "Search" feature! lol Well, I'm not even using this script in my servers. I just found it something like half year ago... EDIT: I know you hate me, because EUHM... I was stupid, I'm now learned much about lua, just forget those old times.
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