Então aqui está:
function doAddVipDays(cid, days)
local Target = db.getResult("SELECT `name` FROM `players` WHERE `name` = " .. (db.escapeString(getPlayerName(cid))) .. ";")
if (Target:getID() ~= -1) then
if getVipTimeByName(getPlayerName(cid)) == 0 then
db.executeQuery("UPDATE `accounts` SET `vip_time` = 86400 * days + ".. os.time() .." WHERE `accounts`.`id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
else
db.executeQuery("UPDATE `accounts` SET `vip_time` = `accounts`.`vip_time` + (86400 * days) WHERE `accounts`.`id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
end
db.executeQuery("UPDATE `accounts` SET `vip` = 1 WHERE `accounts`.`id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
db.executeQuery("UPDATE `accounts` SET `vip_days` = `accounts`.`vip_days` + days WHERE `accounts`.`id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
else
print("Erro ao tentar adicionar vip para o jogador " .. getPlayerName(cid) .. ".")
end
return TRUE
end
local config = {
moneyid = 2159,
}
function onUse(cid, fromPosition, itemEx, toPosition, moneyid)
if doPlayerRemoveItem(cid, config.moneyid, 30) then
doAddVipDays(cid, 30)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Parabéns! Foi adicionado 30 dias de vip ao player ".. getPlayerName(cid) ..". Digite !checkvip para checar os dias de VIP.")
doSendMagicEffect(getCreaturePosition(cid), 27)
doSendAnimatedText(getCreaturePosition(cid), "Vip!", 180)
else
doPlayerSendCancel(cid, "Você não possui moedas VIP suficiente.")
end
return TRUE
end
flw