Natan Beckman
Well-Known Member
Solved!
Last edited:
<globalevent name="vipend" type="Think" event="script" value="vipend.lua"/>
<globalevent name="vipend" interval="60000" event="script" value="vipend.lua"/>
function onThink(interval, lastExecution, thinkInterval)
local Query = db.getResult("SELECT `id`, `vip_time` FROM `accounts` WHERE `accounts`.`vip` = 1")
if Query:getID() == -1 then
return true
end
for i = 1, Query:getRows() do
local AccID = Query:getDataInt('id')
local VipTime = Query:getDataInt('vip_time')
if VipTime >= os.time() then
db.executeQuery("UPDATE `accounts` SET `vip_days` = ".. math.ceil((VipTime - os.time()) / 86400) .." WHERE `accounts`.`id` = ".. AccID .." LIMIT 1;")
else
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0, `vip_days` = 0, `vip` = 0 WHERE `accounts`.`id` = ".. AccID .." LIMIT 1;")
db.executeQuery("UPDATE `players` SET `reset_temple` = 1 WHERE `players`.`account_id` = ".. AccID ..";")
end
Query:next()
end
Query:free()
return true
end
[9:40:02.714] mysql_real_query(): SELECT `id`, `vip_time` FROM `accounts` WHERE `accounts`.`vip` = 1 - MYSQL ERROR: Unknown column 'accounts.vip' in 'where clause' (1054)
function onThink(interval, lastExecution, thinkInterval)
local Query = db.getResult("SELECT `id`, `vip_time` FROM `accounts` WHERE `accounts`.`vip_time` > 0")
if Query:getID() == -1 then
return true
end
for i = 1, Query:getRows() do
local AccID = Query:getDataInt('id')
local VipTime = Query:getDataInt('vip_time')
if VipTime >= os.time() then
db.executeQuery("UPDATE `accounts` SET `vip_days` = ".. math.ceil((VipTime - os.time()) / 86400) .." WHERE `accounts`.`id` = ".. AccID .." LIMIT 1;")
else
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0, `vip_days` = 0 WHERE `accounts`.`id` = ".. AccID .." LIMIT 1;")
db.executeQuery("UPDATE `players` SET `reset_temple` = 1 WHERE `players`.`account_id` = ".. AccID ..";")
end
Query:next()
end
Query:free()
return true
end
[11:34:00.144] mysql_real_query(): UPDATE `accounts` SET `vip_days` = 1 WHERE `accounts`.`id` = 8552246 LIMIT 1; - MYSQL ERROR: Unknown column 'vip_days' in 'field list' (1054)
[11:34:00.145] mysql_real_query(): UPDATE `accounts` SET `vip_time` = 0, `vip_days` = 0, WHERE `accounts`.`id` = 8876342 LIMIT 1; - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `accounts`.`id` = 8876342 LIMIT 1' at line 1 (1064)
[11:34:00.145] mysql_real_query(): UPDATE `players` SET `reset_temple` = 1 WHERE `players`.`account_id` = 8876342; - MYSQL ERROR: Unknown column 'reset_temple' in 'field list' (1054)
[11:34:00.145] mysql_real_query(): UPDATE `accounts` SET `vip_days` = 15 WHERE `accounts`.`id` = 9015828 LIMIT 1; - MYSQL ERROR: Unknown column 'vip_days' in 'field list' (1054)
[11:34:00.145] mysql_real_query(): UPDATE `accounts` SET `vip_time` = 0, `vip_days` = 0, WHERE `accounts`.`id` = 9027404 LIMIT 1; - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `accounts`.`id` = 9027404 LIMIT 1' at line 1 (1064)
[11:34:00.145] mysql_real_query(): UPDATE `players` SET `reset_temple` = 1 WHERE `players`.`account_id` = 9027404; - MYSQL ERROR: Unknown column 'reset_temple' in 'field list' (1054)
[11:34:00.145] mysql_real_query(): UPDATE `accounts` SET `vip_time` = 0, `vip_days` = 0, WHERE `accounts`.`id` = 9031372 LIMIT 1; - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `accounts`.`id` = 9031372 LIMIT 1' at line 1 (1064)
[11:34:00.146] mysql_real_query(): UPDATE `players` SET `reset_temple` = 1 WHERE `players`.`account_id` = 9031372; - MYSQL ERROR: Unknown column 'reset_temple' in 'field list' (1054)
[11:34:00.146] mysql_real_query(): UPDATE `accounts` SET `vip_days` = 15 WHERE `accounts`.`id` = 9327087 LIMIT 1; - MYSQL ERROR: Unknown column 'vip_days' in 'field list' (1054)
vip = {
name = "Vip system";
author = "Mock";
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.executeQuery(vip.query)
else
db.executeQuery(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.executeQuery("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.executeQuery("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
function onStepIn(cid, item, position, fromPosition)
local tileConfig = {
kickPos = fromPosition, kickEffect = CONST_ME_POFF,
kickMsg = "You need to be a vip player to access this area.",
enterMsg = "Welcome to vip area!",
enterEffect = CONST_ME_MAGIC_RED,
}
if isPlayer(cid) == true then
if vip.hasVip(cid) == FALSE then
doTeleportThing(cid, tileConfig.kickPos)
doSendMagicEffect(tileConfig.kickPos, tileConfig.kickEffect)
doPlayerSendCancel(cid, tileConfig.kickMsg)
return
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, tileConfig.enterMsg)
doSendMagicEffect(position, tileConfig.enterEffect)
return true
end
end
function onSay(cid, words, param)
if param == "" then
return doPlayerPopupFYI(cid,"Está com problemas?\nAprenda os comandos!\n---------------\nAdicionar vip:\n/vip add days player\n/vip add 30 Real\n---------------\nDeletar vip:\n/vip del player\n/vip del Real\n---------------\nVer a vip:\n/vip see player\n/vip see Real\n---------------\n")
end
if param:lower():find('add') == 1 and 3 then
local _,_,id,name = param:lower():find('add (%d+) (.+)')
name = name or ""
id = tonumber(id or 1) or 1
if tonumber(id) == nil or getPlayerByName(name) == false then
return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"Adicionar vip:\n/vip add days player\n/vip add 30 Real\n [Player: "..name.."]")
end
if isPlayer(getPlayerByName(name)) == TRUE then
vip.addVipByAccount(getPlayerAccount(getPlayerByName(name)) ,vip.getDays(id))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Foram adicionados "..tonumber(id).." dias de vip a "..name..".")
doPlayerSendTextMessage(getPlayerByName(name),MESSAGE_INFO_DESCR,"Você recebeu "..tonumber(id).." dias de vip.")
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,name.." não esta online ou não existe.")
end
elseif param:lower():find('del') == 1 and 3 then
local _,_,name = param:lower():find('del (.+)')
if getPlayerByName(name) == false then
return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"Deletar vip:\n/vip del player\n/vip del Real\n")
end
vip.setVipByAccount(getPlayerAccount(getPlayerByName(name)),-os.time())
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"A vip de "..name.." foi apagada.")
elseif param:lower():find('see') == 1 and 3 then
local _,_,name = param:lower():find('see (.+)')
name = name or ""
if getPlayerByName(name) == false then
return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"Ver a vip:\n/vip see player\n/vip see Real\n")
end
local ret_ = vip.getVip(getPlayerByName(name))
if ret_ == 0 then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,name.." Não tem vip, e nunca teve.")
else
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "A vip de "..name.." Acaba/terminou em "..os.date("%d %B %Y %X ",ret_))
end
end
return TRUE
end
function onSay(cid, words, param, channel)
doPlayerSendCancel(cid, "Vip removed.")
return doPlayerRemoveVip(cid)
end