• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

table issue

cbrm

Retired scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,599
Solutions
3
Reaction score
972
Location
Caribbean Sea
LUA:
    getOutfit = function (points)
        local ID = {[-5000] = {outfit = {lookType = 40}, msg = 'Devil!!'},
                    [-2000] = {outfit = {lookType = 60}, msg = 'Pig!!'},
                    [-1500] = {outfit = {lookType = 5}, msg = 'Orc!!'},
                    [1500] = {outfit = {lookType = 73}, msg = 'Hero!!'},
                    [2000] = {outfit = {lookType = 266}, msg = 'Legend!!'},
                    [5000] = {outfit = {lookType = 331}, msg = 'Queen!!'},
                    }
        if points > -1 then
            table.sort(ID, function(a, b) return a[1] > b[1] end)
            for _, t in ipairs(ID) do if points >= t[1] then return t[1] end end
        else
            table.sort(ID, function(a, b) return a[1] < b[1] end)
            for _, t in ipairs(ID) do if points <= t[1] then return t[1] end end
        end        
    return ID[points]
    end,

This function fixed by Colandus and me returns a table with values. The problem is that it only works fine for e.g. when player has 2000 points, but if he has 2001 until 4999 then it won't work, as it should do:confused:
:)this is how the table should work
from (<-5000)-[SIZE=+1]∞[/SIZE] to -5000
from -4999 to -2000
from -1999 to -1500
-----------------------
from 1500 to 1999
from 2000 to 4999
from 5000 to [SIZE=+1]∞[/SIZE](>5000)

any halp?:(
 
Code:
	getOutfit = function(points)
		local ID = {
			[{-2147483648, -5000}] = {outfit = {lookType = 40}, msg = 'Devil!!'},
			[{-4999, -2000}] = {outfit = {lookType = 60}, msg = 'Pig!!'},
			[{-1999, -1500}] = {outfit = {lookType = 5}, msg = 'Orc!!'},
			[{1500, 1999}] = {outfit = {lookType = 73}, msg = 'Hero!!'},
			[{2000, 4999}] = {outfit = {lookType = 266}, msg = 'Legend!!'},
			[{5000, 2147483648}] = {outfit = {lookType = 331}, msg = 'Queen!!'},
		}
		for r, v in pairs(ID) do
			if points >= r[1] and points <= r[2] then
				return v
			end
		end
	end,
 
Back
Top