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

Lua TFS 0.4 level beetwen

Blade33711

Member
Joined
Aug 6, 2012
Messages
133
Solutions
1
Reaction score
5
Location
Poland
I have script:
Lua:
local cfg = {[1] = {level = 1, level2 = 100}}
function onSay(cid, words, param, channel)
for v, k in pairs(cfg) do
if getPlayerLevel(cid) >= k.level and getPlayerLevel(cid) <= k.level2 then
SCRIPT
end
end
end
Is it possible to do something different than this?
I tried:
Lua:
local levels = {1,100}
if isInArray(levels, getPlayerLevel(cid))

But it didn't work.
 
Solution
the first is your best bet, the second clearly wouldn't work because isInArray checks for a SPECIFIC value in the table
if the player level was not 1 or 100 it will return false
the first is your best bet, the second clearly wouldn't work because isInArray checks for a SPECIFIC value in the table
if the player level was not 1 or 100 it will return false
 
Solution
Some time ago, i have made this funcion:

Code:
function isValueBetween(value, min, max)
    return (value >= min and value < max)
end

You can use like that on your code:

Code:
local cfg = {[1] = {level = 1, level2 = 100}}
function onSay(cid, words, param, channel)
    for v, k in pairs(cfg) do
        if isValueBetween(getPlayerLevel(cid), k.level, k.level2) then
            SCRIPT
        end
    end
end

Won't make difference, but is more clearly the code. You can use the function if you want...
 

Similar threads

Back
Top