Acho que o problema consiste que tu estás a usar duas srorages diferentes uma 29000 que não sei pra quê está servindo e a outra 13778 que está marcando o tempo.
Quando tu faz a verificação do tempo de vip, tu usa sempre a 29000 e nunca a 13778 que está com o valor marcado do tempo de vip.





info
Grupo: Marquês
Registrado: 18/05/11
Posts: 1.1k
Reputação: +150
Gênero: Masculino
Galera, to usando esse script pra adicionar vip por item e mudar o nick pra [VIP]. Da certo, mas quando o player reloga pra trocar o nome, a vip acaba, ele desloga e sai o [VIP] do nome.
function onUse(cid, item, fromPosition, itemEx, toPosition)
local config={
removeOnUse = "yes" -- remover quando usar ("yes" or "no")
}
local days = 30 -- dias que serão adicionados
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 29000)
local timenow = os.time()
if getPlayerStorageValue(cid, 13778) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados ".. days .." dias de VIP no seu character.")
setPlayerStorageValue(cid, 13778, time)
local quantity = math.floor((getPlayerStorageValue(cid, 13778) - timenow)/(24 * 60 * 60))
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem ".. quantity .." dias de VIP restantes.")
if (config.removeOnUse == "yes") then
doRemoveItem(item.uid, 1)
db.executeQuery("UPDATE `players` SET `name` = '[VIP] "..getCreatureName(cid).."' WHERE `id` = "..getPlayerGUID(cid)..";")
doPlayerSendTextMessage(cid,25,"Você será kickado em 5 segundos para mudança de nome.")
doPlayerAddAddons(cid, 1)
addEvent(doRemoveCreature, 5*1000, cid, true)
end
return TRUE
end
function onLogin(cid)
local temple = { x =156, y = 112, z = 7}
if vip.hasVip(cid) == true then
if getPlayerStorageValue(cid,29000) ~= 1 then
setPlayerStorageValue(cid,29000,1)
end
else
if getPlayerStorageValue(cid,29000) == 1 then
doTeleportThing(cid, temple)
doPlayerSendTextMessage(cid, 22, "Sua vip acabou!")
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerPromotionLevel(cid, 1)
setPlayerStorageValue(cid, 29000, 0)
end
end
return true
end
function onLogin(cid)
local name = string.gsub(""..getCreatureName(cid).."", ".VIP. ", "")
if getPlayerStorageValue(cid, 29000) <= 0 then
if getCreatureName(cid) ~= name then
db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` = "..getPlayerGUID(cid)..";")
addEvent(doRemoveCreature, 2*1000, cid, true)
end
end
return true
end
Queria adicionar também uma nova vocação quando o player usar o item, mas quero que seja removida quando a vip acabar.