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

Solved Convert script for tfs 1.2

flaviiojr

Active Member
Joined
Jan 20, 2017
Messages
230
Solutions
13
Reaction score
39
How to convert this script to tfs 1.2? Can help me, I tried in several places how to do, explain some functions, but do not explain others and the script is incomplete ...
Thank you. <3

Lua:
local BOSS_GLOBAL_STORAGE = 80510 -- to differentiate one from another boss
local TEMPO_SALA = 1 * 60 -- time to be kicked from the room (20 minutes)
local TEMPO_QUEST = 24 * 60 * 60 -- time to enter again on the boss room after killing one (24hours)
local STORAGE_TEMPO_ESPERAR = 22001 -- storage to count 24 hours
local BOSS = "Myruian" -- boss name
local room = {fromx = 33416, tox = 33446, fromy = 31254, toy = 31275, z = 11} -- area boss room
local PLAYER_OUT = {x = 33438, y = 31249, z = 11} -- where will be kicked
local UID_TELEPORT = 8001 -- uid of entrance teleport

function onKill(cid, target)
    if getCreatureName(target) == BOSS then
        setPlayerStorageValue(cid, STORAGE_TEMPO_ESPERAR, os.time() + TEMPO_QUEST)
        doSetItemActionId(UID_TELEPORT, 8001)
        if(getGlobalStorageValue(BOSS_GLOBAL_STORAGE + 1000) < 1) then
            setGlobalStorageValue(BOSS_GLOBAL_STORAGE + 1000, 1)
            addEvent(removePlayerMyruian, TEMPO_SALA * 1000)
        end
    end
    return true
end

-- REMOVE O JOGADOR SE EXCEDER O TEMPO
function removePlayerMyruian()

for x = room.fromx, room.tox do
for y = room.fromy, room.toy do
for z = room.z, room.z do

creature = {x = x, y = y, z = z}
mob = getTopCreature(creature).uid

if isPlayer(mob) then
    doTeleportThing(mob, PLAYER_OUT)
    doSendMagicEffect(PLAYER_OUT, CONST_ME_TELEPORT)
end
addEvent(storageMyruianDelay, 1000)
end
end
end
return TRUE
end

-- VOLTA O STORAGE AO NORMAL
function storageMyruianDelay()
    setGlobalStorageValue(BOSS_GLOBAL_STORAGE + 1000, -1)
    doSetItemActionId(UID_TELEPORT, 8000)
end
 
Solution
You use this file; forgottenserver/compat.lua at master · otland/forgottenserver · GitHub
If you load that file on start up you should be able to just run the script without converting it.
Lua:
local BOSS_GLOBAL_STORAGE = 80510 -- to differentiate one from another boss
local TEMPO_SALA = 1 * 60 -- time to be kicked from the room (20 minutes)
local TEMPO_QUEST = 24 * 60 * 60 -- time to enter again on the boss room after killing one (24hours)
local STORAGE_TEMPO_ESPERAR = 22001 -- storage to count 24 hours
local BOSS = "Myruian" -- boss name
local fromPosition = Position(33416, 31254, 11)
local toPosition = Position(33446, 31275, 11)
local PLAYER_OUT = Position(33438, 31249, 11) -- where will be kicked
local UID_TELEPORT = 8001 --...
You use this file; forgottenserver/compat.lua at master · otland/forgottenserver · GitHub
If you load that file on start up you should be able to just run the script without converting it.
Lua:
local BOSS_GLOBAL_STORAGE = 80510 -- to differentiate one from another boss
local TEMPO_SALA = 1 * 60 -- time to be kicked from the room (20 minutes)
local TEMPO_QUEST = 24 * 60 * 60 -- time to enter again on the boss room after killing one (24hours)
local STORAGE_TEMPO_ESPERAR = 22001 -- storage to count 24 hours
local BOSS = "Myruian" -- boss name
local fromPosition = Position(33416, 31254, 11)
local toPosition = Position(33446, 31275, 11)
local PLAYER_OUT = Position(33438, 31249, 11) -- where will be kicked
local UID_TELEPORT = 8001 -- uid of entrance teleport

function onKill(creature, target)
    if not creature:isPlayer() then
        return true
    end

    if target:getName() == BOSS then
        creature:setStorageValue(STORAGE_TEMPO_ESPERAR, os.time() + TEMPO_QUEST)
        local teleport = Item(UID_TELEPORT)
        if teleport then
            teleport:setActionId(8001)
        end

        if Game.getStorageValue(BOSS_GLOBAL_STORAGE + 1000) < 1 then
            Game.setStorageValue(BOSS_GLOBAL_STORAGE + 1000, 1)
            addEvent(removePlayerMyruian, TEMPO_SALA * 1000)
        end
    end
    return true
end

function removePlayerMyruian()
    for x = fromPosition.x, toPosition.x do
        for y = fromPosition.y, toPosition.y do
            for z = fromPosition.z, toPosition.y do
                local tile = Tile(x, y, z)
                if tile then
                    local creature = tile:getTopCreature()
                    if creature and creature:isPlayer() then
                        creature:teleportTo(PLAYER_OUT)
                        PLAYER_OUT:sendMagicEffect(CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end

    addEvent(storageMyruianDelay, 1000)
    return true
end

function storageMyruianDelay()
    Game.setStorageValue(BOSS_GLOBAL_STORAGE + 1000, -1)
    local teleport = Item(UID_TELEPORT)
    if teleport then
        teleport:setActionId(8000)
    end
end

That should work
 
Solution
Thank you very much for the help, and also thanks for the tip, with this I can already understand some scripts and study more intensely.
 
Back
Top