Bem procurei aqui na comunidade um VIP System mais informativo e nada, além de ter tido problema com os que estão aqui e acabei achando em outro lugar um que funcionou perfeitamente para mim.
Usando tfs 1.2 disponibilizado por Bruno Minervino
Só estou trazendo o conteúdo e por não conhecer bem não posso dar suporte mas do jeito que está é só 'instalar' e vai funcionar.
Creditos.: Summ por fazer e a mim por uma ou duas alterações que estavam fazendo as portas funcionarem de forma estranha..
Sistema Vip
1° execute dentro da sua db
ALTER TABLE `accounts` ADD COLUMN `viplastday` int(10) NOT NULL DEFAULT 0 AFTER `lastday`, ADD COLUMN `vipdays` int(11) NOT NULL DEFAULT 0 AFTER `lastday`;
2º na pasta data/creaturescripts/scripts procure pelo arquivo login.lua e adicione na segunda linha, logo após o function onLogin(player) isso
player:loadVipData() player:updateVipTime()
3° na pasta data\ crie um arquivo chamado vipsystem.lua e adicione o seguinte
local config = { -- true = player will be teleported to this position if Vip runs out -- false = player will not be teleported useTeleport = true, expirationPosition = Position(95, 114, 7), -- true = player will received the message you set -- false = player will not receive a message useMessage = true, expirationMessage = 'Your vip days ran out.', expirationMessageType = MESSAGE_STATUS_WARNING } if not VipData then VipData = { } end function Player.onRemoveVip(self) if config.useTeleport then self:teleportTo(config.expirationPosition) config.expirationPosition:sendMagicEffect(CONST_ME_TELEPORT) end if config.useMessage then self:sendTextMessage(config.expirationMessageType, config.expirationMessage) end end function Player.getVipDays(self) return VipData[self:getId()].days end function Player.getLastVipDay(self) return VipData[self:getId()].lastDay end function Player.isVip(self) return self:getVipDays() > 0 end function Player.addInfiniteVip(self) local data = VipData[self:getId()] data.days = 0xFFFF data.lastDay = 0 db.query(string.format('UPDATE `accounts` SET `vipdays` = %i, `viplastday` = %i WHERE `id` = %i;', 0xFFFF, 0, self:getAccountId())) end function Player.addVipDays(self, amount) local data = VipData[self:getId()] local amount = math.min(0xFFFE - data.days, amount) if amount > 0 then if data.days == 0 then local time = os.time() db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` + %i, `viplastday` = %i WHERE `id` = %i;', amount, time, self:getAccountId())) data.lastDay = time else db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` + %i WHERE `id` = %i;', amount, self:getAccountId())) end data.days = data.days + amount end return true end function Player.removeVipDays(self, amount) local data = VipData[self:getId()] if data.days == 0xFFFF then return false end local amount = math.min(data.days, amount) if amount > 0 then db.query(string.format('UPDATE `accounts` SET `vipdays` = `vipdays` - %i WHERE `id` = %i;', amount, self:getAccountId())) data.days = data.days - amount if data.days == 0 then self:onRemoveVip() end end return true end function Player.removeVip(self) local data = VipData[self:getId()] if data.days == 0 then return end data.days = 0 data.lastDay = 0 self:onRemoveVip() db.query(string.format('UPDATE `accounts` SET `vipdays` = 0, `viplastday` = 0 WHERE `id` = %i;', self:getAccountId())) end function Player.loadVipData(self) local resultId = db.storeQuery(string.format('SELECT `vipdays`, `viplastday` FROM `accounts` WHERE `id` = %i;', self:getAccountId())) if resultId then VipData[self:getId()] = { days = result.getDataInt(resultId, 'vipdays'), lastDay = result.getDataInt(resultId, 'viplastday') } result.free(resultId) return true end VipData[self:getId()] = { days = 0, lastDay = 0 } return false end function Player.updateVipTime(self) local save = false local data = VipData[self:getId()] local days, lastDay = data.days, data.lastDay local daysBefore = days if days == 0 or days == 0xFFFF then if lastDay ~= 0 then lastDay = 0 save = true end elseif lastDay == 0 then lastDay = os.time() save = true else local time = os.time() local elapsedDays = math.floor((time - lastDay) / 86400) if elapsedDays > 0 then if elapsedDays >= days then days = 0 lastDay = 0 else days = days - elapsedDays lastDay = time - ((time - lastDay) % 86400) end save = true end end if save then if daysBefore > 0 and days == 0 then self:onRemoveVip() end db.query(string.format('UPDATE `accounts` SET `vipdays` = %i, `viplastday` = %i WHERE `id` = %i;', days, lastDay, self:getAccountId())) data.days = days data.lastDay = lastDay end end
4° no arquivo global.lua adicione a seguinte linha
dofile('data/vipsystem.lua')
Talkaction !checkvip para todos os players
1° vá na pasta data/talkactions/scripts e crie um arquivo chamando checkvip.lua e adicione o seguinte
function onSay(cid, words, param) local player = Player(cid) local days = player:getVipDays() if days == 0 then player:sendCancelMessage('You do not have any vip days.') else player:sendCancelMessage(string.format('You have %s vip day%s left.', (days == 0xFFFF and 'infinite amount of' or days), (days == 1 and '' or 's'))) end return false end
2° e em data/talkactions/talkactions.xml adicione
<talkaction words="!checkvip" script="checkvip.lua"/>
Talkaction /vip para membros da staff
- /vip adddays, NomedoPlayer, 5 --> Adiciona 5 dias vip para o Player. - /vip removedays, NomedoPlayer, 5 --> Remove 5 dias vip do Player. - /vip remove, PlayerName --> Remove todos os dias vip do Player. - /vip check, NomedoPlayer --> Checa quantos dias vip o Player tem. - /vip addinfinite, NomedoPlayer --> Adiciona tempo vip infinito para o Player.
1° na pasta data/talkactions/scripts crie um arquivo chamado vipcommand.lua e adicione o seguinte
function onSay(cid, words, param) local player = Player(cid) if not player:getGroup():getAccess() then return true end local params = param:split(',') if not params[2] then player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('Player is required.\nUsage:\n%s <action>, <name>, [, <value>]\n\nAvailable actions:\ncheck, adddays, addinfinite, removedays, remove', words)) return false end local targetName = params[2]:trim() local target = Player(targetName) if not target then player:sendCancelMessage(string.format('Player (%s) is not online. Usage: %s <action>, <player> [, <value>]', targetName, words)) return false end local action = params[1]:trim():lower() if action == 'adddays' then local amount = tonumber(params[3]) if not amount then player:sendCancelMessage('<value> has to be a numeric value.') return false end target:addVipDays(amount) player:sendCancelMessage(string.format('%s received %s vip day(s) and now has %s vip day(s).', target:getName(), amount, target:getVipDays())) elseif action == 'removedays' then local amount = tonumber(params[3]) if not amount then player:sendCancelMessage('<value> has to be a numeric value.') return false end target:removeVipDays(amount) player:sendCancelMessage(string.format('%s lost %s vip day(s) and now has %s vip day(s).', target:getName(), amount, target:getVipDays())) elseif action == 'addinfinite' then target:addInfiniteVip() player:sendCancelMessage(string.format('%s now has infinite vip time.', target:getName())) elseif action == 'remove' then target:removeVip() player:sendCancelMessage(string.format('You removed all vip days from %s.', target:getName())) elseif action == 'check' then local days = target:getVipDays() player:sendCancelMessage(string.format('%s has %s vip day(s).', target:getName(), (days == 0xFFFF and 'infinite' or days))) else player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('Action is required.\nUsage:\n%s <action>, <name>, [, <value>]\n\nAvailable actions:\ncheck, adddays, addinfinite, removedays, remove', words)) end return false end
2° e em data/talkactions/talkactions.xml adicione
<talkaction words="/vip" separator=" " script="vipcommand.lua" />
Tiles VIP
Os ids agem de forma diferente Tiles que tiverem id 1500 só serão passáveis caso o player seja vip Tiles que tiverem id 1501 são tiles tp, o player vip passa em cima e é transportado para a coord setana no começo do arquivo lua.
1° em data/movements/movements.xml e adicione
<movevent event="StepIn" actionid="1500" script="viptiles.lua"/> <movevent event="StepIn" actionid="1501" script="viptiles.lua"/>
2° em data/movements/script crie o arquivo viptiles.lua e adicione o seguinte
local vipPosition = Position(101, 116, 7) function onStepIn(cid, item, position, fromPosition) local player = Player(cid) if not player then return true end if item.actionid == 1500 then if not player:isVip() then player:teleportTo(fromPosition) fromPosition:sendMagicEffect(CONST_ME_POFF) player:sendCancelMessage('You do not have any vip days.') end elseif item.actionid == 1501 then if player:isVip() then player:teleportTo(vipPosition) player:say('!* VIP *!', TALKTYPE_MONSTER_SAY) vipPosition:sendMagicEffect(CONST_ME_STUN) else player:teleportTo(fromPosition) player:sendCancelMessage('You do not have any vip days.') fromPosition:sendMagicEffect(CONST_ME_POFF) end end return true end
Portas VIP / Actions
1° em data/actions/actions.xml adicione isso
<action actionid="1502" script="vipdoors.lua"/> <action actionid="1503" script="vipdoors.lua"/> <action actionid="1504" script="vipdoors.lua"/>
Os ids são referentes as portas, 1502 é uma porta norte/sul 1503 é uma porta leste/oeste 1504 é uma porta que da tp para um local definido no começo do arquivo vipdoors.lua
2° em data/actions/scripts crie um arquivo chamado vipdoors.lua e adicione o seguinte
local vipPosition = Position(1295, 1576, 7) function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey) local player = Player(cid) if item.actionid == 1502 then local position = player:getPosition() if player:isVip() then if position.y < fromPosition.y then fromPosition.y = fromPosition.y + 1 else fromPosition.y = fromPosition.y - 1 end player:teleportTo(fromPosition) player:say('!* VIP *!', TALKTYPE_MONSTER_SAY) fromPosition:sendMagicEffect(CONST_ME_STUN) else player:sendCancelMessage('You do not have any vip days.') end elseif item.actionid == 1503 then local position = player:getPosition() if player:isVip() then if position.x < fromPosition.x then fromPosition.x = fromPosition.x + 1 else fromPosition.x = fromPosition.x - 1 end player:teleportTo(fromPosition) player:say('!* VIP *!', TALKTYPE_MONSTER_SAY) fromPosition:sendMagicEffect(CONST_ME_STUN) else player:sendCancelMessage('You do not have any vip days.') end elseif item.actionid == 1504 then if player:isVip() then player:teleportTo(vipPosition) player:say('!* VIP *!', TALKTYPE_MONSTER_SAY) vipPosition:sendMagicEffect(CONST_ME_STUN) else player:sendCancelMessage('You do not have any vip days.') end end return true end
Items que adicionam dias VIP
ItemId 10135 adiciona 10 dias vip. ItemId 10134 adiciona 30 dias vip. ItemId 10133 adiciona 90 dias vip.
1° em data/actions/actions.xml adicione
<action fromid="10133" toid="10135" script="vipitems.lua"/>
2° e em data/actions/scripts crie um arquivo chamado vipitems.lua e adicione o seguinte
local vipItems = { -- [itemid] = amount of vip days [10135] = 10, [10134] = 30, [10133] = 90 } function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey) local player = Player(cid) local days = vipItems[item.itemid] player:addVipDays(days) player:say('!* YAY VIP! *!', TALKTYPE_MONSTER_SAY) player:getPosition():sendMagicEffect(CONST_ME_STUN) player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You received %s vip days.', days)) Item(item.uid):remove(1) return true end
Imagens
Comando !checkvip mas sem ter vip
Comando /vip adddays, dracoknight, 5
Comando !checkvip após adicionar 5 dias
Comando /vip addinfinite, dracoknight
Comando !checkvip após usar infinite
Comando /vip remove, dracoknight