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

[globalevent] gate

Scooty

Enemia.EU
Joined
Jul 24, 2010
Messages
564
Reaction score
14
Location
Kraków
Hi! Can someone write this globalevent?

1.When globalevent start item with unique ID or action ID will remove(this item will be gate)
2.Gate came back(re-spawn) in 2 minutes.
3.After 10 minutes(from first point(remove gate) players who are in pos:

from:100,100,7
to:200,200,7

Will be teleported to temple.


@sorry for my english ;(
 
Try this.

globalevent:

LUA:
function onThink(pos,interval)
    setGlobalStorageValue(1650,1)
    addEvent(spawnGate,2*60*1000)
    return addEvent(teleportPlayers,10*60*1000)
end

local gatePos,gateID = {x=1,y=1,z=1},1111 --- change pos and itemid.
function spawnGate(pos)
    setGlobalStorageValue(1650,0)
    doCreateItem(gateID,1,gatePos)
    return doBroadcastMessage('The gate has been respawned')
end

local fromPos,toPos = {x=100,y=100,z=7},{x=200,y=200,z=7} -- Area
function teleportPlayers(pos)
local players = getPlayersOnline()
    for _,pid in ipairs(players) do
        if isInRange(getThingPos(pid),fromPos,toPos) then
            doTeleportThing(pid,getPlayerMasterPos(pid))
        end
    end
    return true
end

add this to actions.xml.
LUA:
local gatePos = {x=1,y=1,z=1}
function onUse(cid,item,fromPosition,toPosition,itemEx)
gatePos.stackpos = 253
    if getGlobalStorageValue(1650) ~= 0 then
        doRemoveItem(gatePos,1)
    else
        doPlayerSendCancel(cid,'Event not started.')
    end
    return true
end
 
O; i got idea cant it be like you can only use 1 time a day?
so like mm
Death Zone
a place only for lvls x+ can enter 60min a day can you make that?
 
LUA:
local pos =
{
	{x = 100, y = 100, z = 7, stackpos = 253}, --from
	{x = 200, y = 200, z = 7, stackpos = 253} --to
} 

local gatePos, gateId = {x = 150, y = 150, z = 7, stackpos = 1}, xxx
local spawnTime = 120 --in seconds
local kickTime = 600 --in seconds

function onThin(interval, lastExecution, thinkInterval)

	local gate = getTileThingByPos(gatePos)
	if gate.itemid == gateId and gate.uid == xxx then
		doRemoveItem(gate.uid)
		doBroadcastMessage("The gate has been removed.")
		addEvent(spawnGate, spawnTime * 1000, gateId, gatePos)
		addEvent(kickPlayers, kickTime * 1000, pos[1], pos[2])
	end
	return true
end

function spawnGate(id, pos)
	if doCreateItem(id, 1, pos) then
		doBroadcastMessage("The gaste has been respawned.")
	end
	return true
end

function kickPlayers(fromPos, toPos)
	for _, pid in ipairs(getPlayersOnline()) do
		if isInRange(getCreaturePosition(pid), fromPos, toPos) then
			doTeleportThing(pid, getPlayerMasterPos(pid))
			doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "You have been kicked.")
		end
	end
	return true
end
 
[10/09/2010 19:35:14] [Warning - Event::loadScript] Event onThink not found (data/globalevents/scripts/gate.lua)


hmmm ;) unknown666's script was good but i need event "removegate" in him script
 
Here, all in a globalevent, I misunderstood that you wanted an item to remove the gate.

LUA:
local gatePos = {x=1,y=1,z=1} -- gatepos
local getGate = getThingFromPos(gatePos)
function onThink(pos,interval)
    doRemoveItem(getGate.uid,1)
    setGlobalStorageValue(1650,1)
    addEvent(spawnGate,2*60*1000)
    return addEvent(teleportPlayers,10*60*1000)
end
 
local gateID = 1111 --- change itemid.
function spawnGate(pos)
    setGlobalStorageValue(1650,0)
    doCreateItem(gateID,1,gatePos)
    return doBroadcastMessage('The gate has been respawned')
end
 
local fromPos,toPos = {x=100,y=100,z=7},{x=200,y=200,z=7} -- Area
function teleportPlayers(pos)
local players = getPlayersOnline()
    for _,pid in ipairs(players) do
        if isInRange(getThingPos(pid),fromPos,toPos) then
            doTeleportThing(pid,getPlayerMasterPos(pid))
        end
    end
    return true
end
 
[10/09/2010 19:35:14] [Warning - Event::loadScript] Event onThink not found (data/globalevents/scripts/gate.lua)


hmmm ;) unknown666's script was good but i need event "removegate" in him script


Dont be so blind....... You will see a missing "k" in the function of darkhaos script so add it and use it.
 
globalevents.lua

PHP:
<globalevent name="gate" interval="7200" event="script" value="gate.lua"/>

globalevents/scripts/gate.lua

PHP:
local gatePos = {x=1029,y=1009,z=7} -- gatepos
local getGate = getThingFromPos(gatePos)
function onThink(pos,interval)
    doRemoveItem(getGate.uid,1)
    setGlobalStorageValue(1650,1)
    addEvent(spawnGate,2*60*1000)
    return addEvent(teleportPlayers,10*60*1000)
end
 
local gateID = 1547 --- change itemid.
function spawnGate(pos)
    setGlobalStorageValue(1650,0)
    doCreateItem(gateID,1,gatePos)
    return doBroadcastMessage('The gate has been respawned')
end
 
local fromPos,toPos = {x=1026,y=1010,z=7},{x=1031,y=1011,z=7} -- Area
function teleportPlayers(pos)
local players = getPlayersOnline()
    for _,pid in ipairs(players) do
        if isInRange(getThingPos(pid),fromPos,toPos) then
            doTeleportThing(pid,getPlayerMasterPos(pid))
        end
    end
    return true
end

but... any error.. Theforgottenserver crashing when starting.

 
Last edited:
I don't think it changes much, but try this.

LUA:
local gatePos = {x=1029,y=1009,z=7,stackpos=253} -- gatepos
local getGate = getThingFromPos(gatePos)
function onThink(pos,interval)
    addEvent(doRemoveGate,1*1000)
    addEvent(teleportPlayers,10*60*1000)
end
 
local gateID = 1547 --- change itemid.
function spawnGate(pos)
    setGlobalStorageValue(1650,0)
    doCreateItem(gateID,1,gatePos)
    return doBroadcastMessage('The gate has been respawned')
end
 
local fromPos,toPos = {x=1026,y=1010,z=7},{x=1031,y=1011,z=7} -- Area
function teleportPlayers(pos)
local players = getPlayersOnline()
    for _,pid in ipairs(players) do
        if isInRange(getThingPos(pid),fromPos,toPos) then
            doTeleportThing(pid,getPlayerMasterPos(pid))
        end
    end
    return true
end 

function doRemoveGate(pos)
    doBroadcastMessage('The gate has been removed for 2 minutes.')
    setGlobalStorageValue(1650,1)
    addEvent(spawnGate,2*60*1000)
    return doRemoveItem(getGate.uid)
end
 
Back
Top