Perfect Vip system 3.0
Última atualização: 14/08/12
Versão Testada:TFS 0.3.6 - 8.54 - 8.6 - 9.6
Créditos pelas modificações: Kydrai,Vodkart e Marcryzius
Oque Contém no Sistema vip 3.0?
Comandos:
Query
Primeiro passado execute essa query na sua DB:
ALTER TABLE `players` ADD `vipacess` INT(15) NOT NULL DEFAULT 0;
Agora vá em Data/lib/050-function e adicione essas funções:
function getCharacterAcess(cid)
local query = db.getResult("SELECT `vipacess` FROM `players` WHERE `id` = "..getPlayerGUID(cid))
if query:getID() ~= -1 then return query:getDataInt("vipacess") end
end
function getCharacterDays(cid)
local acess = math.ceil((getCharacterAcess(cid) - os.time())/(86400))
return acess <= 0 and 0 or acess
end
function HaveCharaterAcess(cid)
return getCharacterDays(cid) > 0 and true or false
end
function setAcessTime(cid, time)
return db.executeQuery("UPDATE `players` SET `vipacess` = "..time.." WHERE `id` = "..getPlayerGUID(cid))
end
function addCharacterAcess(cid, days)
local add = (days <= 0 and 1 or days)*86400
local time = getCharacterDays(cid) == 0 and (os.time() + add) or (getCharacterAcess(cid) + add)
return setAcessTime(cid, time)
end
function doRemoveCharacterAcess(cid, days)
local remove = days*86400
local time = getCharacterAcess(cid) - remove
return setAcessTime(cid, (time <= 0 and 1 or time))
end
function getVipAcessDate(cid)
if HaveCharaterAcess(cid) then return os.date("%d/%m/%y %X", getCharacterAcess(cid)) end
return false
end
Talkactions
agora em talkactions/scripts
vipsystemplayer.lua
function onSay(cid, words, param)
if(words == "!buyvip") then
local days = 10
local price = 50000
if not doPlayerRemoveMoney(cid, price) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você precisa de "..price.." gp's para colocar vip.") return true
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Foram adicionados "..days.." dias de VIP no seu character.")
addCharacterAcess(cid, days)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem "..getCharacterDays(cid).." dias de VIP, ela acaba em "..getVipAcessDate(cid))
elseif(words == "!vipdays") then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem "..getCharacterDays(cid).." dias de VIP. "..(getCharacterDays(cid) > 0 and "ela acaba em "..getVipAcessDate(cid).."." or ""))
end
return true
end
vipsystemgod.lua
function onSay(cid, words, param)
if(words == "/checkvip") then
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") return true
end
local player = getPlayerByName(param)
if not isPlayer(player) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player "..player.." not found.") return true
end
return doPlayerPopupFYI(cid, "O jogador tem "..getCharacterDays(player).." dias de VIP no character.")
elseif(words == "/addvip") then
local t = string.explode(param, ",")
if not tonumber(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") return true
end
local player = getPlayerByNameWildcard(t[1])
if(not player)then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
end
addCharacterAcess(player, tonumber(t[2]))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você adicionou "..tonumber(t[2]).." dias de VIP no player "..getCreatureName(player))
doPlayerSendTextMessage(player, MESSAGE_INFO_DESCR, "Foram adicionados "..tonumber(t[2]).." dias de VIP no seu character.")
elseif(words == "/delvip") then
local t = string.explode(param, ",")
if not tonumber(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid param specified.") return true
end
local player = getPlayerByNameWildcard(t[1])
if(not player)then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player not found.")
end
doRemoveCharacterAcess(player, tonumber(t[2]))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você removeu "..tonumber(t[2]).." dias de VIP do jogador "..getCreatureName(player)..".")
end
return true
end
em talkactions.xml adicione as tags:
<talkaction words="!buyvip;!vipdays" event="script" value="vipsystemplayer.lua"/>
<talkaction words="/addvip;/delvip;/checkvip" access="4" event="script" value="vipsystemgod.lua"/>
Item Vip
item que adiciona vip no character
actions/script
addvipdays.lua
function onUse(cid, item, fromPosition, itemEx, toPosition)
local days = 15
addCharacterAcess(cid, (days <= 0 and 1 or days))
doRemoveItem(item.uid,1)
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você tem "..getCharacterDays(cid).." dias de VIP, ela acaba em "..getVipAcessDate(cid))
end
Actions.xml
<action itemid="ID DO SEU ITEM" script="addvipdays.lua"/>
Vip Door
actions/script
perfectvipdoor.lua
function onUse(cid, item, frompos, item2, topos)
if not HaveCharaterAcess(cid) then
return doPlayerSendTextMessage(cid,22,"Você precisa ser vip para passar aqui.")
end
doTransformItem(item.uid, item.itemid + 1)
doTeleportThing(cid, topos, true)
return true
end
actions.xml
<action actionid="7779" script="perfectvipdoor.lua"/>
Tile VIP
em movements/scripts crie um arquivo.lua e renomeie para
vipe.lua
function onStepIn(cid, item, position, fromPosition)
if item.actionid == 13700 and not HaveCharaterAcess(cid) then
doTeleportThing(cid, fromPosition, true)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"você não é vip.")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
return true
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"bem vindo.")
return true
end
Em movements.xml adicione a tag:
<movevent type="StepIn" actionid="13700" event="script" value="vipe.lua"/>
no seu piso coloque ACTIONID 13700
Fim Vip
em creaturescript/script
endvip.lua
function onLogin(cid)
if getCharacterDays(cid) > 0 then
setPlayerStorageValue(cid, 9898, 1)
elseif getPlayerStorageValue(cid, 9898) == 1 and getCharacterDays(cid) <= 0 then
doPlayerSetTown(cid, 1)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doPlayerPopupFYI(cid, "Sua vip Account acabou.")
setPlayerStorageValue(cid, 9898, -1)
end
return true
end
em creaturescript.xml adicione a tag:
<event type="login" name="CheckVip" script="endvip.lua"/>