Bom, eu vou explicar o sistema... A maior parte do sistema vip usar o globalevent para remover um dia de vip a cada 24 horas, mas, e se o seu serv tem 23 horas de uptime é um problema. O dia não poderia ser removido, até eu fixar ele, agora o dia de vip será removido em uma hora específica, se você configurá-lo para duas horas, o dia vip será removido em duas horas por isso, se o serv cair para ele como 3 minutos ainda irá remover os dias vip em duas horas.
Ele funciona para toda a conta, assim como uma conta premium.
Testado em TheForgottenServer 0.3.6 / 0.4
Este sistema VIP contém:
-
Próprias funções Lua
-
Automática removedor dia.
-
OnLogin script para verificar vip.
-
Remover Comando Dias Vip.
-
Adicionar comando Dias Vip.
-
Auto teleporter templo quando vipdays mais!.
Agora vamos da incio ao nosso Tutorial.
1° Execute isso no seu phpmyadmin.
ALTER TABLE `accounts` ADD `vipdays` int(11) NOT NULL DEFAULT 0;
2° Vai até data/lib/function.lua e adicione isto na primeira linha:
--- Vip functions by Kekox function getPlayerVipDays(cid) local Info = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1") if Info:getID() ~= LUA_ERROR then local days= Info:getDataInt("vipdays") Info:free() return days end return LUA_ERROR end function doAddVipDays(cid, days) db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";") end function doRemoveVipDays(cid, days) db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";") end
3° Vai até data/creaturescript/scripts/login.lua e registrar esse coder:
registerCreatureEvent(cid, "VipCheck")
E logo após crie um arquivo com o nome vipcheck.lua dentro de data/creaturescript/scripts/ e adicione dentro do arquivo criado este coder:
--- Script by Kekox function onLogin(cid) if getPlayerVipDays(cid) >= 1 then doPlayerSendTextMessage(cid, 19, "You have ".. getPlayerVipDays(cid) .." vip days left.") end return true end
E em data/creaturescript/creaturescripts.xml:
<event type="login" name="VipCheck" event="script" value="vipcheck.lua"/>
4° Agora vei até data/globalevents/scripts/ crie um arquivo.lua com o nome daysremover.lua e adicione este coder ao arquivo criado:
--- Script by Kekox function onTimer() db.executeQuery("UPDATE accounts SET vipdays = vipdays - 1 WHERE vipdays > 0;") return true end
E logo após em data/globalevents/globalevents.xml adicione:
<globalevent name="VipDaysRemover" time="00:01" event="script" value="daysremover.lua"/>
Você pode alterar o tempo quando: (hora = "00:01").
Se você tem um dia a mais ou a menos de vip, quando você fizer login vai receber uma mensagem:

VIP Tile
5º Agora vamos até data/movements/scripts/viptile.lua Adicione este coder:
--- Script by Kekox function onStepIn(cid, item, position, fromPosition) if getPlayerVipDays(cid) == 0 then doTeleportThing(cid, fromPosition, FALSE) end return true end
E logo após em data/movements/movements.xml
<movevent type="StepIn" actionid="13500" event="script" value="viptile.lua"/>
VIP days command
6° Vai até data/talkactions/scripts/adddays.lua Adicone este coder:
--- Script by Kekox. function onSay(cid, words, param, channel) if(param == '') then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") return true end local t = string.explode(param, ",") t[1] = tonumber(t[1]) if(not t[1]) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.") return true end local pid = cid if(t[2]) then pid = getPlayerByNameWildcard(t[2]) if(not pid) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.") return true end end if(t[1] > 365) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can only add max 365 vip days.") return true end sender = getPlayerByNameWildcard(cid) doAddVipDays(pid, t[1]) doPlayerSendTextMessage(cid, "You have added ".. t[1] .." vip days to ".. t[2]) doPlayerSendTextMessage(pid, sender .." just added you ".. t[1] .." vip days.") return true end
Em data/talkactions/talkactions.xml/ adicione:
<talkaction log="yes" words="/adddays" access="5" event="script" value="adddays.lua"/>
Remove VIP days command
7° Em data/talkactions/scripts/removedays.lua adicione:
--- Script by Kekox fixed by Shawak. function onSay(cid, words, param, channel) if(param == '') then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") return true end local t = string.explode(param, ",") t[1] = tonumber(t[1]) if(not t[1]) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.") return true end local pid = cid if(t[2]) then pid = getPlayerByNameWildcard(t[2]) if(not pid) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.") return true end end if(t[1] > 365) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can only add max 365 vip days.") return true end sender = getPlayerByNameWildcard(cid) doRemoveVipDays(pid, t[1]) doPlayerSendTextMessage(cid, "You have removed ".. t[1] .." vip days to ".. t[2]) doPlayerSendTextMessage(pid, sender .." just removed you ".. t[1] .." vip days.") return true end
E em data/talkactions/scripts/talkactions.xml/ adicione:
<talkaction log="yes" words="/removedays" access="5" event="script" value="removedays.lua"/>
VIP Door
8° Em data/actions/scripts/vipdoor.lua adicione:
function onUse(cid, item, frompos, item2, topos) if getPlayerVipDays(cid) >= 1 then pos = getPlayerPosition(cid) if pos.x == topos.x then if pos.y < topos.y then pos.y = topos.y + 1 else pos.y = topos.y - 1 end elseif pos.y == topos.y then if pos.x < topos.x then pos.x = topos.x + 1 else pos.x = topos.x - 1 end else doPlayerSendTextMessage(cid,22,"Stand in front of the door.") return true end doTeleportThing(cid,pos) doSendMagicEffect(topos,12) else doPlayerSendTextMessage(cid,22,'Only VIP Account can go there.') end return true end
Em data/actions/actions.xml adicione:
<action actionid="2112" event="script" value="vipdoor.lua"/>
Effect only for VIP players
9° Em globalevents/scripts/vipEffect.lua adicione:
function onThink(interval, lastExecution) for _, name in ipairs(getOnlinePlayers()) do local cid = getPlayerByName(name) if getPlayerVipDays(cid) >= 1 then doSendMagicEffect(getPlayerPosition(cid), 27) doSendAnimatedText(getPlayerPosition(cid), "VIP!", TEXTCOLOR_RED) end end return true end
Em data/globalevents/globalevents.xml adicione:
<globalevent name="vipEffect" interval="2" script="vipEffect.lua"/>
Auto temple teleporter quando VIP days acabar!
10° Em data/creaturescripts/scripts/templeteleport.lua adicione:
function onLogin(cid) if getPlayerVipDays(cid) > 0 then setPlayerStorageValue(cid, 20500, 1) elseif getPlayerVipDays(cid) == 0 and getPlayerStorageValue(cid, 20500) == 1 then doTeleportThing(cid, getPlayerMasterPos(cid)) setPlayerStorageValue(cid, 20500, -1) end return true end
Em data/creaturescripts/scripts/login.lua register:
registerCreatureEvent(cid, "TempleTeleporter")
E em data/creaturescripts/creaturescripts.xml adicione:
<event type="login" name="TempleTeleporter" event="script" value="templeteleport.lua"/>
Functions usadas:
- getPlayerVipDays(cid) --- Usá-lo para verificar quantos dias vip o jogador tem.
- doAddVipDays(cid, days) --- Use-o para adicionar dias vip para alguém.
- doRemoveVipDays(cid, days) --- Use-a para remover dias vip para alguém.
Creditos:
Kekox