Jump to content

Tables


Tonyx97

Recommended Posts

Hola a todos, me he decidido entender sobre las tables, yo sabia mucho sobres scripting y tal pero ya es hora de que empieze a saber cosas nuevas sobre esto, me gustaria saber como funcionan las tables, table.insert, table.sort etc... He buscado pero en ningun sitio entiendo muy bien, No pido que me hagan un ejemplo (Me vendria muy bien) solo una breve explicacion de como funciona y tal y yo intentare hacer algo, lo que me gustaria hacer con las tables, es por ejemplo un TOP de algo, por ejemplo de kills en un cierto tiempo, pero no se como hacerlo, si ustedes me explican un poco de como va esto, yo intentare hacer algo, gracias por leer.

Link to comment

Intente algo, pero se que esta mal, se supone que cuando pones /plus se pone en la tabla tu nombre con el number de veces que has puesto /plus y detecta que en 1 minuto muestre en el chat el jugador que mas veces lo puso, se que esta mal, pero no entiendo nada, perdonen si parezco tonto al no entender esto pero no es mi culpa... yo lo intento comprender. Miren es una locura...

tablePlayers = {} 
changePlayer = 0 
  
function addPoint(thePlayer) 
    setElementData (thePlayer,"n",1) 
    table.insert (tablePlayers, #changePlayer + 1, getPlayerName(thePlayer), getElementData (thePlayer,"n") + 1) 
end 
addCommandHandler ("plus", addPoint) 
  
function stop () 
    outputChatBox ("The winner player is "..(#changePlayer,getPlayerName(thePlayer)).."!", getRootElement(), 0, 255, 0) 
end 
setTimer (stop,60000,1) 

Link to comment

Tienes muchisimos errores mas allá de las tablas.

  
tablePlayers = {} 
changePlayer = 0 
  
function addPoint(thePlayer) 
    setElementData (thePlayer,"n",1) --Esto sera siempre uno, por consiguiente el de abajo siempre sera 2. 
    table.insert (tablePlayers, #changePlayer + 1, getPlayerName(thePlayer), getElementData (thePlayer,"n") + 1) --Pones un argumento de mas, tambien siempre lo pondrá primero por que changePlayer es 0 y en caso de que eso busques, # esta de mas. 
end 
addCommandHandler ("plus", addPoint) 
  
function stop () 
    outputChatBox ("The winner player is "..(#changePlayer,getPlayerName(thePlayer)).."!", getRootElement(), 0, 255, 0) --Ese concanate no tiene sentido y changePlayer ya es un numero, no hay un tamaño (lenght) que conseguir, aparte de que esto no consigue al jugador con mas 'plus' y 'thePlayer' no esta definido. 
end 
setTimer (stop,60000,1) 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...