• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

VIP System [The Forgotten Server 1.0]

how to make that message after logging showed the player "You have a VIP access for x Days"?
and effect on player every 5 sec?
 
Updated to v0.2
- !checkvip command is now available
- You can set if the player should be teleported somewhere if he loses all vip days now
- You can set if the player should receive a message if he loses all vip days now
In order to access theses changes you have to update your vip-system.lua and follow the instructions on how to add !checkvip command

@CyCu91
In login.lua add:
Code:
    player:setStorageValue(9999, player:getVipDays())
below:
Code:
   player:updateVipTime()
!! Change 9999 to the storage Gesior is using, you can then access the amount of vip days in the storage value.

I do what you said, but now on my website, it say that everyone is vip ;p
 
This part,

player:loadVipData()
player:updateVipTime()

are crashing my server.. people cant even log in :(
using tfs 1.0
what should i need to do?
 
Is it possible in any way to add experience to this?
"If a players earns VIP days experience will be raised by 20% during the time the players has VIP days"

To answer my own question

replace this in player.lua under
-- Apply experience stage multiplier

Lua:
    if self:getVipDays() > 0 then
     exp = exp * Game.getExperienceStage(self:getLevel())*2
else
     exp = exp * Game.getExperienceStage(self:getLevel())
end
 
Last edited:
Extensions

- Note! You must edit Position(101, 116, 7) to your vip area position if using actionid 1501

- Note! You must edit Position(101, 116, 7) to your vip area position if using actionid 1503.

i try to understant what you mean by this but now idea.. i have to change it to exacly position where tp are located in vip room? but it not pass with doors :D
can you explain?


Is it possible in any way to add experience to this?
"If a players earns VIP days experience will be raised by 20% during the time the players has VIP days"

To answer my own question

replace this in player.lua under
-- Apply experience stage multiplier

Lua:
    if self:getVipDays() > 0 then
     exp = exp * Game.getExperienceStage(self:getLevel())*2
else
     exp = exp * Game.getExperienceStage(self:getLevel())
end

made it but not working at all.. nothing changed..
 
im using TFS 1.1

my login.lua and global.lua is diffrent, so i have no idea where i add the system..

Lua:
function onLogin(player)
  
    local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
    if player:getLastLoginSaved() <= 0 then
        loginStr = loginStr .. " Please choose your outfit."
        player:sendOutfitWindow()
    else
        if loginStr ~= "" then
            player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
        end

        loginStr = string.format("Your last visit was on %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
    end
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

    nextUseStaminaTime[player:getId()] = 0

    player:registerEvent("PlayerDeath")
    player:registerEvent("DropLoot")
    return true
end

dofile('data/lib/lib.lua')
ropeSpots = {384, 418, 8278, 8592, 13189, 14435, 14436, 15635, 19518}
doors = {[1209] = 1211, [1210] = 1211, [1212] = 1214, [1213] = 1214, [1219] = 1220, [1221] = 1222, [1231] = 1233, [1232] = 1233, [1234] = 1236, [1235] = 1236, [1237] = 1238, [1239] = 1240, [1249] = 1251, [1250] = 1251, [1252] = 1254, [1253] = 1254, [1539] = 1540, [1541] = 1542, [3535] = 3537, [3536] = 3537, [3538] = 3539, [3544] = 3546, [3545] = 3546, [3547] = 3548, [4913] = 4915, [4914] = 4915, [4916] = 4918, [4917] = 4918, [5082] = 5083, [5084] = 5085, [5098] = 5100, [5099] = 5100, [5101] = 5102, [5107] = 5109, [5108] = 5109, [5110] = 5111, [5116] = 5118, [5117] = 5118, [5119] = 5120, [5125] = 5127, [5126] = 5127, [5128] = 5129, [5134] = 5136, [5135] = 5136, [5137] = 5139, [5138] = 5139, [5140] = 5142, [5141] = 5142, [5143] = 5145, [5144] = 5145, [5278] = 5280, [5279] = 5280, [5281] = 5283, [5282] = 5283, [5284] = 5285, [5286] = 5287, [5515] = 5516, [5517] = 5518, [5732] = 5734, [5733] = 5734, [5735] = 5737, [5736] = 5737, [6192] = 6194, [6193] = 6194, [6195] = 6197, [6196] = 6197, [6198] = 6199, [6200] = 6201, [6249] = 6251, [6250] = 6251, [6252] = 6254, [6253] = 6254, [6255] = 6256, [6257] = 6258, [6795] = 6796, [6797] = 6798, [6799] = 6800, [6801] = 6802, [6891] = 6893, [6892] = 6893, [6894] = 6895, [6900] = 6902, [6901] = 6902, [6903] = 6904, [7033] = 7035, [7034] = 7035, [7036] = 7037, [7042] = 7044, [7043] = 7044, [7045] = 7046, [7054] = 7055, [7056] = 7057, [8541] = 8543, [8542] = 8543, [8544] = 8546, [8545] = 8546, [8547] = 8548, [8549] = 8550, [9165] = 9167, [9166] = 9167, [9168] = 9170, [9169] = 9170, [9171] = 9172, [9173] = 9174, [9267] = 9269, [9268] = 9269, [9270] = 9272, [9271] = 9272, [9273] = 9274, [9275] = 9276, [10276] = 10277, [10274] = 10275, [10268] = 10270, [10269] = 10270, [10271] = 10273, [10272] = 10273, [10471] = 10472, [10480] = 10481, [10477] = 10479, [10478] = 10479, [10468] = 10470, [10469] = 10470, [10775] = 10777, [10776] = 10777, [12092] = 12094, [12093] = 12094, [12188] = 12190, [12189] = 12190, [19840] = 19842, [19841] = 19842, [19843] = 19844, [19980] = 19982, [19981] = 19982, [19983] = 19984, [20273] = 20275, [20274] = 20275, [20276] = 20277, [17235] = 17236, [18208] = 18209, [13022] = 13023, [10784] = 10786, [10785] = 10786, [12099] = 12101, [12100] = 12101, [12197] = 12199, [12198] = 12199, [19849] = 19851, [19850] = 19851, [19852] = 19853, [19989] = 19991, [19990] = 19991, [19992] = 19993, [20282] = 20284, [20283] = 20284, [20285] = 20286, [17237] = 17238, [13020] = 13021, [10780] = 10781, [12095] = 12096, [12195] = 12196, [19845] = 19846, [19985] = 19986, [20278] = 20279, [10789] = 10790, [12102] = 12103, [12204] = 12205, [19854] = 19855, [19994] = 19995, [20287] = 20288, [10782] = 10783, [12097] = 12098, [12193] = 12194, [19847] = 19848, [19987] = 19988, [20280] = 20281, [10791] = 10792, [12104] = 12105, [12202] = 12203, [19856] = 19857, [19996] = 19997, [20289] = 20290}
verticalOpenDoors = {1211, 1220, 1224, 1228, 1233, 1238, 1242, 1246, 1251, 1256, 1260, 1540, 3546, 3548, 3550, 3552, 4915, 5083, 5109, 5111, 5113, 5115, 5127, 5129, 5131, 5133, 5142, 5145, 5283, 5285, 5289, 5293, 5516, 5737, 5749, 6194, 6199, 6203, 6207, 6251, 6256, 6260, 6264, 6798, 6802, 6902, 6904, 6906, 6908, 7044, 7046, 7048, 7050, 7055, 8543, 8548, 8552, 8556, 9167, 9172, 9269, 9274, 9274, 9269, 9278, 9282, 10270, 10275, 10279, 10283, 10479, 10481, 10485, 10483, 10786, 12101, 12199, 19851, 19853, 19991, 19993, 20284, 20286, 17238, 13021, 10790, 12103, 12205, 19855, 19995, 20288, 10792, 12105, 12203, 19857, 19997, 20290}
horizontalOpenDoors = {1214, 1222, 1226, 1230, 1236, 1240, 1244, 1248, 1254, 1258, 1262, 1542, 3537, 3539, 3541, 3543, 4918, 5085, 5100, 5102, 5104, 5106, 5118, 5120, 5122, 5124, 5136, 5139, 5280, 5287, 5291, 5295, 5518, 5734, 5746, 6197, 6201, 6205, 6209, 6254, 6258, 6262, 6266, 6796, 6800, 6893, 6895, 6897, 6899, 7035, 7037, 7039, 7041, 7057, 8546, 8550, 8554, 8558, 9170, 9174, 9272, 9276, 9280, 9284, 10273, 10277, 10281, 10285, 10470, 10472, 10476, 10474, 10777, 12094, 12190, 19842, 19844, 19982, 19984, 20275, 20277, 17236, 18209, 13023, 10781, 12096, 12196, 19846, 19986, 20279, 10783, 12098, 12194, 19848, 19988, 20281}
openSpecialDoors = {1224, 1226, 1228, 1230, 1242, 1244, 1246, 1248, 1256, 1258, 1260, 1262, 3541, 3543, 3550, 3552, 5104, 5106, 5113, 5115, 5122, 5124, 5131, 5133, 5289, 5291, 5293, 5295, 6203, 6205, 6207, 6209, 6260, 6262, 6264, 6266, 6897, 6899, 6906, 6908, 7039, 7041, 7048, 7050, 8552, 8554, 8556, 8558, 9176, 9178, 9180, 9182, 9278, 9280, 9282, 9284, 10279, 10281, 10283, 10285, 10474, 10476, 10483, 10485, 10781, 12096, 12196, 19846, 19986, 20279, 10783, 12098, 12194, 19848, 19988, 20281, 10790, 12103, 12205, 19855, 19995, 20288, 10792, 12105, 12203, 19857, 19997, 20290}
questDoors = {1223, 1225, 1241, 1243, 1255, 1257, 3542, 3551, 5105, 5114, 5123, 5132, 5288, 5290, 5745, 5748, 6202, 6204, 6259, 6261, 6898, 6907, 7040, 7049, 8551, 8553, 9175, 9177, 9277, 9279, 10278, 10280, 10475, 10484, 10782, 12097, 12193, 19847, 19987, 20280, 10791, 12104, 12202, 19856, 19996, 20289}
levelDoors = {1227, 1229, 1245, 1247, 1259, 1261, 3540, 3549, 5103, 5112, 5121, 5130, 5292, 5294, 6206, 6208, 6263, 6265, 6896, 6905, 7038, 7047, 8555, 8557, 9179, 9181, 9281, 9283, 10282, 10284, 10473, 10482, 10780, 10789, 10780, 12095, 12195, 19845, 19985, 20278, 10789, 12102, 12204, 19854, 19994, 20287}
keys = {2086, 2087, 2088, 2089, 2090, 2091, 2092, 10032}
function getDistanceBetween(firstPosition, secondPosition)
local xDif = math.abs(firstPosition.x - secondPosition.x)
local yDif = math.abs(firstPosition.y - secondPosition.y)
local posDif = math.max(xDif, yDif)
if firstPosition.z ~= secondPosition.z then
posDif = posDif + 15
end
return posDif
end
function getFormattedWorldTime()
local worldTime = getWorldTime()
local hours = math.floor(worldTime / 60)
local minutes = worldTime % 60
if minutes < 10 then
minutes = '0' .. minutes
end
return hours .. ':' .. minutes
end
string.split = function(str, sep)
local res = {}
for v in str:gmatch("([^" .. sep .. "]+)") do
res[#res + 1] = v
end
return res
end
string.trim = function(str)
return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)'
end
if nextUseStaminaTime == nil then
nextUseStaminaTime = {}
end

last step i don't quite get, you said:

"vip-system.lua
- create this file in your data folder
- !Note: You have to adjust the following lines to your needs:"
&
"paste the following code in the newly created file"

should i paste the last code in the vip-system.lua or create new one, if so what should i name the new lua and where to put it.

sorry for the noob questions but im kinda new to all of this..
 
ERROR VIP.png

I have this error on console. Getting error with "data.xxxxxx" for example data.days or data.lastDays
 
System works fine for me but I've got one problem. When editing the vipitems.lua (line 12 and 14 to be exact), saving the file and restarting the server, the changes I've made don't apply. No errors in console or anything it just goes with the original text that was put in.

e.g.

Lua:
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('!* VIP WOoHoo! *!', TALKTYPE_MONSTER_SAY)
    player:getPosition():sendMagicEffect(CONST_ME_YELLOW_RINGS)
    player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You received %s vip days!', days))
    Item(item.uid):remove(1)
    return true
end

This is my code

Lua:
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

This is the original. On using the specified items even after editing the file and restarting the server the old code is still in place rather the one with my edits.

Any ideas?



EDIT:

BIG MISTAKE ON MY SIDE! MADE DOUBLE COPIES OF THE SCRIPT BY ACCIDENT, SOLVED Lol.
 
Last edited:
TESTED ON TFS 1.3 Tibia 10.98 - WORKING GREAT

Almost everything working well i have just 1 question.

Why actionid 1502 and actionid 1503 can be use by players with no VIP? Can u add for me if player:isVip() to every door for me?
Code:
    <action actionid="1502" script="vipdoors.lua"/>
    <action actionid="1503" script="vipdoors.lua"/>

If u can to solve my problem i will be happy.
 
How to add to the script that players from vip get 10% extra exp ? +1

and any one tested in tfs 1.3 OTBR? klient 12.51 ?
 
Last edited:
How to add to the script that players from vip get 10% extra exp ? +1

and any one tested in tfs 1.3 OTBR? klient 12.51 ?
Its working with otbr lastr version.. im using it with their latest release

adding % for vip players isnt that hard ;)
right now i have premum and vip players, working side by side.and stackable xp, 50% from permmy + 20% from vip
 
Credits & Stuff
Credits go to @Printer for creating the original system (VIP System TFS [1.1] (http://otland.net/threads/vip-system-tfs-1-1.224758/)) upon which this system is based and which motivated me to work on it. Thanks for that.

This version uses a global variable to look up the current vip days of a player, so there is no need to use a mysql query each time you check if a player has vip status (which I assume is the most used function of the system).
I added support for infinite vip time and a talkaction for staff members.
If you miss any basic feature which might be helpful feel free to request it.
This version is supposed to work on The Forgotten Server 1.0 which you can download at Releases · otland/forgottenserver (https://github.com/otland/forgottenserver/releases).
I think I tested every case of the system if you however find any bugs / issues report them please or I might have messed up some copy & pasting.



System
MySQL queries
- execute those in your database
Code:
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`;

login.lua
  • this file is located in data/creaturescripts/scripts/ folder
  • add the following code after local player = Player(cid)
Code:
    player:loadVipData()
    player:updateVipTime()

global.lua
  • this file is located in data/ folder
  • add this code below dofile('data/compat.lua')
Code:
dofile('data/vip-system.lua')

vip-system.lua
  • create this file in your data folder
  • !Note: You have to adjust the following lines to your needs:
Code:
    -- 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
- paste the following code in the newly created file
Code:
--[[

# Vip System for The Forgotten Server 1.0
# https://github.com/otland/forgottenserver/releases (1.0)

# Vip System by Summ
## Version v0.2
## Link: http://otland.net/threads/vip-system-the-forgotten-server-1-0.224910/

# Credits to Printer upon whose script this is based
## Link: http://otland.net/threads/vip-system-tfs-1-1.224758/

# MySQL query
    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`;

]]

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

if i try to add vip columns in database but i don't have 'last day' in accounts.
i have new TFS 1.3.
 
Is it possible in any way to add experience to this?
"If a players earns VIP days experience will be raised by 20% during the time the players has VIP days"

To answer my own question

replace this in player.lua under
-- Apply experience stage multiplier

Lua:
    if self:getVipDays() > 0 then
     exp = exp * Game.getExperienceStage(self:getLevel())*2
else
     exp = exp * Game.getExperienceStage(self:getLevel())
end


In mine is like this, I try to change but just the error, what would be the correct way? Thanks

Lua:
    -- Experience Stage Multiplier
    local expStage = Game.getExperienceStage(self:getLevel())
    exp = exp * expStage
    baseExp = rawExp * expStage
    if Game.getStorageValue(GlobalStorage.XpDisplayMode) > 0 then
        displayRate = expStage
        else
        displayRate = 1
    end
 
In mine is like this, I try to change but just the error, what would be the correct way? Thanks

Lua:
    -- Experience Stage Multiplier
    local expStage = Game.getExperienceStage(self:getLevel())
    exp = exp * expStage
    baseExp = rawExp * expStage
    if Game.getStorageValue(GlobalStorage.XpDisplayMode) > 0 then
        displayRate = expStage
        else
        displayRate = 1
    end
paste your complete player.lua please
 
Back
Top