• 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 Fury Gate

lordfelipe

New Member
Joined
Sep 29, 2008
Messages
21
Reaction score
0
Hello,
I have tried to make some script to show Fury Gate locations but didn't get a good result...

Can anyone help me to create a script to broadcast a message when login or a php/mysql script to connect to website showing its location?

Used .lua just below

Code:
function onStartup(interval)
    if (math.random(1,6) == 1) then -- venore
        setGlobalStorageValue(9710, 1)
        doCreateItem(7853, {x = 32833, y = 32081, z = 7})
        doCreateItem(7851, {x = 32834, y = 32081, z = 7})
        doCreateItem(5066, {x = 32834, y = 32081, z = 7})
        doCreateItem(5066, {x = 32833, y = 32081, z = 7})
        gate1 = doCreateItem(6116, {x = 32834, y = 32081, z = 7})
        doSetItemActionId(gate1, 9710)
        print('>> Fury Gate is at venore.')
        broadcastMessage("Fury Gate is at Venore.", MESSAGE_STATUS_WARNING)
    elseif (math.random(1,6) == 2) then -- ab'dendriel
        setGlobalStorageValue(9711, 1)
        doCreateItem(7853, {x = 32679, y = 31719, z = 7})
        doCreateItem(7851, {x = 32680, y = 31719, z = 7})
        doCreateItem(5066, {x = 32680, y = 31719, z = 7})
        doCreateItem(5066, {x = 32679, y = 31719, z = 7})
        gate2 = doCreateItem(6116, {x = 32680, y = 31719, z = 7})
        doSetItemActionId(gate2, 9711)
        print('>> Fury Gate hoje it at ab dendriel.')
        broadcastMessage("Fury Gate is at Ab'dendriel.", MESSAGE_STATUS_WARNING)
    elseif (math.random(1,6) == 3) then -- thais
        setGlobalStorageValue(9712, 1)
        doCreateItem(5064, {x = 32264, y = 32163, z = 7})
        doCreateItem(5064, {x = 32264, y = 32164, z = 7})
        doCreateItem(7852, {x = 32264, y = 32164, z = 7})
        doCreateItem(7853, {x = 32264, y = 32163, z = 7})
        doCreateItem(5064, {x = 32265, y = 32163, z = 7})
        doCreateItem(5064, {x = 32265, y = 32164, z = 7})
        gate3 = doCreateItem(6117, {x = 32264, y = 32164, z = 7})
        doSetItemActionId(gate3, 9712)
        print('>> Fury Gate is at thais.')
        broadcastMessage("Fury Gate is at Thais.", MESSAGE_STATUS_WARNING)
    elseif (math.random(1,6) == 4) then -- carlin
        setGlobalStorageValue(9713, 1)
        doCreateItem(5066, {x = 32262, y = 31848, z = 7})
        doCreateItem(5066, {x = 32263, y = 31848, z = 7})
        doCreateItem(7853, {x = 32262, y = 31848, z = 7})
        doCreateItem(7851, {x = 32263, y = 31848, z = 7})
        gate4 = doCreateItem(6116, {x = 32263, y = 31848, z = 7})
        doSetItemActionId(gate4, 9713)
        print('>> Fury Gate is at carlin.')
        broadcastMessage("Fury Gate is at Carlin.", MESSAGE_STATUS_WARNING)
    elseif (math.random(1,6) == 5) then -- edron
        setGlobalStorageValue(9714, 1)
        doCreateItem(5066, {x = 33220, y = 31922, z = 7})
        doCreateItem(5066, {x = 33221, y = 31922, z = 7})
        doCreateItem(7853, {x = 33220, y = 31922, z = 7})
        doCreateItem(7851, {x = 33221, y = 31922, z = 7})
        doCreateItem(5066, {x = 33220, y = 31923, z = 7})
        doCreateItem(5066, {x = 33221, y = 31923, z = 7})
        gate5 = doCreateItem(6116, {x = 33221, y = 31922, z = 7})
        doSetItemActionId(gate5, 9714)
        print('>> Fury Gate is at edron.')
        broadcastMessage("Fury Gate is at Edron.", MESSAGE_STATUS_WARNING)
    elseif (math.random(1,6) == 6) then -- kazordoon
        setGlobalStorageValue(9716, 1)
        doCreateItem(5066, {x = 32573, y = 31982, z = 7})
        doCreateItem(5066, {x = 32574, y = 31982, z = 7})
        doCreateItem(7853, {x = 32573, y = 31982, z = 7})
        doCreateItem(7851, {x = 32574, y = 31982, z = 7})
        gate6 = doCreateItem(6116, {x = 32574, y = 31982, z = 7})
        doSetItemActionId(gate6, 9716)
        print('>> Fury Gate is at kazordoon.')
        broadcastMessage("Fury Gate is at Kazordoon.", MESSAGE_STATUS_WARNING)
    end
end
 
Code:
if (math.random(1,6) == 1) then -- venore
bro don't use it ..
use:
Code:
local chance = math.random(1, 6)
to use in if and elseif
Code:
if chance == 1  then -- venore
you can put a msg in login with the globalStorage
but aff this script is a little shit :S it put diferents storages to the same function
... you need to chance the storages
Code:
setGlobalStorageValue(9711, 1)
setGlobalStorageValue(9712, 1)
setGlobalStorageValue(9713, 1)
setGlobalStorageValue(9714, 1)
setGlobalStorageValue(9715, 1)
setGlobalStorageValue(9716, 1)
to
Code:
SetGlobalStorageValue(9710, HERE YOU PUT THE VALUE OF EACH CITY)
and then put in the login.lua
Code:
if getGlobalStorageValue(9710) == 1 then -- for venore
      doPlayerSendTextMessage("YOUR MSG FOR VENORE")
elseif getGlobalStorageValue(9710) == 2 then -- for ab...
      doPlayerSendTextMessage("YOUR MSG FOR AB\'DENDRIEL")
........
 
Last edited:
if (math.random(1,6) == 1) then -- venore
bro don't use it ..
use:
local chance = math.random(1, 6)
to use in if and elseif
if chance == 1 then -- venore
you can put a msg in login with the globalStorage
but aff this script is a little shit :S it put diferents storages to the same function
... you need to chance the storages
setGlobalStorageValue(9711, 1)
setGlobalStorageValue(9712, 1)
setGlobalStorageValue(9713, 1)
setGlobalStorageValue(9714, 1)
setGlobalStorageValue(9715, 1)
setGlobalStorageValue(9716, 1)
to SetGlobalStorageValue(9710, HERE YOU PUT THE VALUE OF EACH CITY)
and then put in the login.lua
if getGlobalStorageValue(9710) == 1 then -- for venore
doPlayerSendTextMessage("YOUR MSG FOR VENORE")
elseif getGlobalStorageValue(9710) == 2 then -- for ab...
doPlayerSendTextMessage("YOUR MSG FOR AB\'DENDRIEL")
........
You're right in most of the cases.
But depending on which tfs he is using, you have to use different functions.
For TFS 1.0 im using
PHP:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Text goes here.")
with local defined as
PHP:
local player = Player(cid)


And please for gods sake... use proper tags and split your messages. I barerly could read it ...
 
You're right in most of the cases.
But depending on which tfs he is using, you have to use different functions.
For TFS 1.0 im using
PHP:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Text goes here.")
with local defined as
PHP:
local player = Player(cid)


And please for gods sake... use proper tags and split your messages. I barerly could read it ...
i'm sorry for it, i'll edit all to make more understandable ..
about the tfs, seems TFS 1.0 .. this script is from tibia king :S
 
Code:
    local items = {
        [1] = {
            { id = 7853, pos = {x = 32833, y = 32081, z = 7} },
            { id = 7851, pos = {x = 32834, y = 32081, z = 7} },
            { id = 5066, pos = {x = 32834, y = 32081, z = 7} },
            { id = 5066, pos = {x = 32833, y = 32081, z = 7} },
            msg = "Venore",
            gStorage = 9710,
            gate = function() return doCreateItem(6116, {x = 32834, y = 32081, z = 7} ) end
          
        },
        [2] = {
            { id = 7853, pos = {x = 32679, y = 31719, z = 7} },
            { id = 7851, pos = {x = 32680, y = 31719, z = 7} },
            { id = 5066, pos = {x = 32680, y = 31719, z = 7} },
            { id = 5066, pos = {x = 32679, y = 31719, z = 7} },
            msg = "Ab'dendriel",
            gStorage = 9711,
            gate = function() return doCreateItem(6116, {x = 32680, y = 31719, z = 7} ) end
        },
        [3] = {
            { id = 5064, pos = {x = 32264, y = 32163, z = 7} },
            { id = 5064, pos = {x = 32264, y = 32164, z = 7} },
            { id = 7852, pos = {x = 32264, y = 32164, z = 7} },
            { id = 7853, pos = {x = 32264, y = 32163, z = 7} },
            { id = 5064, pos = {x = 32265, y = 32163, z = 7} },
            { id = 5064, pos = {x = 32265, y = 32164, z = 7} },
            msg = "Thais",
            gStorage = 9712,
            gate = function() return doCreateItem( 6117, {x = 32264, y = 32164, z = 7} ) end
        },
        [4] = {
            { id = 5066, pos = {x = 32262, y = 31848, z = 7} },
            { id = 5066, pos = {x = 32263, y = 31848, z = 7} },
            { id = 7853, pos = {x = 32262, y = 31848, z = 7} },
            { id = 7851, pos = {x = 32263, y = 31848, z = 7} },
            msg = "Carlin",
            gStorage = 9713,
            gate = function() return doCreateItem( 6116, {x = 32263, y = 31848, z = 7} ) end
        },
        [5] = {
            { id = 5066, pos = {x = 33220, y = 31922, z = 7} },
            { id = 5066, pos = {x = 33221, y = 31922, z = 7} },
            { id = 7853, pos = {x = 33220, y = 31922, z = 7} },
            { id = 7851, pos = {x = 33221, y = 31922, z = 7} },
            { id = 5066, pos = {x = 33220, y = 31923, z = 7} },
            { id = 5066, pos = {x = 33221, y = 31923, z = 7} },
            msg = "Edron",
            gStorage = 9714,
            gate = function() return doCreateItem( 6116, {x = 33221, y = 31922, z = 7} ) end
        },
        [6] = {
            { id = 5066, pos = {x = 32573, y = 31982, z = 7} },
            { id = 5066, pos = {x = 32574, y = 31982, z = 7} },
            { id = 7853, pos = {x = 32573, y = 31982, z = 7} },
            { id = 7851, pos = {x = 32574, y = 31982, z = 7} },
            msg = "Kazordoon",
            gStorage = 9716,
            gate = function() return doCreateItem( 6116, {x = 32574, y = 31982, z = 7} ) end
        }
    }
  

function onStartup(interval)
    local function getRandomGate(rv)
        setGlobalStorageValue(items[rv].gStorage, 1)
        for i = 1, #items[rv] - 3 do
            doCreateItem(items[rv][i].id, items[rv][i].pos)
        end
         doSetItemActionId(items[rv].gate(), items[rv].gStorage)
         print('>> Fury Gate is at '..(items[rv].msg:lower())..'.')
         broadcastMessage("Fury Gate is at "..items[rv].msg..".", MESSAGE_STATUS_WARNING)
    end
    getRandomGate(math.floor( math.random(1, 6) ) )
    return true
end
 
Code:
    local items = {
        [1] = {
            { id = 7853, pos = {x = 32833, y = 32081, z = 7} },
            { id = 7851, pos = {x = 32834, y = 32081, z = 7} },
            { id = 5066, pos = {x = 32834, y = 32081, z = 7} },
            { id = 5066, pos = {x = 32833, y = 32081, z = 7} },
            msg = "Venore",
            gStorage = 9710,
            gate = function() return doCreateItem(6116, {x = 32834, y = 32081, z = 7} ) end
         
        },
        [2] = {
            { id = 7853, pos = {x = 32679, y = 31719, z = 7} },
            { id = 7851, pos = {x = 32680, y = 31719, z = 7} },
            { id = 5066, pos = {x = 32680, y = 31719, z = 7} },
            { id = 5066, pos = {x = 32679, y = 31719, z = 7} },
            msg = "Ab'dendriel",
            gStorage = 9711,
            gate = function() return doCreateItem(6116, {x = 32680, y = 31719, z = 7} ) end
        },
        [3] = {
            { id = 5064, pos = {x = 32264, y = 32163, z = 7} },
            { id = 5064, pos = {x = 32264, y = 32164, z = 7} },
            { id = 7852, pos = {x = 32264, y = 32164, z = 7} },
            { id = 7853, pos = {x = 32264, y = 32163, z = 7} },
            { id = 5064, pos = {x = 32265, y = 32163, z = 7} },
            { id = 5064, pos = {x = 32265, y = 32164, z = 7} },
            msg = "Thais",
            gStorage = 9712,
            gate = function() return doCreateItem( 6117, {x = 32264, y = 32164, z = 7} ) end
        },
        [4] = {
            { id = 5066, pos = {x = 32262, y = 31848, z = 7} },
            { id = 5066, pos = {x = 32263, y = 31848, z = 7} },
            { id = 7853, pos = {x = 32262, y = 31848, z = 7} },
            { id = 7851, pos = {x = 32263, y = 31848, z = 7} },
            msg = "Carlin",
            gStorage = 9713,
            gate = function() return doCreateItem( 6116, {x = 32263, y = 31848, z = 7} ) end
        },
        [5] = {
            { id = 5066, pos = {x = 33220, y = 31922, z = 7} },
            { id = 5066, pos = {x = 33221, y = 31922, z = 7} },
            { id = 7853, pos = {x = 33220, y = 31922, z = 7} },
            { id = 7851, pos = {x = 33221, y = 31922, z = 7} },
            { id = 5066, pos = {x = 33220, y = 31923, z = 7} },
            { id = 5066, pos = {x = 33221, y = 31923, z = 7} },
            msg = "Edron",
            gStorage = 9714,
            gate = function() return doCreateItem( 6116, {x = 33221, y = 31922, z = 7} ) end
        },
        [6] = {
            { id = 5066, pos = {x = 32573, y = 31982, z = 7} },
            { id = 5066, pos = {x = 32574, y = 31982, z = 7} },
            { id = 7853, pos = {x = 32573, y = 31982, z = 7} },
            { id = 7851, pos = {x = 32574, y = 31982, z = 7} },
            msg = "Kazordoon",
            gStorage = 9716,
            gate = function() return doCreateItem( 6116, {x = 32574, y = 31982, z = 7} ) end
        }
    }
 

function onStartup(interval)
    local function getRandomGate(rv)
        setGlobalStorageValue(items[rv].gStorage, 1)
        for i = 1, #items[rv] - 3 do
            doCreateItem(items[rv][i].id, items[rv][i].pos)
        end
         doSetItemActionId(items[rv].gate(), items[rv].gStorage)
         print('>> Fury Gate is at '..(items[rv].msg:lower())..'.')
         broadcastMessage("Fury Gate is at "..items[rv].msg..".", MESSAGE_STATUS_WARNING)
    end
    getRandomGate(math.floor( math.random(1, 6) ) )
    return true
end
bro, why broadCast in server startup?
who is online ? not have people online when server up, this script will run at the server start, will broadcast the message too much fast, and no players will see, the message need to be at the login.lua
 
bro, why broadCast in server startup?
who is online ? not have people online when server up, this script will run at the server start, will broadcast the message too much fast, and no players will see, the message need to be at the login.lua
All I did was re-write the script, the person who wants to use it on their server can execute it in any interface they like :)

Plus this allows them to see there are different ways to write a script, I have all sorts of things happening in the script other than just relying solely on the tfs functions. :)

Another plus, building scripts using this structures makes updating them or porting them to other distro's a lot easier, because the code is designed to be reuseable :)
 
Last edited:
Thanks for all replies.. what I did was..

globalevents/furygate.lua
Code:
function onStartup(interval)
    Game.setStorageValue(GlobalStorage.FuryGates, math.random(6))
end

movements/furygate.lua
Code:
local gates = {
    [9710] = {value = 1, position = Position(32834, 32082, 7)},
    [9711] = {value = 2, position = Position(32680, 31720, 7)},
    [9712] = {value = 3, position = Position(32268, 32162, 7)},
    [9713] = {value = 4, position = Position(32263, 31847, 7)},
    [9714] = {value = 5, position = Position(33221, 31921, 7)},
    [9716] = {value = 6, position = Position(32574, 31981, 7)}
}

local exitPositions = {
    [1] = Position(32834, 32082, 7),
    [2] = Position(32680, 31720, 7),
    [3] = Position(32268, 32162, 7),
    [4] = Position(32263, 31847, 7),
    [5] = Position(33221, 31921, 7),
    [6] = Position(32574, 31981, 7)
}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    if isInArray({9710, 9711, 9712, 9713, 9714, 9716}, item.actionid) then
        local gate = gates[item.actionid]
        if not gate then
            return true
        end

        position:sendMagicEffect(CONST_ME_TELEPORT)

        if Game.getStorageValue(GlobalStorage.FuryGates) ~= gate.value then
            player:teleportTo(gate.position)
            gate.position:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end

        if player:getLevel() < 60 then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have to be at least level 60 to enter this gate.')
            player:teleportTo(gate.position)
            gate.position:sendMagicEffect(CONST_ME_TELEPORT)
            return true
        end

        local destination = Position(33290, 31786, 13)
        player:teleportTo(destination)
        destination:sendMagicEffect(CONST_ME_FIREAREA)
    else
        local destination = exitPositions[Game.getStorageValue(GlobalStorage.FuryGates)]
        if not destination then
            return true
        end

        position:sendMagicEffect(CONST_ME_TELEPORT)
        player:teleportTo(destination)
        destination:sendMagicEffect(CONST_ME_FIREAREA)
    end
    return true
end
Code:
<movevent event="StepIn" fromaid="9710" toaid="9716" script="others/furygate.lua" />

But it isn't creating the teleport.. what am I doing wrong?
 
Back
Top