Simbad de Zeeman Posted January 8, 2008 Share Posted January 8, 2008 hi, look at my code, my vehicles wont respawn when they die for theKey,theVehicle in getElementsByType ( "vehicle" ) do local rand1 = randInt(50,255) local rand2 = randInt(50,255) local rand3 = randInt(50,255) local rand4 = randInt(50,255) id = getVehicleID ( theVehicle ) setVehicleColor ( id, rand1, rand2, rand3, rand4 ) toggleVehicleRespawn ( id, true ) setVehicleRespawnDelay ( id, 5000 ) end the setvehiclecolor works, the cars will be colored randomly, but they aint respawning can someone help me with this? Link to comment
CJGrove Posted January 8, 2008 Share Posted January 8, 2008 (edited) Simbad ik denk niet dat je hier veel aan hebt maar heb je er wat aan ? function respawnVehicle( vehicle ) spawnVehicle ( vehicle, getElementData( vehicle, "posX" ), getElementData( vehicle, "posY" ), getElementData( vehicle, "posZ" ), getElementData( vehicle, "rotX" ), getElementData( vehicle, "rotY" ), getElementData( vehicle, "rotZ" ) ) end function onVehicleExplode () setTimer( respawnVehicle, 10000, 1, source ) end I will translate i'm sorry: Simbad i don't think you have something with this but is this something for you? Edited January 8, 2008 by Guest Link to comment
FireBlood Posted January 8, 2008 Share Posted January 8, 2008 Simbad aan mij zal je niet veel hebben ik ben niet zo snugger maar heb je hier wat aan? function respawnVehicle( vehicle ) spawnVehicle ( vehicle, getElementData( vehicle, "posX" ), getElementData( vehicle, "posY" ), getElementData( vehicle, "posZ" ), getElementData( vehicle, "rotX" ), getElementData( vehicle, "rotY" ), getElementData( vehicle, "rotZ" ) ) end function onVehicleExplode () setTimer( respawnVehicle, 10000, 1, source ) end eh, English? Link to comment
CJGrove Posted January 8, 2008 Share Posted January 8, 2008 Simbad aan mij zal je niet veel hebben ik ben niet zo snugger maar heb je hier wat aan? function respawnVehicle( vehicle ) spawnVehicle ( vehicle, getElementData( vehicle, "posX" ), getElementData( vehicle, "posY" ), getElementData( vehicle, "posZ" ), getElementData( vehicle, "rotX" ), getElementData( vehicle, "rotY" ), getElementData( vehicle, "rotZ" ) ) end function onVehicleExplode () setTimer( respawnVehicle, 10000, 1, source ) end eh, English? I'm sorry i will translate see my edit. Link to comment
Simbad de Zeeman Posted January 8, 2008 Author Share Posted January 8, 2008 That was not my question CJGrove, i want to know what was wrong with my code? why it didnt work.. Link to comment
Guest Posted January 8, 2008 Share Posted January 8, 2008 This should work. You should use the vehicle object to call the functions, not the model ID. getVehicleID() returns the model ID. And indentation is priceless, especially when you need others to understand it for theKey,theVehicle in getElementsByType ( "vehicle" ) do local rand1 = randInt(50,255) local rand2 = randInt(50,255) local rand3 = randInt(50,255) local rand4 = randInt(50,255) setVehicleColor ( theVehicle, rand1, rand2, rand3, rand4 ) toggleVehicleRespawn ( theVehicle, true ) setVehicleRespawnDelay ( theVehicle, 5000 ) end Link to comment
Simbad de Zeeman Posted January 8, 2008 Author Share Posted January 8, 2008 it still wont work Link to comment
Simbad de Zeeman Posted January 10, 2008 Author Share Posted January 10, 2008 and it still wont work in DP2 for theKey,theVehicle in getElementsByType ( "vehicle" ) do <---------- Line 95 toggleVehicleRespawn ( theVehicle, true ) setVehicleRespawnDelay ( theVehicle, 5000 ) end ERROR: attemt to call a table value Link to comment
Stevvo Posted January 10, 2008 Share Posted January 10, 2008 I think your code wont work because you are trying to use functions that do not exists, read this page to see functions that don't exist anymore: http://development.mtasa.com/index.php? ... epreciated Link to comment
Jumba' Posted January 10, 2008 Share Posted January 10, 2008 This should work. You should use the vehicle object to call the functions, not the model ID. getVehicleID() returns the model ID.And indentation is priceless, especially when you need others to understand it for theKey,theVehicle in getElementsByType ( "vehicle" ) do local rand1 = randInt(50,255) local rand2 = randInt(50,255) local rand3 = randInt(50,255) local rand4 = randInt(50,255) setVehicleColor ( theVehicle, rand1, rand2, rand3, rand4 ) toggleVehicleRespawn ( theVehicle, true ) setVehicleRespawnDelay ( theVehicle, 5000 ) end Uhm, this isn't really about the problem but rand1 is a random color right? but arent car colors codes between 0 and 126? or is it something else... (im just wondering) Link to comment
Guest Posted January 10, 2008 Share Posted January 10, 2008 I'm sorry, I usually only code for Garry's Mod, were all colors are using the 255 RGB scale, I didn't really know anything about the way MTA worked at the time, that could very well be the problem. Link to comment
Jumba' Posted January 10, 2008 Share Posted January 10, 2008 I'm sorry, I usually only code for Garry's Mod, were all colors are using the 255 RGB scale, I didn't really know anything about the way MTA worked at the time, that could very well be the problem. They do use te 255RGB scale, but i think vehicle colors are set by gta, but i dunno, here's the lsit tho = / http://development.mtasa.com/index.php? ... hicleColor Link to comment
ChrML Posted January 10, 2008 Share Posted January 10, 2008 Try this code local cars = getElementsByType ( "vehicle" ) for theKey,theVehicle in ipairs(cars) do local rand1 = randInt(0,126) local rand2 = randInt(0,126) local rand3 = randInt(0,126) local rand4 = randInt(0,126) setVehicleColor ( theVehicle, rand1, rand2, rand3, rand4 ) toggleVehicleRespawn ( theVehicle, true ) setVehicleRespawnDelay ( theVehicle, 5000 ) end Link to comment
Simbad de Zeeman Posted January 10, 2008 Author Share Posted January 10, 2008 Still no respawn after 5 seconds Link to comment
Jumba' Posted January 10, 2008 Share Posted January 10, 2008 er, maybe "for theKey,theVehicle in ipairs(cars) do" should be "for theKey, theVehicle in ipairs(cars) do" (space after comma). I dunno though, looks like it should work = / Link to comment
Simbad de Zeeman Posted January 10, 2008 Author Share Posted January 10, 2008 Ok i cleaned up my whole code now and its working, thanks for all who taked time to help me! its kevuwk's code which worked! 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