Ir para conteúdo

Featured Replies

Postado
  • Autor

 

tente assim. /endvip.lua

function onLogin(cid)
local temple = { x =32369, y = 32246, z = 6}
if vip.hasVip(cid) == true then
if getPlayerStorageValue(cid,33339) ~= 1 then
setPlayerStorageValue(cid,33339,1)
end
else
if getPlayerStorageValue(cid,33339) == 1 then
doTeleportThing(cid, temple)
doPlayerSendTextMessage(cid, 22, "Your VIP Time over!")
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerPromotionLevel(cid, 1)
setPlayerStorageValue(cid, 33339, 0)
end
end
return true
end

O meu VIP não é pela DB, e sim por Storage, não testei o código mas pelo o que vi, acho que não funcionará.

  • Respostas 9
  • Visualizações 600
  • Created
  • Última resposta

Top Posters In This Topic

Postado
  • Autor

 

tente assim.

 

action/

function onUse(cid, item)
              if getPlayerStorageValue(cid, 13540) - os.time() < 0 then
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Agora voce e um player VIP.")
              setPlayerStorageValue(cid, 9898, os.time() + (30*24*60*60)) 
              doRemoveItem(item.uid, 1)
          else
             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Voce ja e VIP so poderá renovar daqui 30 dias.")
          end
return TRUE
end

creturescript/

 function onLogin(cid)

if getPlayerStorageValue(cid, 13540) - os.time() > 0 then
setPlayerStorageValue(cid, 9898, 1)
end

local pos = {x = 157, y = 50, z = 7} -- posiçao do templo. 

function EddyHavoc(cid)
if isPlayer(cid) then    
db.executeQuery("UPDATE `players` SET `name` = '"..string.sub(getCreatureName(cid), 7).."' WHERE `id` = "..getPlayerGUID(cid)..";")
doRemoveCreature(cid)
end
end

if getPlayerStorageValue(cid, 9898) == 1 and getPlayerStorageValue(cid, 13540) - os.time() < 1 or getPlayerStorageValue(cid, 13540) - os.time() == 0 then
doTeleportThing(cid, pos)
doPlayerPopupFYI(cid, "Sua vip Account acabou.")
setPlayerStorageValue(cid, 9898, -1)
if string.find(tostring(getCreatureName(cid)),"[[Vip]]") then    
addEvent(EddyHavoc, 3*1000, cid)
end
end
return TRUE
end

Vish, agora nem na área donate ele entra mais ;/ Meu Storage é 13500

UP

Editado por moviebr (veja o histórico de edições)

Postado

Em creaturescripts/creaturescripts.xml adiciona á tag:

<event type="login" name="FimVip" event="script" value="fimvip.lua"/>

 

Em creaturescripts/scripts/fimvip.lua adicione:

function onLogin(cid)
local temple = { x =655, y = 1014, z = 7}
if vip.hasVip(cid) == true then
if getPlayerStorageValue(cid,13500) ~= 1 then
setPlayerStorageValue(cid,13500)
end
else
if getPlayerStorageValue(cid,13500) == 1 then
doTeleportThing(cid, temple)
doPlayerSendTextMessage(cid, 22, "Your VIP Time over!")
db.executeQuery("UPDATE `accounts` SET `vip_time` = 0 WHERE `id` = ".. getAccountIdByName(getPlayerName(cid)) ..";")
setPlayerPromotionLevel(cid, 1)
setPlayerStorageValue(cid, 13500, 0)
end
end
return true
end

E no login.lua adicione a tag: 

registerCreatureEvent(cid, "FimVip")

Eu sei que é por storage, porém no meu server funcionava desse jeito, mas mudei, testa e me fala.

Editado por p e o p l e (veja o histórico de edições)

Postado

Caso não funcionar utilize a que @Wise fez.

Ele criou um método que envolve outra storage key, possibilitando assim a identificação de um player com tempo de vip ativo/inativo.

 

autocheckvip.lua (data\creaturescripts\scripts):

local key = {13500, 53100} -- storages
local default = 1 -- default town id

function onLogin(cid)
    if getPlayerStorageValue(cid, key[1]) < os.time() and getPlayerStorageValue(cid, key[2]) > 0 then
        doPlayerSetTown(cid, default)
        setPlayerStorageValue(cid, key[2], -1)
        doTeleportThing(cid, getTownTemplePosition(default))
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Your VIP time is over.')
    end
    
    return true
end

function onLogout(cid)
    return getPlayerStorageValue(cid, key[1]) > os.time() and getPlayerStorageValue(cid, key[2]) < 1 and setPlayerStorageValue(cid, key[2], 1) or true
end

 

creaturescripts.xml (data\creaturescripts):

<event type="login" name="CheckLogin" event="script" value="autocheckvip.lua"/>
<event type="logout" name="CheckLogout" event="script" value="autocheckvip.lua"/>

 

Basta o player vip fazer logout 1 vez para que o resto execute perfeitamente.

Sugiro que remova a vip de todos os players ou que faça uso de uma nova storage key para evitar possíveis falhas na identificação do player vip ativo/inativo.

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo