ManeXi Posted June 17, 2015 Share Posted June 17, 2015 (edited) I would like to know the script to make a empty vehicle respawn, the conditions are that the vehicle should be empty during 60 seconds (60000 ms) this is the actual script i use to respawn exploted vehicles: function respawnexploredcrs() setTimer(respawnVehicle,15000,1,source) end addEventHandler("onVehicleExplode", getRootElement(), respawnexploredcrs) Edited June 30, 2015 by Guest Link to comment
Ab-47 Posted June 17, 2015 Share Posted June 17, 2015 Create a loop to get all vehicles, use the loop to define whether any seat within such vehicle has been taken or not, then initiate the respawn, with setElementPosition or whatever you want. Then for the function handler, use the timer to handle it. Link to comment
The_Walrus Posted June 17, 2015 Share Posted June 17, 2015 Use this function: setVehicleIdleRespawnDelay(vehicle theVehicle, int timeDelay) Check the syntax on wiki for more details, this will respawn any vehicle that has been idle for the amount of time you set, apply it after the vehicle is created or in a loop upon start if all vehicles on your server is constant. Important Note: toggleVehicleRespawn must be set to true for this function to have any effect Link to comment
ManeXi Posted June 18, 2015 Author Share Posted June 18, 2015 Use this function: setVehicleIdleRespawnDelay(vehicle theVehicle, int timeDelay) Check the syntax on wiki for more details, this will respawn any vehicle that has been idle for the amount of time you set, apply it after the vehicle is created or in a loop upon start if all vehicles on your server is constant. Important Note: toggleVehicleRespawn must be set to true for this function to have any effect It works, but, how can i add various vehicles for example this vehicles: ( 400, 1552.552734375, -1624.3525390625, 13.3828125 ) ( 400, 1577.2568359375, -1612.421875, 13.3828125 ) Link to comment
The_Walrus Posted June 18, 2015 Share Posted June 18, 2015 (edited) local veh = { { 400, 1552.552734375, -1624.3525390625, 13.3828125 }, { 400, 1577.2568359375, -1612.421875, 13.3828125 }, } for k,v in pairs(veh) do local new_veh = createVehicle(v[1],v[2],v[3],v[4]) toggleVehicleRespawn(new_veh, true) setVehicleIdleRespawnDelay(new_veh, 60*1000) end Like that for instance, all vehicles in the table "veh" will spawn upon load and get instructions to re-spawn after 60 seconds when idle after used. It should be able to handle a large amount of vehicles without using any noticeable amount of system resources. Edited June 19, 2015 by Guest Link to comment
Anubhav Posted June 18, 2015 Share Posted June 18, 2015 Well 60*1000 = 60,000 = 60 seconds Not 60*100.. 60*100 = 6000 = 6 seconds. It's in ms.. You should edit your post asap. Link to comment
The_Walrus Posted June 19, 2015 Share Posted June 19, 2015 I hope people are smart enough to understand how to multiply the right amount of seconds for their needs, despite a few mistakes in my post. Thanks for noticing it @Anubhav. I better find a proper keyboard without slow keys. Link to comment
ManeXi Posted June 25, 2015 Author Share Posted June 25, 2015 It's working but now i've got another problem, how to set vehicle color with createVehicle or Is there any way to choose all the vehicles of .map file, instead of setting all them manually? Link to comment
The_Walrus Posted June 28, 2015 Share Posted June 28, 2015 Use this to obtain a table containing all vehicles created by a certain resource, (preferable the resource containing your map file with all the vehicles): local all_vehicles_in_resource = getElementsByType("vehicle", resourceRoot) Link to comment
ManeXi Posted June 28, 2015 Author Share Posted June 28, 2015 Thank you much walrus for efforing in helping me but i still not get succesful If you could do it for me with this conditions: The resource containing vehicles will be known as "VehMap"Respawn each 10000 Really if you do it, i will thank you much. If you want i can make you any 3D model with Autodesk 3ds max(preferable for GTA San Andreas). Link to comment
The_Walrus Posted June 29, 2015 Share Posted June 29, 2015 I already got something similar on my "todo" list which you can follow here: http://forum.gtw-games.org/mta-servers-development/parked-vehicles/, the result will be available on Github when it's finished. SCRUM (development method) is used so I have no idea how much time it takes to finish, it's still a simple job to put all these pieces together so I recommend you to try for yourself. Link to comment
ManeXi Posted June 29, 2015 Author Share Posted June 29, 2015 Anyway there is something i don't understand what i have to put in the second argument of getElementsByType? [ element startat=getRootElement() ] I don't get it... Link to comment
ManeXi Posted June 30, 2015 Author Share Posted June 30, 2015 Finally i get it, i've put map file in the same resource of script file, and used this code: for _ , vehicles in ipairs ( getElementsByType ("vehicle"), resourceRoot) do toggleVehicleRespawn(vehicles, true) setVehicleIdleRespawnDelay(vehicles, 10000) end And it works perfectly thank you much for helping Walrus #Solved 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