• 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 Last man Standing Event 100% Working

patriciou

Member
Joined
Dec 26, 2009
Messages
180
Reaction score
6
Hello Otlanders.

Today i Would like to present a LMS - Last man Standing Events with Broadcast

What is Last man Standing Event?
LMS - It's an Event in which Players have to Fight to Survive and Win certain Rewards
This should show some people new InGame Tactics or Techniques which could be
then used by them in Battle.

*The Event contains Broadcast which Tells the Users about the Event
*The Event Restarts every 2h ( Can be changed )
*Every 2h Teleport appears for 120 Seconds in certain Area
*Min players - 12 ( Can be Changed )

So lets get to the Script

In GlobalEvents/Scripts - Create new Folder called LMS and Inside the Folder Create
A File Called arena.lua

PHP:
local t = {
 tmp = {
 {x = 1111, y = 1111, z = 7}, -- North west corner of Area where players must stand in order to join the event
 {x = 1111, y = 1111, z = 7} -- South east corner of Area
 },
 arena = {
 {x = 1111, y = 1111, z = 7}, -- North west Corner of Arena
 {x = 1111, y = 1111, z = 7}, -- South East corner of Arena
 {x = 1111, y = 1111, z = 7} -- Center of Arena
 },

 from = {x = 351, y = 1340, z = 6}, -- Top left cornor of the playground (random players teleportation)
 to = {x = 366, y = 1350, z = 6}, -- Bottom right cornor of the playground (random players teleportation)

 minPlayers = 2, -- min players required to start the battle
 noPlayers = 1, -- Leave it as it is
 prize = {6527} -- Reward that player recives
 }
 local kick = 0

 function onThink()
 local arenaPlayers = {}

 for x = t.arena[1].x, t.arena[2].x do
 for y = t.arena[1].y, t.arena[2].y do
 for z = t.arena[1].z, t.arena[2].z do
 local pos = {x = x, y = y, z = z}
 local n = getTileInfo(pos).creatures
 if n ~= 0 then
 pos.stackpos = 1
 local c = getThingfromPos(pos)
 while c.uid ~= 0 do
 if c.itemid == 1 and c.type == 1 then
 table.insert(arenaPlayers, c.uid)
 if #arenaPlayers == n then
 break
 end
 end
 pos.stackpos = pos.stackpos + 1
 c = getThingfromPos(pos)
 end
 end
 end
 end
 end

 if #arenaPlayers == 1 then
 local p = getPlayerMasterPos(arenaPlayers[1])
 doTeleportThing(arenaPlayers[1], p)
 doSendMagicEffect(p, CONST_ME_TELEPORT)
 doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You have won the event and received your reward.")
 doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")
 doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 10)
 kick = 0
 elseif #arenaPlayers > 1 then
 if kick == 0 then
 kick = os.time()
 else
 if os.time() - kick >= 840 then
 kick = 0
 for i = 1, #arenaPlayers do
 doTeleportThing(arenaPlayers[i], {x=32345, y=32225, z=7})
 doPlayerSendTextMessage(arenaPlayers[i], MESSAGE_STATUS_WARNING, "Too even, try harder next time.")
 end
 end
 end
 elseif #arenaPlayers == 0 then
 kick = 0

 local players = {}
 for x = t.tmp[1].x, t.tmp[2].x do
 for y = t.tmp[1].y, t.tmp[2].y do
 for z = t.tmp[1].z, t.tmp[2].z do
 local c = getTopCreature({x = x, y = y, z = z})
 if c.type == 1 then
 table.insert(players, c.uid)
 end
 end
 end
 end

 if #players >= t.minPlayers then
 for i = 1, #players do
 local p = {x = math.random(t.from.x, t.to.x), y = math.random(t.from.y, t.to.y), z = math.random(t.from.z, t.to.z)}
 doTeleportThing(players[i], p)
 doSendMagicEffect(p, CONST_ME_TELEPORT)
 doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
 end
else
 for i = 1, #players do
 doTeleportThing(players[i], {x=876, y=1025, z=7})
 doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The event didn't start because there isn't enough players in area!")
 end
 end
 end
 return true
 end


Next in the Same folder we have to Create a lua file Called Lastman.lua

PHP:
local createpos = {x=273,y=1330,z=6} -- Every 2h where will the Teleport Appear
 local topos = {x=385,y=1345,z=7} -- Where will the Teleport take you
 local msg = "Last man standing event TP has now been closed! It will open again in 2 hours! All participants get Ready for a Fight!"
 local timetoclose = 120 -- in second

 local function remove()
 local tp = getTileItemById(createpos,1387).uid
 if tp ~= 0 then
 doRemoveItem(tp)
 doBroadcastMessage(msg)
 end
 end

 function onThink(interval)
 doCreateTeleport(1387, topos, createpos)
 doBroadcastMessage("Last man standing event TP is now open!\nCatch the teleport within "..timetoclose.." seconds! Teleport is Located in Events Room.")
 addEvent(remove,timetoclose*1000)
 return true
 end


Now in Globalevents.xml add these 2 lines

PHP:
	<globalevent name="LastMan" interval="36000" event="script" value="lms/lastman.lua"/>
	<globalevent name="arena" interval="36150" event="script" value="lms/arena.lua"/>



CORRECT CONFIG OF THE SCRIPT

PHP:
 {x = 382, y = 1343, z = 7}, -- northwest corner of area where players must stand in order to join the event
 {x = 389, y = 1346, z = 7} -- south east corner
 },
 arena = {
 {x = 349, y = 1338, z = 6}, -- nw corner of arena
 {x = 368, y = 1352, z = 6}, -- se corner of arena
 {x = 358, y = 1345, z = 6} -- center of arena
 },

 from = {x = 351, y = 1340, z = 6}, -- top left cornor of the playground (random players teleportation)
 to = {x = 366, y = 1350, z = 6}, -- bottom right cornor of the playground (random players teleportation)

 minPlayers = 2, -- min players required to start the battle
 noPlayers = 1, -- no players
 prize = {6527} -- rewards
 }


As you can see below, There are 2 Lines -

PHP:
 {x = 382, y = 1343, z = 7}, -- northwest corner of area where players must stand in order to join the event
 {x = 389, y = 1346, z = 7} -- south east corner

Area where players must stand in order to Join the Event...
This means that after entering the Teleport, Player will be teleported to
The Waiting room. After the teleport closing, Everybody that Were in the
Waiting room will be teleported to the Arena...

After the Battle the winner will have to wait at-least 30 Seconds before receiving a Reward.

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

These 3 Lines -
PHP:
 {x = 349, y = 1338, z = 6}, -- nw corner of arena
 {x = 368, y = 1352, z = 6}, -- se corner of arena
 {x = 358, y = 1345, z = 6} -- center of arena
 },

Here you have to Selected right coordinations of the Arena in Which players
will fight for the Reward.

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

PHP:
local createpos = {x=273,y=1330,z=6}
 local topos = {x=385,y=1345,z=7}
 local msg = "Last man standing event TP has now been closed! It will open again in 2 hours! All participants get Ready for a Fight!"
 local timetoclose = 120 -- in second

In the Lastman.lua File

You have got...

Where will the Teleport appear after 2h of time
After entering the Teleport, Where will it take you
Broadcast Message when the Teleport Appears
How long will the Teleport be on For. (120 second default)

MAP SAMPLE

http://www.filedropper.com/lmssamplemap

Waiting Room - x-1024 y-1024 z-7
Arena - x-1086 y-1024 z-5




Regards
Patriciou
 
Last edited:
Not Really, I had this script for a Really Long time. And
Last night, i decided to share it with you guys.

Regards, Patriciou
 
Thanks but if you can give us the map will be great.
 
Last edited:
sorry but i need tutorial in spanish or guide in english in my server dosent work only work tp :S
Need explication in spanish the coordinates of arena and temporaly arena and all please help
 
hi

i have everything set out properly all my x,y,z position are fine people get tp'd to my waiting area but it dont want to tp them and also the tp dont go after 120 seconds (2 minutes) if you could help it would be most helpful

kind regards

Smokiee Jo
 
whats this?

Lua:
from = {x = 351, y = 1340, z = 6}, -- top left cornor of the playground (random players teleportation) 
 to = {x = 366, y = 1350, z = 6}, -- bottom right cornor of the playground (random players teleportation)
 
PHP:
from = {x = 351, y = 1340, z = 6}, -- top left cornor of the playground (random players teleportation) 
 to = {x = 366, y = 1350, z = 6}, -- bottom right cornor of the playground (random players teleportation)

Set this as your Arena too- It will teleport players Randomly to arena so they wont appear near each other.

- - - Updated - - -

hi

i have everything set out properly all my x,y,z position are fine people get tp'd to my waiting area but it dont want to tp them and also the tp dont go after 120 seconds (2 minutes) if you could help it would be most helpful

kind regards

Make sure you copied everything into correct directions
PHP:
local timetoclose = 120 -- in second
- time of teleport being there. 120 - 2min
Do you get any errors in your console?,
if you don't that means that you must of done something wrong.

Regards, Patriciou
 
Last edited:
the only error i get is "onthink" in lms/arena where the config of it all is and everything seems to work fine i use 0.4_SVN have you tested it on 0.4 or just 0.3?
 
well here is my bug on why people wont get tp'd from the waiting to area to the arena

bug.jpg
 
well here is my bug on why people wont get tp'd from the waiting to area to the arena

View attachment 19911

try enter time in miliseconds in globalevents.xml


i have another bug,

After the Battle the winner will have to wait at-least 30 Seconds before receiving a Reward.

I won the battle, I killed a player, after 30 seconds i didint received a reward and im alone in arena - whats wrong?
 
Back
Top