• 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!

Lua Xikini's Free Scripting Service TFS 1.3

Status
Not open for further replies.

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
Please request
actions / creatureevents / globalevents / npcs / movements / talkactions

Do not request
spells / weapons / monsters / source editing / database queries

My goal of this thread is to learn TFS 1.3 scripting.

------------------------------------
Support

If you have an issue with one of my scripts, I will attempt to help you, but not in this thread.
Make a thread in the support board.
Ensure to follow all rules of the support board.
Without all neccesary information it's impossible to help you.

------------------------------------
I will only be scripting for TFS 1.3

Not TFS 1.1 / 1.2
Not OTServBR / OTX
and certainly not TFS 0.4

When requesting a script, don't ask for "this script I saw on super popular OT".

I don't care where the idea came from.
I don't want to see a video of the script in action.

I'm here to learn how to script better.
Just describe what the script is supposed to do, and I'll try to make it.

Any script that I make in response to a request from this thread will be shared publically, here, in this thread.

I'm not going to make anything in private, so post your request in this thread only.
Please, for the love of god, don't pm me asking to make a script.
I will actually add you to my ignore list if you do that.
--------------

Anyways!

Thanks for coming by and checking the thread out.
If you think there is a better way to script something, feel free to let me know.
I'm here to learn.

Cheers,

Xikini

----

Completed Scripts

DPS Dummy -> using RevScripts
!playerinfo character name -> using RevScripts
Positional Text talkaction -> using RevScripts
||--> Updated version that can use text & effects
Vocational Item Bonus's -> using RevScripts
||--> Updated version with easier config.
Simple damge buff potion -> using Revscripts
Kill monster in specific area, remove stone for x seconds -> using RevScripts
Training Room Teleporter -> using RevScripts
Lever that removes/adds/transforms objects or ground tiles -> using RevScripts
Loot from monster goes into single backpack, no matter how much loot there is.
Extra loot in monsters, based on chance and tier list -> using RevScripts
||--> Updated version that allows specific monsters to have their own loot table
Random Item chest that disappears after use, and respawns after x time -> using RevScripts
Multiple players required to open passageway.
Monster Arena Lever (x amount of waves, complete all waves, teleport appears) -> using RevScripts
Daily Boosted Creatures (experience & loot chance of items)
||--> Updated main file of boosted creatures, so that it triggers at midnight, instead of when the server starts up.
Reward Chest - Extremely simple. -> using Revscripts
Simple Npc that can sell an item, via text.

----

Extremely useful libs that I use quite often.

data/lib/core/player.lua
Give player items by table

data/lib/core/container.lua
getContainerFreeSlots

----

To-Do List

Shalaby - Player death counter. (Movement and talkaction)
Shalaby - Npc kill monster task, with item reward.
Shalaby - Boss respawn after x time.

-------

Last spot I've read messages
 
Last edited:
OP
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
Sure, I'll try to explain.

I have a random value defined by the "gamount" var in the script above, lets assume it randomized 157.
I want to separate that in two or three vars (whatever is possible)

Example:
hundredths = 1
rest = 57

Just so I could make a statement to add 39 platinum coins and 57 gold coins instead of adding like 3957 gold coins
Would need to do a bit of math trickery.
Lua:
local goldCoinAmount = 3957
local platinumCoinAmount = math.floor(goldCoinAmount/100)
goldCoinAmount = goldCoinAmount - (platinumCoinAmount * 100)

local text = "You received "
text = text .. (platinumCoinAmount > 0 and "" .. platinumCoinAmount .. " platinum coin" or "") .. (platinumCoinAmount > 1 and "s" or "")
text = text .. (goldCoinAmount > 0 and " and " or "")
text = text .. (goldCoinAmount > 0 and goldCoinAmount .. " gold coin" or "") .. (goldCoinAmount > 1 and "s" or "")

print(text .. ".")
 
Last edited:

Oneda

Aspiring Spriter
Joined
Dec 3, 2013
Messages
157
Solutions
2
Reaction score
90
Location
Brazil
Would need to do a bit of math trickery.
Lua:
local goldCoinAmount = 3957
local platinumCoinAmount = math.floor(goldCoinAmount/100)
goldCoinAmount = goldCoinAmount - (platinumCoinAmount * 100)

local text = "You received "
text = text .. (platinumCoinAmount > 0 and "" .. platinumCoinAmount .. " platinum coin" or "") .. (platinumCoinAmount > 1 and "s" or "")
text = text .. (goldCoinAmount > 0 and " and " or "")
text = text .. (goldCoinAmount > 0 and goldCoinAmount .. " gold coin" or "") .. (goldCoinAmount > 1 and "s" or "")

print(text .. ".")
Worked like a charm, thank you!
 

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,877
Solutions
37
Reaction score
1,095
Location
Germany
Done.
View attachment 55325
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local coinId = 24774
local coinCost = 42 -- gold coins
local coinsAmount = {}

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local function greetCallback(cid)
    npcHandler.topic[cid] = 0
    coinsAmount[cid] = 0
    return true
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
   
    local player = Player(cid)

    if msgcontains(msg, "buy") then
        npcHandler:say("How many store coins would you want to buy?", cid)
        npcHandler.topic[cid] = 1
       
    elseif npcHandler.topic[cid] == 1 then
        local amount = tonumber(msg) ~= nil
        if not amount then
            npcHandler:say("I'm unfamiliar with that number. How many store coins do you want to buy?", cid)
            return true
        end
        amount = tonumber(msg)
        if amount < 0 or amount > 1000000 then
            npcHandler:say("I'm unfamiliar with that number. How many store coins do you want to buy?", cid)
            return true
        end
        npcHandler:say("Would you like to purchase " .. amount .. " store coins for " .. (amount * coinCost) .. " gold coins?", cid)
        npcHandler.topic[cid] = 2
        coinsAmount[cid] = amount
       
    elseif npcHandler.topic[cid] == 2 then
        if not msgcontains(msg, "yes") then
            npcHandler:say("Another time then.", cid)
            npcHandler.topic[cid] = 0
            return true
        end
        local cost = coinsAmount[cid] * coinCost
        if player:getMoney() < cost then
            npcHandler:say("You do not have enough gold coins to make this purchase. Another time, maybe?", cid)
            npcHandler.topic[cid] = 0
            coinsAmount[cid] = 0
            return true
        end
        player:removeMoney(cost)
        player:addItem(coinId, coinsAmount[cid], true)
        npcHandler:say("I appreciate your business.", cid)
        npcHandler.topic[cid] = 0
        coinsAmount[cid] = 0
       
    end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


Quick question
how are you doing these gifs?
 

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,246
Solutions
71
Reaction score
585
Location
Hell
how are you doing these gifs?
Shia Labeouf Snl GIF
 
OP
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
is it still possible to ask for a script?
Yeah. Probably this weekend or next week I'm going to have a bunch of time to do some scripts from this thread.
Gonna try to do as many as I can.
 

Restles

fallen human nature
Joined
Jan 30, 2014
Messages
68
Solutions
1
Reaction score
35
Location
Poland
Thank you for the answer, so if I can do it, I would like a script that takes a certain amount of hp and mana of the character after logging out and after death I cordially greet
 
OP
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
Thank you for the answer, so if I can do it, I would like a script that takes a certain amount of hp and mana of the character after logging out and after death I cordially greet
I do not understand what you mean, at all. xD

Can you try to explain again, but differently?
 

tibiamaniak

New Member
Joined
Aug 15, 2020
Messages
15
Reaction score
2
its possible to do custom script?
example

if donate x tibia coins to store get benefits like special scroll and when use it gets special addon and mount like golden outfit and mount.
 

Restles

fallen human nature
Joined
Jan 30, 2014
Messages
68
Solutions
1
Reaction score
35
Location
Poland
I mean something like that, but it doesn't work
Lua:
local profesions = {
    { vocid=1, newvoc=2, mana=11, looktype=8, backhp=451, backmp=523 },
}

local value = {}

function onThink(creature, interval)
    player = Player(creature)

    for i=1, #profesions do
        value = profesions[i]
        if(player:getVocation() == value.vocid) then
            if(player:getMana() >= value.mana) then
                if(player:getStorageValue(504205) <= os.time()) then
                    player:setStorageValue(504205, os.time() + 2)
                    player:addMana(-value.mana)
                end
            else
                local outfit = player:getOutfit()
                outfit.lookType = value.looktype
                player:setOutfit(outfit)
                player:setVocation(value.newvoc)
                player:setMaxHealth(getCreatureMaxHealth(cid)-value.backhp)
                player:addHealth(-value.backhp)
                player:setMaxMana(getCreatureMaxMana(cid)-value.backmp)
                player:addMana(-value.backmp)
            end
 

tibiamaniak

New Member
Joined
Aug 15, 2020
Messages
15
Reaction score
2
I mean something like that, but it doesn't work
Lua:
local profesions = {
    { vocid=1, newvoc=2, mana=11, looktype=8, backhp=451, backmp=523 },
}

local value = {}

function onThink(creature, interval)
    player = Player(creature)

    for i=1, #profesions do
        value = profesions[i]
        if(player:getVocation() == value.vocid) then
            if(player:getMana() >= value.mana) then
                if(player:getStorageValue(504205) <= os.time()) then
                    player:setStorageValue(504205, os.time() + 2)
                    player:addMana(-value.mana)
                end
            else
                local outfit = player:getOutfit()
                outfit.lookType = value.looktype
                player:setOutfit(outfit)
                player:setVocation(value.newvoc)
                player:setMaxHealth(getCreatureMaxHealth(cid)-value.backhp)
                player:addHealth(-value.backhp)
                player:setMaxMana(getCreatureMaxMana(cid)-value.backmp)
                player:addMana(-value.backmp)
            end
can you pm to me // napisz pm do mnie
 

bolekx34

New Member
Joined
Feb 18, 2021
Messages
6
Reaction score
0
Witaj!
Hello!

Are you able to dodge the system and the critical system ??

And the second question .. Will tfs 1.3 manage to pop: critic when inflicting a critical hit to a monster / player?
 

Nokturno

Not a human
Joined
Aug 7, 2009
Messages
496
Solutions
2
Reaction score
358
Witaj!
Hello!

Are you able to dodge the system and the critical system ??

And the second question .. Will tfs 1.3 manage to pop: critic when inflicting a critical hit to a monster / player?
It doesnt have dodge system.
And the critical system togu has, its diferent than the one cipsoft use.
 
OP
OP
Xikini

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,810
Solutions
433
Reaction score
3,949
Updated this script to automatically grab all of the itemid and slot information, instead of having to put it all in manually.

Now you only need to setup the config table.

Lua:
local config  = {
    [1111] = { -- itemid
        slot = "ammo", -- ("head", "necklace", "backpack", "armor", "shield", "weapon", "legs", "feet", "ring", "ammo")
        {
            [{1, 5}] = { -- vocation 1 and vocation 5
                ["statMain"] = {
                    -- flat_bonus_stats
                    {"life increase", 50},
                    {"mana increase", -200}, -- negative numbers will reduce a players stats
                    {"magic", 5},
                    {"melee", 15}, -- sword/axe/club
                    {"fist", 5},
                    {"club", 5}, -- if both melee and club exist on a single item, club will be the one that will trigger.
                    {"sword", 5}, -- example: (melee 20) -> (sword 5) ----> Result: (club 20) (sword 5) (axe 20)
                    {"axe", 5},
                    {"distance", 5},
                    {"shield", 5},
                    {"fishing", 5},
                    {"critical hit chance", 5},
                    {"critical hit damage", 5},
                    {"life leech chance", 5},
                    {"life leech amount", 5},
                    {"mana leech chance", 5},
                    {"mana leech amount", 5},
                    -- percent_bonus_stats
                    {"life increase percent", 200}, -- If using flat_bonus_stats and percent_bonus_stats on the same item, the percent_bonus_stats is the only one that will trigger.
                    {"mana increase percent", 200}, -- same idea as melee/club, but for flat/percent
                    {"magic percent", 3000},
                    {"melee percent", 200},
                    {"fist percent", 200}, -- 200 = 200%  -> 15 fisting would turn into 30
                    {"club percent", 200},
                    {"sword percent", 200},
                    {"axe percent", 200},
                    {"distance percent", 200},
                    {"shield percent", 200},
                    {"fishing percent", 200}
                },
                ["statSpeed"] = {
                    {"speed", 1000} -- when testing, it only gave half of this value. Might just be my client though
                },
                ["statRegen"] = {
                    {"life regen", 5, 5000}, --{type, amount, ticks_in_milliseconds}
                    {"mana regen", 5, 5000}  -- (can't go lower then 1 second)
                },
                ["statSoulRegen"] = {
                    {"soul regen", 5, 5000}
                },
            },
            [{2, 6}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{3, 7}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{4, 8}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            }
        }
    },
    [2222] = {
        slot = "armor",
        {
            [{1, 5}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{2, 6}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{3, 7}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{4, 8}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            }
        }
    },
    [3333] = {
        slot = "ammo",
        {
            [{1, 5}] = {["statMain"] = {{"magic", 5}} },
            [{2, 6}] = {["statSpeed"] = {{"speed", 500}} },
            [{3, 7}] = {["statRegen"] = {{"life regen", 5, 5000}} },
            [{4, 8}] = {["statSoulRegen"] = {{"soul regen", 5, 5000}} }
        }
    }
}

local function convertSlotTextToNumber(slot)
    local text = nil
    if slot == "head" then
        slot = 1
    elseif slot == "necklace" then
        slot = 2
    elseif slot == "backpack" then
        slot = 3
    elseif slot == "armor" then
        slot = 4
    elseif slot == "shield" then
        slot = 5
    elseif slot == "weapon" then
        slot = 6
    elseif slot == "legs" then
        slot = 7
    elseif slot == "feet" then
        slot = 8
    elseif slot == "ring" then
        slot = 9
    elseif slot == "ammo" then
        slot = 10
    end
    return slot
end

local condition_ids = {
    CONDITIONID_HEAD,
    CONDITIONID_NECKLACE,
    CONDITIONID_BACKPACK,
    CONDITIONID_ARMOR,
    CONDITIONID_RIGHT,
    CONDITIONID_LEFT,
    CONDITIONID_LEGS,
    CONDITIONID_FEET,
    CONDITIONID_RING,
    CONDITIONID_AMMO
}

local conditions = {
    ["life increase"] = {CONDITION_PARAM_STAT_MAXHITPOINTS},
    ["mana increase"] = {CONDITION_PARAM_STAT_MAXMANAPOINTS},
    ["speed"] = {CONDITION_PARAM_SPEED},
    ["magic"] = {CONDITION_PARAM_STAT_MAGICPOINTS},
    ["melee"] = {CONDITION_PARAM_SKILL_MELEE},
    ["fist"] = {CONDITION_PARAM_SKILL_FIST},
    ["club"] = {CONDITION_PARAM_SKILL_CLUB},
    ["sword"] = {CONDITION_PARAM_SKILL_SWORD},
    ["axe"] = {CONDITION_PARAM_SKILL_AXE},
    ["distance"] = {CONDITION_PARAM_SKILL_DISTANCE},
    ["shield"] = {CONDITION_PARAM_SKILL_SHIELD},
    ["fishing"] = {CONDITION_PARAM_SKILL_FISHING},
    ["critical hit chance"] = {CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE},
    ["critical hit damage"] = {CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT},
    ["life leech chance"] = {CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE},
    ["life leech amount"] = {CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT},
    ["mana leech chance"] = {CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE},
    ["mana leech amount"] = {CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT},
    ["life increase percent"] = {CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT},
    ["mana increase percent"] = {CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT},
    ["magic percent"] = {CONDITION_PARAM_STAT_MAGICPOINTSPERCENT},
    ["melee percent"] = {CONDITION_PARAM_SKILL_MELEEPERCENT},
    ["fist percent"] = {CONDITION_PARAM_SKILL_FISTPERCENT},
    ["club percent"] = {CONDITION_PARAM_SKILL_CLUBPERCENT},
    ["sword percent"] = {CONDITION_PARAM_SKILL_SWORDPERCENT},
    ["axe percent"] = {CONDITION_PARAM_SKILL_AXEPERCENT},
    ["distance percent"] = {CONDITION_PARAM_SKILL_DISTANCEPERCENT},
    ["shield percent"] = {CONDITION_PARAM_SKILL_SHIELDPERCENT},
    ["fishing percent"] = {CONDITION_PARAM_SKILL_FISHINGPERCENT},
    ["life regen"] = {CONDITION_PARAM_HEALTHGAIN, CONDITION_PARAM_HEALTHTICKS},
    ["mana regen"] = {CONDITION_PARAM_MANAGAIN, CONDITION_PARAM_MANATICKS},
    ["soul regen"] = {CONDITION_PARAM_SOULGAIN, CONDITION_PARAM_SOULTICKS}
}

local main_attributes = {CONDITION_ATTRIBUTES, CONDITION_HASTE, CONDITION_REGENERATION, CONDITION_SOUL}
local main_stats = {"statMain", "statSpeed", "statRegen", "statSoulRegen"}

local function giveItemBonus(playerid)
    local player = Player(playerid)
    local player_equipment = {}
 
    -- find all player equipment
    for i = 1, 10 do
        local slotItem = player:getSlotItem(i)
        if slotItem then
            slotItem = slotItem.itemid
            if not config[slotItem] or convertSlotTextToNumber(config[slotItem].slot) ~= i then
                slotItem = 0
            end
        else
            slotItem = 0
        end
        table.insert(player_equipment, slotItem)
    end
 
    -- remove all buffs from armor
    for i = 1, 10 do
        for n = 1, 4 do
            if player:getCondition(main_attributes[n], condition_ids[i]) then
                player:removeCondition(main_attributes[n], condition_ids[i])
            end
        end
    end
 
    -- add all buffs from equipment
    local vocation = player:getVocation():getId()
    for i = 1, 10 do
        local itemID = player_equipment[i]
        if itemID ~= 0 then
            for voc, _ in pairs(config[itemID][1]) do
                if isInArray(voc, vocation) then
                    for n = 1, 4 do
                        if config[itemID][1][voc][main_stats[n]] then
                            local condition = Condition(main_attributes[n], condition_ids[i])
                            condition:setParameter(CONDITION_PARAM_TICKS, -1)
                            local itemBonusIndex = config[itemID][1][voc][main_stats[n]]
                            for h = 1, #itemBonusIndex do
                                for p = 1, #conditions[itemBonusIndex[h][1]] do
                                    condition:setParameter(conditions[itemBonusIndex[h][1]][p], itemBonusIndex[h][2])
                                end
                            end
                            player:addCondition(condition)
                        end
                    end
                end
            end
        end
    end
    return true
end


-- Equip ------------------------------------------------------------------------------
local equipSlot
local dodgeOnEquip = MoveEvent()

function dodgeOnEquip.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

for itemId, _ in pairs(config) do
    equipSlot = config[itemId].slot
    if config[itemId].slot == "weapon" or config[itemId].slot == "shield" then
        equipSlot = "hand"
    end
    dodgeOnEquip:slot(equipSlot)
    dodgeOnEquip:id(itemId)
end
dodgeOnEquip:register()

-- DeEquip ----------------------------------------------------------------------------
local dodgeOnDeEquip = MoveEvent()

function dodgeOnDeEquip.onDeEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

for itemId, _ in pairs(config) do
    equipSlot = config[itemId].slot
    if config[itemId].slot == "weapon" or config[itemId].slot == "shield" then
        equipSlot = "hand"
    end
    dodgeOnDeEquip:slot(equipSlot)
    dodgeOnDeEquip:id(itemId)
end
dodgeOnDeEquip:register()


-- LOGIN ------------------------------------------------------------------------------
local loginEvent = CreatureEvent("newLoginEvent")
loginEvent:type("login")

function loginEvent.onLogin(player)
    addEvent(giveItemBonus, 0, player:getId())
    return true
end

loginEvent:register()
 

Kabo Flow

New Member
Joined
May 17, 2020
Messages
50
Reaction score
4
Location
Mexico
Twitch
KaboFlow18
hi i wanted if you could create a script
I have TheRubyServer base
I wanted to know how to add a quest that gives you a pokemon at the end is by actions ,,,
is a TFS 1.3 base
 

Levi999x

AoT
Joined
Dec 14, 2017
Messages
1,877
Solutions
37
Reaction score
1,095
Location
Germany
hi i wanted if you could create a script
I have TheRubyServer base
I wanted to know how to add a quest that gives you a pokemon at the end is by actions ,,,
is a TFS 1.3 base

so item with actionid?

local item = player:addItem(itemID, 1)
item:setActionId(ActionID)
 
Status
Not open for further replies.
Top