• 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
Senator
Premium User
Joined
Nov 17, 2010
Messages
6,811
Solutions
582
Reaction score
5,370
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:
to your answer if an actionid that gives you a pokemon I mean that it gives you an item
I think he means that I have no idea what a 'pokemon' is or entails.

If it's just a simple item.. then use this.
 
I think he means that I have no idea what a 'pokemon' is or entails.

If it's just a simple item.. then use this.

local reward1 = {2160, 1} -- {itemid, amount}
local reward2 = {2160, 1} -- {itemid, amount}
local reward3 = {2160, 1} -- {itemid, amount}

It works for me, but even though I'm looking for a pokemon, but that helps me to implement a quest to the server, even though it could be more than 1 item?
that you also have experience
and I teleport you
Post automatically merged:

and Done. :)
Note: don't trap your players. 😋

View attachment 49241


Put this into any monster you want the script to activate for.
XML:
<script>
    <event name="onDeath_open_passageway" />
</script>

data\scripts\ onDeath_open_passageway.lua
Lua:
local config = {
    positionCheck = {north_west = Position(99, 99, 7), south_east = Position(101, 101, 7)},
    item = {Position(103, 100, 7), 1285}, -- {item_position, itemid}
    timer = 20, -- timer is how long until the 'stone' aka: item, is replaced.
    discoveryText = "A passageway has opened nearby!\nQuickly, get inside!"
}

local toggle = 0
local function changePassageway()
    local item = Tile(config.item[1]):getItemById(config.item[2])
    if item then
        item:remove()
        return true
    end
    config.item[1]:sendMagicEffect(CONST_ME_BIGPLANTS)
    Game.createItem(config.item[2], 1, config.item[1])
    toggle = 0
end

local creatureevent = CreatureEvent("onDeath_open_passageway")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if toggle == 1 then
        return true
    end
    local deathPosition = creature:getPosition()
    if not deathPosition:isInRange(config.positionCheck.north_west, config.positionCheck.south_east) then
        return true
    end
    toggle = 1
    config.item[1]:sendMagicEffect(CONST_ME_POFF)
    changePassageway()
    addEvent(changePassageway, config.timer * 1000)
    creature:say(config.discoveryText, TALKTYPE_MONSTER_SAY, false, nil, deathPosition)   
    return true
end

creatureevent:register()

sorry for my ignorance but where do I add it to make the system work
 
Last edited:
@Nokturno Your "Random Item chest that disappears after use, and respawns after x time" script is finished.

I was semi-absent for awhile soo... sorry if you no longer need this.

View attachment 54293

data\scripts\ disappearingLootChest.lua
Lua:
--[[

Install this
https://otland.net/threads/tfs-1-x-give-player-items-by-table.260702/#post-2643954

]]--

--[[
__  __     _      _        _               _   
\ \/ /    (_)    | |__    (_)    _ _      (_)  
  >  <     | |    | / /    | |   | ' \     | |  
/_/\_\   _|_|_   |_\_\   _|_|_  |_||_|   _|_|_ 
_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|
"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'

]]--

local rewardsTable = {
    [45000] = {
        containerId = 10522, -- itemid of bag/backpack that holds items
        chestReturnTime = 10, -- in seconds.
        magicEffect = CONST_ME_TELEPORT,
        {2173, 5, 5, 2500},
        {2160, 1, 5, 10000}  --{itemid, amount_min, amount_max, chance/10000}
    },
    [45001] = {
        containerId = 1988,
        chestReturnTime = 5, -- 5 * 60 would be 5 minutes
        magicEffect = CONST_ME_TELEPORT,
        {2173, 5, 5, 2500},
        {2152, 1, 5, 10000}
    },
    [45002] = {
        containerId = 1987,
        chestReturnTime = 2,
        magicEffect = CONST_ME_TELEPORT,
        {2148, 1, 5, 10000},
        {2148, 1, 5, 10000},
        {2173, 5, 5, 2500},  -- 25% chance
        {2148, 1, 5, 10000}, -- 100% chance
        {2148, 1, 5, 10000}
    },
}

local function lootChestDeAndReappear(position, chestId, actionId, effect, timer)
    position:sendMagicEffect(effect)
    if timer > 0 then
        -- remove chest
        Tile(position):getItemById(chestId):remove()
        addEvent(lootChestDeAndReappear, timer, position, chestId, actionId, effect, 0)
    else
        -- reAdd chest with actionid
        local chest = Game.createItem(chestId, 1, position)
        chest:setActionId(actionId)
    end
end

local disappearingLootChest = Action()

function disappearingLootChest.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    -- confirm index exists
    local actionId = item:getActionId()
    local index = rewardsTable[actionId]
    if not index then
        print("LUA error: ActionId not in table." .. item:getActionId())
        return true
    end
   
    -- check chances and create rewardItems table
    local rewardItems = {}
    local amount = 0
    for i = 1, #index do
        if math.random(10000) <= index[i][4] then
            amount = math.random(index[i][2], index[i][3])
            table.insert(rewardItems, {index[i][1], amount})
        end
    end

    -- give rewardItems if any exist
    if #rewardItems > 0 then
        player:giveItems(rewardItems, index.containerId and index.containerId > 0 and index.containerId or 1987)
    end
   
    -- remove and reAdd the chest
    lootChestDeAndReappear(toPosition, item:getId(), actionId, index.magicEffect, index.chestReturnTime * 1000)
    return true
end

for actionid, _ in pairs(rewardsTable) do
    disappearingLootChest:aid(actionid) -- adds all actionid's from rewardsTable
end
disappearingLootChest:register()

Hey, add this and the other one that you told me, but on the server when you click it, it doesn't give anything, it just opens the box and I already have to add the quest in another place apart from actionid?
Post automatically merged:

duda.png

yes lose but when doing it as well as in the TFS 1
They do not pull example the item quest adds it to the actionid and in the RME and when entering the server I open the box and it does not pull it does not give me anything
Post automatically merged:



error poke.png
 
Last edited:
Hey, add this and the other one that you told me, but on the server when you click it, it doesn't give anything, it just opens the box and I already have to add the quest in another place apart from actionid?
Post automatically merged:

View attachment 56301

yes lose but when doing it as well as in the TFS 1
They do not pull example the item quest adds it to the actionid and in the RME and when entering the server I open the box and it does not pull it does not give me anything
Post automatically merged:



View attachment 56302
looks like your server doesn't have revscripts.
You'd have to convert the script into regular actions
 
hi i looking for revscript multi reward chest like anihilator or demon oak.
example:
player can pick up only one chest from 4 chest
i need this script with addon, exp, item, mount
 
I need script for TFS 0.3.7 - Addon Lever.
You had to put needed addon items for any addon on a table and pull a lever -> %&^#$&POOF -> addon unlocked) :)

Can you do this for me? :)
 
You can extract first login from database using db.storeQuery, it should be located in players table. Last death would be most likely more complex, but again a query to player_deaths and conditional to look for most recent death. (time column)
I thinking about going back and adding the extra portions in.
Seems a waste to leave it out, and gives me a reason to learn database queries.

Will have to wait until my sleep schedule it better though. xD
I always end up scripting when I'm super tired. 🤷‍♂️

very nice thread and initiative!


well you could try using vocation:getRequiredManaSpent(magicLevel) to achieve this in a simple way.


I have a request tho, if you don't mind :p it will be very useful to the community (and players of course), to have a working Imbuing, system, but I thought about a really simple system (idea from this thread), no modal window involved so it can be used on lower tibia versions:

"Imbuing system" Adding attributes to items by slot

talkactions, for example

!imbue head, life leech, basic

and it will give player SPECIALSKILL_LIFELEECHCHANCE, 100 and SPECIALSKILL_LIFELEECHAMOUNT, 5 for 20 hours, at cost of 5k and 25 Vampire Teeth


okay, this seems a little more complicated than I thought as of writing it now 😁 If anyone feels like giving ideas on how to make it easier/more conceivable, I'm all ears
If I do this system, I'd rather do it in modal windows tbh.
Need to learn how they work. xP

I can do it with talkactions as well though.. or an npc?
I would just split/explode the strings apart and compare/evaluate them against a table.

Let me know which way you'd prefer.

I would like to see a script which allows players to buy inactive houses
As explain if someone has a House and hes more than 14+ days Inactive you can use a Command like
!inactivehouse but you must stand infront of the house door of the inactive player house
If the player is inactive more than 14 days the house will be sold and the guy can buy it normaly with !buyhouse
If the player is not inactive you getting a message with "Player name is not inactive"
Exhaustion Time of using command 30 seconds
Don't think this one is happening, as the entire thing is basically database queries.
This is similar, but made for TFS 1.2
It'll probably work?
Guildmaster npc just like in the old days, here you can make your guild/invite new members/kick members/disband guild/give members an nickname.
Adding this to my to-do list, so I can learn about guild functions.
Idk how useful the script itself will be though.. since you can literally do all of these things through the standard default websites everyone installs.

---------------

I've added a to-do list in the first post.

and I've basically fallen in love with RevScripts.
Everything about a system in a single file.. it's just so sexy.

Unless I absolutely have to script something differently, I'm going to be using RevScripts for everything.
 
Status
Not open for further replies.
Back
Top