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

VIP System using functions.lua

leonardo123

New Member
Joined
Jul 10, 2008
Messages
90
Reaction score
0
well i was trying to create a vip system for my ot creating new functions everything was ok but then i start having this error and i don't know what to do i have tried several different ways but i still can't make it work
9icpsg.jpg

Code:
function isVip(cid)
local acnt = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '" .. getPlayerName .. "' LIMIT 1;")
local PlayerVipDays = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = 'acnt' LIMIT 1;")

    return (isPlayer(cid) and (PlayerVipDays > 0))
end
does anybody knows how i can fix my problem? it would be very appreciated and i know it would be very useful not only for me but for everyone esle that could be interested in something like this...
 
Look at your code from beggining and at the error what appeared.
"attempt to compare number with table"

Your isVip(cid) returns sth like this: {false, nil} or {true, 365}.

You have to open your data/lib/050-function.lua and check the 5th line, which function can't compare.

Or try this:
Code:
function isVip(cid)
    local n = false
    if isPlayer(cid) == true then
        local acnt = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '" .. getPlayerName .. "' LIMIT 1;")
        local PlayerVipDays = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = 'acnt' LIMIT 1;")
        if PlayerVipDays > 0 then
            n = true
        end  
    end
    return n
end

Now it will return true if player is vip or,
will return false if player isn't vip or cid isn't a player.

Or use this:
Code:
function getPlayerVipDays(cid)
    local acnt = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = '" .. getPlayerName .. "' LIMIT 1;")
    local PlayerVipDays = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = 'acnt' LIMIT 1;")
    if PlayerVipDays > 0 then
        return PlayerVipDays
    end    
    return 0
end

function isVip(cid)
    local n = false
    if isPlayer(cid) == true then
        if getPlayerVipDays(cid) > 0 then
            n = true
        end
    end
    return n
end

Both will work.
 
Last edited:
Back
Top