• 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 Help with "getAccountVipTime(accountName)" function.

Vikarious

New Member
Joined
Dec 16, 2008
Messages
93
Reaction score
2
I'm using this function on my actual server ( The Forgotten Server - Version 0.2.13 (Mystic Spirit). 9.51), I had it in a 8.51 working just perfect, but it just won't work on my actual server.

I'm trying to adapt the script that goes on global.lua

This is the main function:

Lua:
function getAccountVipTime(accountName) 
  local result = db.getResult("SELECT `viptime` FROM `accounts` WHERE `name` = '" .. accountName .. "' LIMIT 1;")
    if(result:getID() ~= -1) then 
     if(result:getDataInt("viptime") > os.time())then 
      return result:getDataInt("viptime")-os.time() 
     else 
      return 0 
     end 
   else 
    return FALSE 
   end 
   result:free() 
 end

Secondary functions:

Lua:
function isVip(accountName) 
  if(getAccountVipTime(accountName) == TRUE or getConfigInfo("freeVip") == "yes")then
    return TRUE 
  else 
   return FALSE 
  end 
 end 
  
 function doAccountAddVipTime(accountName, vipTime) 
  local result = db.getResult("SELECT `viptime` FROM `accounts` WHERE `name` = '" .. accountName .. "' LIMIT 1;")
    if(result:getID() ~= -1) then 
    if(result:getDataInt("viptime") > os.time())then 
     timeToAdd = result:getDataInt("viptime")+vipTime 
    else 
     timeToAdd = os.time()+vipTime 
    end 
    db.executeQuery("UPDATE `accounts` SET `viptime` = " .. timeToAdd .. " WHERE `name`='" .. accountName .. "' LIMIT 1;")
     result:free() 
   return TRUE 
   end 
 end

Seems like this query just cannot return the right values, because even when I have manually added numbers to my DB into 'viptime' in accounts table, the result is always FALSE or 0 and things like that.

Could any one bring some light into this?

I tried already make things like:


local result = db.getResult("SELECT `viptime` FROM `accounts` WHERE `id` FROM `players`= '" .. account_id .. "' LIMIT 1;")

But it just returned a wrong syntax error.

I'm counting on any sugestions guys!!

Thank's a lot in advance!!
 
Back
Top