Sasu Posted August 19, 2013 Posted August 19, 2013 Server: function getPlayerKillsInOrder() theTable = {} for i, acc in ipairs(getAccounts()) do local name = getAccountName(acc) local kills = getAccountData(acc, "kills") or 0 table.insert(theTable, {kills, name}) end table.sort(theTable) return theTable end addEvent("refreshList", true) addEventHandler("refreshList", root, function() triggerClientEvent(source, "onRequestRefresh", source, getPlayerKillsInOrder()) theTable = nil end) Client: addEvent("onRequestRefresh", true) addEventHandler("onRequestRefresh", root, function(theTable) guiGridListClear(GUIEditor.gridlist[1]) for i, v in ipairs(theTable) do local row = guiGridListAddRow(GUIEditor.gridlist[1]) guiGridListSetItemText(GUIEditor.gridlist[1], row, 1, tostring(i), false, false) guiGridListSetItemText(GUIEditor.gridlist[1], row, 2, tostring(v[2]), false, false) guiGridListSetItemText(GUIEditor.gridlist[1], row, 3, tostring(v[1]), false, false) end end) Why the debugscript says: ERROR: attempt to compare two table values ?
TAPL Posted August 19, 2013 Posted August 19, 2013 Change this table.sort(theTable) to table.sort(theTable, function(a,b) return a[1] > b[1] end)
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