• 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!

TFS 1.X+ From number to number

anderkrox

New Member
Joined
May 14, 2020
Messages
21
Reaction score
1
How is the function to check it?
Lua:
example = {
    [Jhon] = {fromNumber = 1, toNumber = 10},
    [Hanna] = {fromNumber = 11, toNumber = 15},
}

Return Jhon if storage is 1, or 2, or 3, ... or 10;
... else,
return Hanna if storage is 11, or 12, or 13, or 14, or 15.
 
Solution
How is the function to check it?
Lua:
example = {
    [Jhon] = {fromNumber = 1, toNumber = 10},
    [Hanna] = {fromNumber = 11, toNumber = 15},
}

Return Jhon if storage is 1, or 2, or 3, ... or 10;
... else,
return Hanna if storage is 11, or 12, or 13, or 14, or 15.
[Jhon] is reference for a variable Jhon. You have to use Quotes to "Jhon" be a string.
You can do:

Lua:
local myTable = {
    ["Jhon"] = {start = 1, end = 10},
    ["Marie"] = {start = 11, end = 20},
    ["Hanna"] = {start = 21, end = 30},
}

function returnMyName(player)
    local myStorageValue = player:getStorageValue(MY_STORAGE_NUMBER)
   
    for key, value in pairs(myTable) do
        if myStorageValue >= value.start and myStorageValue <= value.end...
How is the function to check it?
Lua:
example = {
    [Jhon] = {fromNumber = 1, toNumber = 10},
    [Hanna] = {fromNumber = 11, toNumber = 15},
}

Return Jhon if storage is 1, or 2, or 3, ... or 10;
... else,
return Hanna if storage is 11, or 12, or 13, or 14, or 15.
[Jhon] is reference for a variable Jhon. You have to use Quotes to "Jhon" be a string.
You can do:

Lua:
local myTable = {
    ["Jhon"] = {start = 1, end = 10},
    ["Marie"] = {start = 11, end = 20},
    ["Hanna"] = {start = 21, end = 30},
}

function returnMyName(player)
    local myStorageValue = player:getStorageValue(MY_STORAGE_NUMBER)
   
    for key, value in pairs(myTable) do
        if myStorageValue >= value.start and myStorageValue <= value.end then
            return key
        end
    end
    return "Name not found"
end

--[[
Exemple Outputs:

Player Storage Value = 8
print(returnMyName) -> "Jhon"

Player Storage Value = 14
print(returnMyName) -> "Marie"

Player Storage Value = 25
print(returnMyName) -> "Hanna"

Player Storage Value = -1
print(returnMyName) -> "Name not found"

Player Storage Value = 1000
print(returnMyName) -> "Name not found"
]]--

Remember to setup the function with your Storage Number and pass the Player userData as variable when call the function.
 
Solution
Back
Top