Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

Esse é um sistema de VIP por account, com comandos in game para adicionar/remover/checar dias de VIP.

 

Para instalar crie Killua VIP System.lua em data/lib e coloque:

-- Account VIP System criado por Vitor Bertolucci - Killua


function installVipSystem()
      local func = db.query or db.executeQuery

      if func("CREATE TABLE `killua_vip_time` (`account_id` int(11) NOT NULL default '0', `time` varchar(255) NOT NULL default '0')") then
            return print(os.date("%X").." - Killua VIP System instalado com sucesso.") and true

      end
      return print(os.date("%X").." - Killua VIP System ja esta instalado.") and false
end


function getAccountVipTime(accid)
      local time_ = db.getResult("SELECT `time` FROM `killua_vip_time` WHERE `account_id` = '"..accid.."' LIMIT 1")
      if time_:getID() ~= -1 then
            return time_:getDataInt("time")
      end
      return false
end


function setAccountVipTime(accid, time)
      local func = db.query or db.executeQuery
      local time_ = db.getResult("SELECT `time` FROM `killua_vip_time` WHERE `account_id` = '"..accid.."' LIMIT 1")
      if time_:getID() ~= -1 then
            func("UPDATE `killua_vip_time` SET `time` = '"..time.."' WHERE `account_id` = '"..accid.."' LIMIT 1")
            time_:free()
            return true
      end
      return func("INSERT INTO `killua_vip_time` (`account_id`, `time`) VALUES ('"..accid.."', '"..time.."')")
end


function isVip(cid)
      if getAccountVipTime(getPlayerAccountId(cid)) then
            return getAccountVipTime(getPlayerAccountId(cid)) >= os.time()
      end
      return false
end


function doPlayerSetVipDays(cid, days)
      if days and tonumber(days) and tonumber(days) >= 0 then
            if tonumber(days) == 0 then
                  return setAccountVipTime(getPlayerAccountId(cid), days)
            end
            return setAccountVipTime(getPlayerAccountId(cid), (os.time() + (days * 60 * 60 * 24)))
      end
      return print("Aviso: Nao foi possivel executar a funcao doPlayerAddVipDays. O parametro days deve ser um numero.")
end


function getPlayerVipDays(cid)
      if getAccountVipTime(getPlayerAccountId(cid)) then
            return getAccountVipTime(getPlayerAccountId(cid)) > 0 and math.ceil((getAccountVipTime(getPlayerAccountId(cid)) - os.time()) / 60 / 60 / 24) or 0
      end
      return 0
end
PS: Se na sua pasta lib já tiver algum arquivo com vip no nome, delete o arquivo.
 
Em data/talkactions/scripst crie vip.lua e coloque:
 
-- Account VIP System criado por Vitor Bertolucci - Killua


function onSay(cid, words, param, channel)


      if param == "" then
            return doPlayerSendCancel(cid, "Utilize os parametros corretos.")
      end


      local t = string.explode(param, ',')


      if t[1] ~= "days" and getPlayerGroupId(cid) < 4 then
            return doPlayerSendCancel(cid, "Comandos disponiveis apenas para gods. Player podem usar /vip days")
      end


      if t[1] == "days" then
            if isVip(cid) then
                  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Voce tem "..getPlayerVipDays(cid).." dias de VIP.")
            else
                  doPlayerSendCancel(cid, "Voce nao tem VIP.")
            end
      elseif t[1] == "add" then
            if getPlayerByName(t[2]) and tonumber(t[3]) and tonumber(t[3]) > 0 then
                  doPlayerSetVipDays(getPlayerByName(t[2]), getPlayerVipDays(getPlayerByName(t[2])) + tonumber(t[3]))
                  doPlayerSendTextMessage(getPlayerByName(t[2]), 25, "Voce recebeu "..t[3].." dias de VIP.")
                  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[3].." dias de VIP adicionados para "..t[2])
            else
                  doPlayerSendCancel(cid, "Voce fez algo errado! Utilize /vip add, PLAYERNAME, dias.")
            end
      elseif t[1] == "remove" then
            if getPlayerByName(t[2]) and tonumber(t[3]) and tonumber(t[3]) > 0 then
                  if isVip(getPlayerByName(t[2])) then
                        if getPlayerVipDays(getPlayerByName(t[2])) > tonumber(t[3]) then
                              doPlayerSetVipDays(getPlayerByName(t[2]), getPlayerVipDays(getPlayerByName(t[2])) - tonumber(t[3]))
                              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[3].." dias de vip removidos de "..t[2])
                              doPlayerSendTextMessage(getPlayerByName(t[2]), MESSAGE_STATUS_WARNING, "Fora retirados "..t[3].." dias de VIP da sua account.")
                        else
                              doPlayerSetVipDays(getPlayerByName(t[2]), 0)
                              doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[2].." tinha menos que "..t[3].." dias de VIP. A VIP dele foi removida.")
                              doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Sua VIP acabou.")
                        end
                  else
                        doPlayerSendCancel(cid, t[2].." nao eh VIP.")
                  end
            else
                  doPlayerSendCancel(cid, "Voce fez algo errado! Utilize /vip remove, PLAYERNAME, dias.")
            end
      elseif t[1] == "check" then
            if getPlayerByName(t[2]) then
                  if isVip(getPlayerByName(t[2])) then
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[2].." tem "..getPlayerVipDays(getPlayerByName(t[2])).." dias de VIP Account.")
                  else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, t[2].." nao eh VIP.")
                  end
           else
                doPlayerSendCancel(t[2].." Nao esta online ou nao existe!")
           end
      elseif t[1] == "install" then
            if installVipSystem() then
                  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "O sistema foi instalado com sucesso.")
            else
                  doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "O sistema ja esta instalado.")
            end
      end
      return true
end

E em talkactions.xml coloque: 

<talkaction words="/vip" event="script" value="vip.lua"/>

Comandos:

 

/vip install - instala o sistema

/vip days - mostra quantos dias de VIP vc tem

/vip add, NOMEDOPLAYER, dias - Adiciona dias de VIP à acc do jogador

/vip remove, NOMEDOPLAYER, dias - Remove dias de VIP da acc do jogador

/vip check, NOMEDOPLAYER - Mostra quantos dias de VIP o jogador tem

 

 

Funções que fiz pro sistema e podem acabar sendo úteis:

 

doPlayerSetVipDays(cid, days)

 

getPlayerVipDays(cid)

 

isVip(cid)

 

 

 
Pronto.
 
Vou por aqui tbm um piso que só jogadores VIP podem passar, usem esse script como base para criarem outros.
 
Crie piso vip.lua em data/movements/scripts e coloque:
 
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
      if not isVip(cid) then
            doTeleportThing(cid, fromPosition)
            doPlayerSendCancel(cid, "Somente jogadores VIP podem passar.")
            doSendMagicEffect(fromPosition, CONST_ME_POFF)
      else
            doSendMagicEffect(toPosition, 12)
      end
      return true
end

E em movements.xml: 

<movevent type="StepIn" actionid="5723" event="script" value="piso vip.lua"/>

Depois disso é só colocar actionID 5723 nos pisos que somente jogadores VIP podem passar.

 

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

 

 

 

 

 

v61snZO.png?129bcx1x.pngiVgTXVz.png?1

 

 

 

 

 

  • Respostas 10
  • Visualizações 3k
  • Created
  • Última resposta

Top Posters In This Topic

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.6k

Informação Importante

Confirmação de Termo