• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Script vip.Add not work in tfs 0.3.6

TibiaGameHost

Hello!
Joined
Feb 25, 2009
Messages
255
Reaction score
0
Location
Canadá
This is script:

local config = {
level = 10,
days = 1,
storageId = 15558,
msg = "Parabéns, por jogar DarkTibia, você recebeu 1 dia VIP!",
msgtype = MESSAGE_EVENT_ADVANCE
}

function onAdvance(cid, oldLevel, newLevel)
if (getPlayerLevel(cid) >= config.level and getGlobalStorageValue(getPlayerAccountId(cid)+450) <= 0) then
setGlobalStorageValue(getPlayerAccountId(cid)+450, 1)
vip.addVipByAccount(getPlayerAccount(cid) ,vip.getDays(config.days))
doPlayerSendTextMessage(cid, config.msgtype, config.msg)

end

return TRUE
end

This is script is work in TFS 0.4 , more not work in TFS 0.3.6 (I Using).

I'm using 0.3.6 and not set days of VIP for the character, and also not appearing error in TFS.
I use VIP System Mock.

LIB:

vip = {
name = "Vip system";
author = "Igor";
version = "1.0.0.0";
query="ALTER TABLE `accounts` ADD `vip_time` INTEGER";
query2="ALTER TABLE `accounts` ADD `vip_time` INT(15) NOT NULL"
}

function vip.setTable()
dofile('config.lua')
if sqlType == "sqlite" then
db.escapeString(vip.query)
else
db.escapeString(vip.query2)
end
end

function vip.getVip(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == FALSE then error('Player don\'t find') end;
ae = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."';")
if ae:getID() == -1 then
return 0
end

local retee = ae:getDataInt("vip_time") or 0
ae:free()
return retee
end

function vip.getVipByAcc(acc)
assert(acc,'Account is nil')
local a = db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';")
if a:getID() ~= -1 then
return a:getDataInt("vip_time") or 0, a:free()
else
error('Account don\'t find.')
end
end

function vip.setVip(cid,time)
dofile("config.lua")
assert(tonumber(cid),'Parameter must be a number')
assert(tonumber(time),'Parameter must be a number')
if isPlayer(cid) == FALSE then error('Player don\'t find') end;
db.escapeString("UPDATE `"..sqlDatabase.."`.`accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='".. getPlayerAccount(cid).."';")
end

function vip.getVipByAccount(acc)
assert(acc,'Account is nil')
return db.getResult("SELECT `vip_time` FROM `accounts` WHERE `name` = '"..acc.."';"):getDataInt("vip_time") or 0
end

function vip.hasVip(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == FALSE then return end;
local t = vip.getVip(cid) or 0
if os.time(day) < t then
return TRUE
else
return FALSE
end
end

function vip.hasVips(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == FALSE then return end;
local t = vip.getVip(cid)
if os.time(day) < t then
return TRUE
else
return FALSE
end
end

function vip.accountHasVip(acc)
assert(acc,'Account is nil')
if os.time() < vip.getVipByAccount(acc) then
return TRUE
else
return FALSE
end
end
function vip.getDays(days)
return (3600 * 24 * days)
end

function vip.addVipByAccount(acc,time)
assert(acc,'Account is nil')
assert(tonumber(time),'Parameter must be a number')
local a = vip.getVipByAcc(acc)
a = os.difftime(a,os.time())
if a < 0 then a = 0 end;
a = a+time
return vip.setVipByAccount(acc,a)
end

function vip.setVipByAccount(acc,time)
dofile("config.lua")
assert(acc,'Account is nil')
assert(tonumber(time),'Parameter must be a number')
db.escapeString("UPDATE `accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='"..acc.."';")
return TRUE
end

function vip.returnVipString(cid)
assert(tonumber(cid),'Parameter must be a number')
if isPlayer(cid) == TRUE then
return os.date("%d %B %Y %X ", vip.getVip(cid))
end
end
 
try changing
LUA:
db.escapeString("UPDATE `accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='"..acc.."';")
to
LUA:
db.executeQuery("UPDATE `accounts` SET `vip_time` = '"..(os.time()+time).."' WHERE `accounts`.`name` ='"..acc.."';")

But I'm not really sure it would be easier to read if the code was properly tagged and tabbed xD

to do lua set ["lua"] without "" around lua and ["/lua"] without "" around /lua and put code between the 2 and for xml same and php same yatta yatta
 
Back
Top