#DaMiAnO Posted March 10, 2012 Share Posted March 10, 2012 Hi! I have this: That's working, but when anyone dies, it not spawn him, and i see error in debugscript. local randomSpawnTable = { { -2818.3391, 1134.4768, 26.1129, 179.2400 }, { 2021.3114, 1344.1099, 10.8203, 269.5800 }, { 2221.3726, 1838.4792, 10.8203, 90.3700 } } function randomSpawn(thePlayer, randomSpawnTable) local random = math.random(1, #randomSpawnTable) spawnPlayer(thePlayer, randomSpawnTable[random][1], randomSpawnTable[random][2], randomSpawnTable[random][3], randomSpawnTable[random][4]) end function onPlayerJoin() fadeCamera(source, true) setCameraTarget(source, source) randomSpawn(source, randomSpawnTable) end addEventHandler("onPlayerJoin", g_root, onPlayerJoin) function onPlayerDeath() fadeCamera (source, false, 1.0, 255, 0, 0) setTimer(randomSpawn, 3000, 1, source) setTimer(fadeCamera, 2500, 1, source, true, 0.5) end addEventHandler("onPlayerWasted", g_root, onPlayerDeath) attempt to get length of local 'randomSpawnTable' (a nil value) Link to comment
Kenix Posted March 10, 2012 Share Posted March 10, 2012 (edited) local randomSpawnTable = { { -2818.3391, 1134.4768, 26.1129, 179.2400 }, { 2021.3114, 1344.1099, 10.8203, 269.5800 }, { 2221.3726, 1838.4792, 10.8203, 90.3700 } } function randomSpawn( thePlayer, randomSpawnTable ) local random = math.random( 1, #randomSpawnTable ) spawnPlayer( thePlayer, randomSpawnTable[random][1], randomSpawnTable[random][2], randomSpawnTable[random][3], randomSpawnTable[random][4] ) end function onPlayerJoin( ) fadeCamera( source, true ) setCameraTarget( source, source ) randomSpawn( source, randomSpawnTable ) end addEventHandler( "onPlayerJoin",root, onPlayerJoin ) function onPlayerDeath( ) fadeCamera ( source, false, 1.0, 255, 0, 0 ) setTimer( randomSpawn, 3000, 1, source,randomSpawnTable ) setTimer( fadeCamera, 2500, 1, source, true, 0.5 ) end addEventHandler( "onPlayerWasted", root, onPlayerDeath ) Edited March 10, 2012 by Guest Link to comment
#DaMiAnO Posted March 10, 2012 Author Share Posted March 10, 2012 local randomSpawnTable = { { -2818.3391, 1134.4768, 26.1129, 179.2400 }, { 2021.3114, 1344.1099, 10.8203, 269.5800 }, { 2221.3726, 1838.4792, 10.8203, 90.3700 } } function randomSpawn( thePlayer ) local random = math.random( #randomSpawnTable ) spawnPlayer( thePlayer, randomSpawnTable[random][1], randomSpawnTable[random][2], randomSpawnTable[random][3], randomSpawnTable[random][4] ) end function onPlayerJoin( ) fadeCamera( source, true ) setCameraTarget( source, source ) randomSpawn( source ) end addEventHandler( "onPlayerJoin", root, onPlayerJoin ) function onPlayerDeath( ) fadeCamera ( source, false, 1.0, 255, 0, 0 ) setTimer( randomSpawn, 3000, 1, source ) setTimer( fadeCamera, 2500, 1, source, true, 0.5 ) end addEventHandler( "onPlayerWasted", root, onPlayerDeath ) Not working. Link to comment
Kenix Posted March 10, 2012 Share Posted March 10, 2012 It working, i test it now. Also i forgot say problem. You problem in 28 line setTimer( randomSpawn, 3000, 1, source ) You forgot call table. setTimer( randomSpawn, 3000, 1, source,randomSpawnTable ) Correct. Full correct code local randomSpawnTable = { { -2818.3391, 1134.4768, 26.1129, 179.2400 }, { 2021.3114, 1344.1099, 10.8203, 269.5800 }, { 2221.3726, 1838.4792, 10.8203, 90.3700 } } function randomSpawn( thePlayer, randomSpawnTable ) local random = math.random( 1, #randomSpawnTable ) spawnPlayer( thePlayer, randomSpawnTable[random][1], randomSpawnTable[random][2], randomSpawnTable[random][3], randomSpawnTable[random][4] ) end function onPlayerJoin( ) fadeCamera( source, true ) setCameraTarget( source, source ) randomSpawn( source, randomSpawnTable ) end addEventHandler( "onPlayerJoin",root, onPlayerJoin ) function onPlayerDeath( ) fadeCamera ( source, false, 1.0, 255, 0, 0 ) setTimer( randomSpawn, 3000, 1, source,randomSpawnTable ) setTimer( fadeCamera, 2500, 1, source, true, 0.5 ) end addEventHandler( "onPlayerWasted", root, onPlayerDeath ) Link to comment
#DaMiAnO Posted March 10, 2012 Author Share Posted March 10, 2012 My bad, working - thanks. Last question, how is the name of function, when player entering to the vehicle? Link to comment
Kenix Posted March 10, 2012 Share Posted March 10, 2012 No problem. Last question, how is the name of function, when player entering to the vehicle? It's not function, it's event. https://wiki.multitheftauto.com/wiki/OnVehicleStartEnter https://wiki.multitheftauto.com/wiki/OnVehicleEnter Link to comment
#DaMiAnO Posted March 10, 2012 Author Share Posted March 10, 2012 Big ty! Can be closed (topic). Link to comment
jeremaniak Posted March 11, 2012 Share Posted March 11, 2012 If you use the resource play you could also search the coordinats by /getpos and then add it in the file brophy under it 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