Este é o sistema de Vip Account do Mock, convertido ao TFS 1.1 e TFS 1.2, utilizando a nova funcionalidade de concatenação.
Vip System:
Em data/lib/core/core.lua adicione a seguinte linha:
dofile('data/lib/core/vipsystem.lua')Ainda em data/lib/core crie um arquivo chamado vipsystem com o seguinte conteúdo:
function Player.getVip(self) if not self:isPlayer() then error('Player don\'t find') end local query = db.storeQuery("SELECT `vip_time` FROM `accounts` WHERE `id` = '" .. self:getAccountId() .. "';") if not query then return 0 end local days = result.getDataInt(query, "vip_time") or 0 result.free(query) return days end function Player.setVip(self, time) dofile("config.lua") assert(tonumber(time), 'Parameter must be a number') if not self:isPlayer() then error('Player don\'t find') end db.query("UPDATE `accounts` SET `vip_time` = '" .. ( os.time() + time ) .. "' WHERE `accounts`.`id` ='" .. self:getAccountId() .. "';") end function Player.isVip(self) if not self:isPlayer() then return end local t = self:getVip() or 0 if os.time(day) < t then return true else return false end end function getDays(days) return (3600 * 24 * days) end function Player.addVipByAccount(self, time) assert(tonumber(time), 'Parameter must be a number') local a = self:getVip() a = os.difftime(a, os.time()) if a < 0 then a = 0 end a = a + time return self:setVipByAccount(a) end function Player.setVipByAccount(self, time) assert(tonumber(time), 'Parameter must be a number') dofile("config.lua") db.query("UPDATE `accounts` SET `vip_time` = '" ..(os.time() + time) .. "' WHERE `accounts`.`id` ='" .. self:getAccountId() .. "';") return true end function Player.returnVipString(self) if self:isPlayer() then return os.date("%d %B %Y %X ", self:getVip()) end end
Piso Vip:
Em data/movements/movements.xml adicione a seguinte tag:
<movevent event="StepIn" actionid="13500" script="viptile.lua"/>Agora em data/movements/scripts crie um arquivo chamado viptile.lua com o seguinte conteúdo:
function onStepIn(creature, item, position, fromPosition) if not creature:isPlayer() or not creature:isVip() then creature:teleportTo(fromPosition) creature:getPosition():sendMagicEffect(CONST_ME_POFF) creature:sendCancelMessage("Area destinada a jogadores Vip.") return false end creature:sendTextMessage(MESSAGE_EVENT_ORANGE, "Bem vindo a Area Vip.") creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) return true endAgora basta criar um tile com a actionid 13500 utilizando um map editor.
Talkaction para Add Vip:
Em data/talkactions/talkactions.xml adicione a seguinte tag:
<talkaction words="/vip" separator=" " script="addvip.lua" />Agora em data/talkactions/scripts crie um arquivo chamado addvip.lua com o seguinte conteúdo:
function onSay(player, words, param) if param == "" then doPlayerPopupFYI(player, "Esta com problemas?\n---------------\nAdicionar vip:\n/vip add days player\n/vip add 30 Diabolic=\n---------------\n") return false end if param:lower():find('add') == 1 and 3 then local _, _, id, name = param:lower():find('add (%d+) (.+)') name = name or "" local p = Player(name) id = tonumber(id or 1) or 1 if id == nil then doPlayerPopupFYI(player, "Adicionar vip:\n/vip add days player\n---------------\nExemplo:\n/vip add 30 Diabolic") return false elseif not p then player:sendCancelMessage("O jogador " .. name .. " nao existe ou nao esta online.") return false end if p:isPlayer()then p:addVipByAccount(getDays(id)) player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Foram adicionados " .. id .. " dias de vip a jogador " .. name .. ".") p:sendTextMessage(MESSAGE_EVENT_ORANGE, "Voce recebeu " .. id .. " dias de vip.") else player:sendCancelMessage(name .. " nao esta online ou nao existe.") return false end end return false endÉ só usar o comando, por exemplo: /vip add 30 Bruno
Créditos:
Bruno Minervino
Mock