Tentar Usar Essa função na script
doPlayerAddPremiumDays
ou poder fazer 1 tabela +/- assim
local config = {
days = 30,
}
doPlayerAddPremiumDays(cid, config.days)
info
Grupo: Artesão
Registrado: 08/10/15
Posts: 103
Reputação: +34

Tentar Usar Essa função na script
doPlayerAddPremiumDays
ou poder fazer 1 tabela +/- assim
local config = {
days = 30,
}
doPlayerAddPremiumDays(cid, config.days)
Editado Abril 10 por luizmachado1
meu vip não é por premium, sabe me dizer aonde tem um tutorial de vip por premium account ??
info
Grupo: Conde
Registrado: 07/04/15
Posts: 926
Reputação: +335
Gênero: Masculino

@Adriez, mande o script da action do referido baú.
ai bro
local lever = {
[7045] = {30,30,{2160}}
}
function onUse(cid,item,fromPosition,itemEx,toPosition)
if getPoints(cid) < lever[item.actionid][1] then
return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Você precisa de "..lever[item.actionid][1].." points.")
end
removePoints(cid,lever[item.actionid][1])
local add = (lever[item.actionid][2]*86400)
setPlayerStorageValue(cid, 85258, getPlayerStorageValue(cid, 85258) - os.time() <= 0 and (os.time() + add) or (getPlayerStorageValue(cid, 85258) + add))
local quantity = math.floor((getPlayerStorageValue(cid, 85258) - os.time())/(24 * 60 * 60))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
for _, items in pairs(lever[item.actionid][3]) do
doPlayerAddItem(cid,items,1)
end
return true
end
info
Grupo: Conde
Registrado: 07/04/15
Posts: 926
Reputação: +335
Gênero: Masculino

Tenta ae:
local lever = { [7045] = {30,30,{2160}}}function onUse(cid,item,fromPosition,itemEx,toPosition) if getPoints(cid) < lever[item.actionid][1] then return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Você precisa de "..lever[item.actionid][1].." points.") end removePoints(cid,lever[item.actionid][1]) local add = (lever[item.actionid][2]*86400) local sid = getPlayersByAccountId(getPlayerAccountId(cid)) setPlayerStorageValue(sid, 85258, getPlayerStorageValue(cid, 85258) - os.time() <= 0 and (os.time() + add) or (getPlayerStorageValue(cid, 85258) + add)) local quantity = math.floor((getPlayerStorageValue(cid, 85258) - os.time())/(24 * 60 * 60)) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.") for _, items in pairs(lever[item.actionid][3]) do doPlayerAddItem(cid,items,1) end return trueend
Editado Abril 12 por danihcv
info
Grupo: Visconde
Registrado: 03/02/10
Posts: 322
Reputação: +98
Gênero: Masculino
Char no Tibia: Miguel Absy

Ele escreveu "sid" ao inves de "cid". Tenta de novo, fazendo essa alteração.
EDIT: acabei de ver q "sid" esta certo, esquece kkk
Talvez assim funfe: (se funfar, da o rep pro rapaz ai de cima, so tirei o "Id" do "getPlayersByAccount"
local lever = { [7045] = {30,30,{2160}}}function onUse(cid,item,fromPosition,itemEx,toPosition) if getPoints(cid) < lever[item.actionid][1] then return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Você precisa de "..lever[item.actionid][1].." points.") end removePoints(cid,lever[item.actionid][1]) local add = (lever[item.actionid][2]*86400) local sid = getPlayersByAccount(getPlayerAccountId(cid)) setPlayerStorageValue(sid, 85258, getPlayerStorageValue(cid, 85258) - os.time() <= 0 and (os.time() + add) or (getPlayerStorageValue(cid, 85258) + add)) local quantity = math.floor((getPlayerStorageValue(cid, 85258) - os.time())/(24 * 60 * 60)) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.") for _, items in pairs(lever[item.actionid][3]) do doPlayerAddItem(cid,items,1) end return trueend
Editado Abril 12 por miguel223
info
Grupo: Visconde
Registrado: 03/02/10
Posts: 322
Reputação: +98
Gênero: Masculino
Char no Tibia: Miguel Absy

Tente adicionar isso em lib/functions.lua:
function getPlayersByAccount(id)local f = db.getResult("SELECT `id` FROM `players` WHERE `account_id` = "..id..";")local players = {}if f:getID() ~= -1 thenrepeattable.insert(players, f:getDataInt("id"))until not f:next()f:free()endreturn playersend
aí da o mesmo erro anterior....
info
Grupo: Visconde
Registrado: 03/02/10
Posts: 322
Reputação: +98
Gênero: Masculino
Char no Tibia: Miguel Absy

Ok, aguarde, o problema ta no chest mesmo, vo tentar achar o bug.
info
Grupo: Visconde
Registrado: 03/02/10
Posts: 322
Reputação: +98
Gênero: Masculino
Char no Tibia: Miguel Absy

local lever = {
[7045] = {30,30,{2160}}
}
function onUse(cid,item,fromPosition,itemEx,toPosition)
if getPoints(cid) < lever[item.actionid][1] then
return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Você precisa de "..lever[item.actionid][1].." points.")
end
removePoints(cid,lever[item.actionid][1])
local add = (lever[item.actionid][2]*86400)
if getPlayerStorageValue(cid, 85258) > os.time() then
setPlayerStorageValue(cid, 85258, getPlayerStorageValue(cid) + add)
else
setPlayerStorageValue(cid, 85258, os.time() + add)
end
local quantity = math.floor((getPlayerStorageValue(cid, 85258) - os.time())/(24 * 60 * 60))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
for _, items in pairs(lever[item.actionid][3]) do
doPlayerAddItem(cid,items,1)
end
return true
end
Em creaturescripts/scripts/, crie um arquivo de nome leverchest.lua e adicione:
function onThink(cid, interval)
if getPlayerStorageValue(cid, 85258) > os.time() then
setPlayerStorageValue(getPlayersByAccountId(getPlayerAccountId(cid)), 85258, getPlayerStorageValue(cid, 85258))
end
return true
end
Em creaturescripts.xml, adicione:
<event type="think" name="leverchest" event="script" value="leverchest.lua"/>
Em login.lua, registre o evento "leverchest"
Editado Abril 12 por miguel223
info
Grupo: Visconde
Registrado: 03/02/10
Posts: 322
Reputação: +98
Gênero: Masculino
Char no Tibia: Miguel Absy

Se pegar, agora eu quero o rep pra mim kkk
Para dar menos lag, se pode também substituir function onThink(cid, interval) por function onLogin(cid)
Dai o event type se altera pra login tbm.
Como funfa, em tese: toda x q o player entrar num personagem, se tiver vip, todos os chars da conta passarão a ter. O bom eh q se criar char novo, pega no char novo tbm, só eh preciso entrar num char q tenha a vip pra q o script se ative.
Editado Abril 12 por miguel223
info
Grupo: Visconde
Registrado: 03/02/10
Posts: 322
Reputação: +98
Gênero: Masculino
Char no Tibia: Miguel Absy

Outra opçao seria a seguinte:
local lever = {
[7045] = {30,30,{2160}}
}
function onUse(cid,item,fromPosition,itemEx,toPosition)
if getPoints(cid) < lever[item.actionid][1] then
return doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Você precisa de "..lever[item.actionid][1].." points.")
end
removePoints(cid,lever[item.actionid][1])
local add = (lever[item.actionid][2]*86400)
if (db.getResult("SELECT `vip_time` FROM `accounts` WHERE `accounts`.`id` = ".. getPlayerAccountId(cid) ..";") :getDataInt("vip_time")) > os.time()) then
db.executeQuery("UPDATE `accounts` SET `vip_time` = 'vip_time + ".. add .. "' WHERE `accounts`.`id`= " .. getPlayerAccountId(cid) .. "")
setPlayerStorageValue(cid, 85258, (db.getResult("SELECT `vip_time` FROM `accounts` WHERE `accounts`.`id` = ".. getPlayerAccountId(cid) ..";") :getDataInt("vip_time"))
setPlayerStorageValue(cid, 12532, 1)
else
db.executeQuery("UPDATE `accounts` SET `vip_time` = '".. os.time() + add .. "' WHERE `accounts`.`id`= " .. getPlayerAccountId(cid) .. "")
setPlayerStorageValue(cid, 85258, (db.getResult("SELECT `vip_time` FROM `accounts` WHERE `accounts`.`id` = ".. getPlayerAccountId(cid) ..";") :getDataInt("vip_time"))
setPlayerStorageValue(cid, 12532, 1)
end
local quantity = math.floor((getPlayerStorageValue(cid, 85258) - os.time())/(24 * 60 * 60))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
for _, items in pairs(lever[item.actionid][3]) do
doPlayerAddItem(cid,items,1)
end
return true
end
E, em creaturescripts/scripts, criando um arquivo de nome chestlever.lua, adicionando:
function onLogin(cid)
if (db.getResult("SELECT `vip_time` FROM `accounts` WHERE `accounts`.`id` = ".. getPlayerAccountId(cid) ..";") :getDataInt("vip_time")) > os.time()) then
setPlayerStorageValue(cid, 85258, (db.getResult("SELECT `vip_time` FROM `accounts` WHERE `accounts`.`id` = ".. getPlayerAccountId(cid) ..";") :getDataInt("vip_time"))
setPlayerStorageValue(cid, 12532, 1)
end
return true
end
function onThink(cid, interval)
if getPlayerStorageValue(cid, 12532) >= 1 then
if getPlayerStorageValue(cid, 85258) <= os.time() then
doTeleportThing(cid, {x= ,y=, z=})
setPlayerStorageValue(cid, 12532, 0)
doPlayerSendTextMessage(cid, 22, "Sua vip acabou")
end
end
return true
end
Em creaturescripts.xml, adicione:
<event type="login" name="chestlever" event="script" value="chestlever.lua"/>
<event type="think" name="chestlevert" event="script" value="chestlever.lua"/>
Em login.lua, adicionando:
registerCreatureEvent(cid, "chestlever")
registerCreatureEvent(cid, "chestlevert")
Dessa forma, todos os chars terão automaticamente o storage. Sem façanhas de precisar logar em 1 q ja tinha.
ACTIONID PARA TILE VIP(entrada da vip - usar a action id 12532 no piso/tp):
Crie um arquivo em movements/scripts chamado tilevipe.lua e adicione:
function onStepIn(cid, item, pos)
if getPlayerStorageValue(cid, 12532) >= 1 then
doPlayerSendTextMessage(cid, 22, "Bem-vindo a vip, jogador")
else
return false
doPlayerSendCancel(cid, "Voce nao e vip")
end
return true
end
Em movements.xml, adicione:
<movevent event="StepIn" actionid="12532" script="tilevipe.lua" />
Editado Abril 13 por miguel223
info
Grupo: Visconde
Registrado: 02/09/10
Posts: 341
Reputação: +6
Gênero: Masculino
blz galera é o seguinte no meu servidor o cara abre o bau e vira vip, só q o vip só da pra um boneco de vez pra acc dele toda, como arrumar ???