#DaMiAnO Posted March 10, 2012 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)
Kenix Posted March 10, 2012 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
#DaMiAnO Posted March 10, 2012 Author 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.
Kenix Posted March 10, 2012 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 )
#DaMiAnO Posted March 10, 2012 Author Posted March 10, 2012 My bad, working - thanks. Last question, how is the name of function, when player entering to the vehicle?
Kenix Posted March 10, 2012 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
jeremaniak Posted March 11, 2012 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
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