#Dv^ Posted September 23, 2016 Posted September 23, 2016 (edited) Hola, ¿Se puede hacer que un player al escribir /ir vaya a cierta posición pero por orden? Es decir que el primero en escribir /ir vaya la posición 1 y el segundo en escribir /ir vaya a la posición 2 y así, pero mediante una tabla local posiciones = { { 48, 2564, 208 }, { 61, 2471, 211 }, { 138, 2496, 202}, { 104, 2549, 204 }, { 81, 2502, 208 }, { 105, 2531, 208 }, } local players = { } function consoleSetPlayerPosition ( thePlayer ) local azar = math.random ( #posiciones ) setElementPosition ( thePlayer, unpack ( posiciones [ azar ] ) ) table.insert(players,thePlayer) outputChatBox(""..getPlayerName(thePlayer).." #FFFFFFse ha unido a la partida",root, 255,255,255,true) end addCommandHandler ( "ir", consoleSetPlayerPosition ) Lo hice al azar pero quiero hacer que sea por orden,¿Qué debo usar? Edited September 23, 2016 by Slash14
Tomas Posted September 23, 2016 Posted September 23, 2016 local posiciones = { { 48, 2564, 208 }, { 61, 2471, 211 }, { 138, 2496, 202}, { 104, 2549, 204 }, { 81, 2502, 208 }, { 105, 2531, 208 }, } local players = { } local spawn = { } function consoleSetPlayerPosition ( thePlayer ) local cspawn = spawn[ thePlayer ] or 1 spawn[ thePlayer ] = ( cspawn + 1 > #posiciones and 1 or cspawn + 1 ) setElementPosition ( thePlayer, unpack ( cspawn [ azar ] ) ) table.insert(players,thePlayer) outputChatBox(""..getPlayerName(thePlayer).." #FFFFFFse ha unido a la partida",root, 255,255,255,true) end addCommandHandler ( "ir", consoleSetPlayerPosition )
Recommended Posts