Posted 22 September 2013 - 01:16 PM
local list = {}
function setTable(...)
local arguments = {select(1,...)}
local player = arguments[1]
if table.getn(arguments)==1 then
list[player]={}
list[player]["player"] = arguments[1]
list[player]["deaths"] = 0
list[player]["kills"] = 0
list[player]["logins"] = 0
list[player]["messages"] = 0
list[player]["average"] = 0
elseif table.getn(arguments)==6 then
list[player]={}
list[player]["player"] = arguments[1]
list[player]["deaths"] = arguments[2]
list[player]["kills"] = arguments[3]
list[player]["logins"] = arguments[4]
list[player]["messages"] = arguments[5]
list[player]["average"] = arguments[6]
else
print("Error: Wrong parameter passed to 'setTable'!")
end
print("Player " ..arguments[1].. " successfully created.")
end
Well a while ago I asked about a similar problem already, but I still have problems with it and didn't want to post in a dead thread, so..
I have this array shown in the code above. Multiple players and their data are stored in there. Now I would like to be able to sort this array, sort by names, sort by kills etc.. I know there's table.sort() but i don't know if it's possible to use with more than one dimension and if so, how to write it exactly. I'm really having trouble with this :(/>
Thanks in advance,to everybody :)/>