nick1995 Posted May 8, 2012 Posted May 8, 2012 Hi, I have set many cars in the map. But in the gamemode, if a car exploded, how can i do that the car comes back at the spawn place? Regards, Nick
Jaysds1 Posted May 10, 2012 Posted May 10, 2012 It should be able to respawn in the same place after it explodes.. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Moderators IIYAMA Posted May 10, 2012 Moderators Posted May 10, 2012 I can help you. I am right now at school.... Afther school I will send you a script that can respawn these cars greets IIYAMA Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
nick1995 Posted May 10, 2012 Author Posted May 10, 2012 I can help you. I am right now at school....Afther school I will send you a script that can respawn these cars greets IIYAMA Thanks you! Thats great ;D
Moderators IIYAMA Posted May 10, 2012 Moderators Posted May 10, 2012 ---meta-- call this "meta.xml" <meta> <info author="NONE" description="respawn" version="1" type="script" /> <script src="respawn.lua" /> </meta> --server--call this "respawn.lua" function respawn() for i,vehicle in ipairs(getElementsByType("vehicle")) do toggleVehicleRespawn(vehicle, true) setVehicleRespawnDelay(vehicle, 20000) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), respawn) Put the meta and the server script inside a folder. > setVehicleRespawnDelay(vehicle, 20000) 20000 = 20 seconds for respawn. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
nick1995 Posted May 11, 2012 Author Posted May 11, 2012 ---meta-- call this "meta.xml" <meta> <info author="NONE" description="respawn" version="1" type="script" /> <script src="respawn.lua" /> </meta> --server--call this "respawn.lua" function respawn() for i,vehicle in ipairs(getElementsByType("vehicle")) do toggleVehicleRespawn(vehicle, true) setVehicleRespawnDelay(vehicle, 20000) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), respawn) Put the meta and the server script inside a folder. > setVehicleRespawnDelay(vehicle, 20000) 20000 = 20 seconds for respawn. Thanks for your reaction, but it doesn't work here. The car dont spawn back
Moderators IIYAMA Posted May 11, 2012 Moderators Posted May 11, 2012 ofcourse it works, when the vehicle has been destroyed. Do you know how to use a script? Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
nick1995 Posted May 11, 2012 Author Posted May 11, 2012 Yes, The first one you save us meta.xml The second one as respawn.lua You take it into a .zip file and in the resource folder. In the commando (if the server is running) you do "refresh" Then he said, new resource added: "carspawn" Then you do the command "start carspawn" He said, "Carspawn started" Then i destroy a vehicle in the gameplay, (with my weapon i blow the vehicle up) And he doesn't spawn back? Sorry for my bad english (:
Jaysds1 Posted May 11, 2012 Posted May 11, 2012 try this: addEventHandler("onVehicleExplode",root,function() toggleVehicleRespawn(source, true) setVehicleRespawnDelay(source, 10000) -- Respawn it in 10 seconds end) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Moderators IIYAMA Posted May 11, 2012 Moderators Posted May 11, 2012 well for me my script just works fine afther 20 seconds. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Jaysds1 Posted May 11, 2012 Posted May 11, 2012 well for me my script just works fine afther 20 seconds. Ya, but it seems like he wants it for when the vehicle just explode... Not sure My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
nick1995 Posted May 11, 2012 Author Posted May 11, 2012 Thanks for your reaction! But it doesn't work
Jaysds1 Posted May 11, 2012 Posted May 11, 2012 Wait, Is the vehicle created with the map or did you spawned it? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Moderators IIYAMA Posted May 11, 2012 Moderators Posted May 11, 2012 If your script also does not work, it means that you made a mistake with putting the script inside your folder and start it. You started the script? YES folder or .zip > meta and script. NO .zip > folder > meta and script Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
mjr Posted May 11, 2012 Posted May 11, 2012 same troule with me. vehicles are defined in .map file i must learn not to be an asshole
Jaysds1 Posted May 11, 2012 Posted May 11, 2012 ok, first of all, If you make a map in map editor, and saved it then it would make a resource... after all of that, you should edit the meta.xml and add ="server.lua" type="server" /> then make another file and call it "server.lua", in this file put this: addEventHandler("onVehicleExplode",root,function() toggleVehicleRespawn(source, true) setVehicleRespawnDelay(source, 10000) -- Respawn it in 10 seconds end) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
mjr Posted May 11, 2012 Posted May 11, 2012 to Jaysds1, i mean my code function onStart() -- car spawn for i, v in ipairs (getElementsByType("vehicle")) do toggleVehicleRespawn(v, true) setVehicleRespawnDelay(v, 5000) setVehicleIdleRespawnDelay(v, 5000) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart) doesn't work. Vehicles aren't respawning. ps. onVehicleExplode event triggers only when car is wrecked. i need respawn not only on wreck, but also idle i must learn not to be an asshole
Moderators IIYAMA Posted May 11, 2012 Moderators Posted May 11, 2012 Man you so..... that I have to upload my script. You guys get it from here... the same script I write down on this topic. This one works other you are failing so badly to manage your scripts... 20 seconds for respawn. http://www.2shared.com/file/O1iauaZe/re ... hicle.html Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
nick1995 Posted May 11, 2012 Author Posted May 11, 2012 It works! The resource "carvehiclesystemshops" cant handle with this...
mjr Posted May 12, 2012 Posted May 12, 2012 to IIYAMA, can you just write where's the problem? why single resource is working, but integrating the code to my main .lua file gives no result? edited: okay, i got it. when main resource starts, vehicles need time to spawn and the "vehicle" element table is just EMPTY, so the fucntions apply to no elements. setting timer solves this problem. function onStart() -- car spawn setTimer (function() for i, v in ipairs (getElementsByType("vehicle")) do toggleVehicleRespawn(v, true) setVehicleRespawnDelay(v, 5000) setVehicleIdleRespawnDelay(v, 5000) end end, 1000,1) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart) i must learn not to be an asshole
Moderators IIYAMA Posted May 12, 2012 Moderators Posted May 12, 2012 to IIYAMA, can you just write where's the problem? why single resource is working, but integrating the code to my main .lua file gives no result? Well it means the one that integrading this code did something wrong, because the code is the same... I have to remind you to use debugscript for checking the folder you put it in. I haven't seen in your reaction what whent wrong with it. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
mjr Posted May 12, 2012 Posted May 12, 2012 okay, okay, great programming guru, i'll remember your super smart advice! i must learn not to be an asshole
Moderators IIYAMA Posted May 12, 2012 Moderators Posted May 12, 2012 I am not a pro scripter, I am more a beginner/normal. But debugscript is a very handy tool. 1. give your self andmin. 2. write "/debug 3" for understanding all the trouble in the server. (wiki) debug * 0: Custom message 1: Error message 2: Warning message 3: Information message (default) It is also handy for testing scripts, you can use outputDebugString inside your scripts. Put it in a line that needs to be checked and call your string like that. https://wiki.multitheftauto.com/wiki/OutputDebugString Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
mjr Posted May 13, 2012 Posted May 13, 2012 of course, you made my scripting experience! probably, i'd never read this on wiki i must learn not to be an asshole
Jaysds1 Posted May 13, 2012 Posted May 13, 2012 ok,ok,ok, Is everything solved here? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
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