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

Working LMS for TFS 1.0

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,317
Solutions
35
Reaction score
435
Does anybody know how to get LMS working for TFS 1.0?

I've been trying with no success :(

Thanks, for the help!
 
Hello,
@ricotje1 and @therrax

I would love for you guys to have an LMS event on your TFS 1.0 Server. Since I have seen you asking around at quite a few places I think it is better that I try to help you fix it on your own first. So why not post your errors/problems here and I will assist you through them.

This way you can learn more and improve your Lua skills. If we end up going no where then I will make a new topic and release my version of LMS for TFS 1.0 (which I assure you it can be much improved :p).

Best Regards,
imkingran
 
@imkingran I dont have errors, but when I won battle nothing happens.. :/
globalevent/scripts/Lastman.lua:
Code:
local createpos = {x=778,y=996,z=7} -- Every 2h where will the Teleport Appear
local topos = {x=775,y=1006,z=8} -- 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)
broadcastMessage("Teleport zamkniety!", MESSAGE_STATUS_WARNING)
end
end

function onThink(interval)
doCreateTeleport(1387, topos, createpos)
broadcastMessage("Last man standing event TP is now open!\nCatch the teleport within "..timetoclose.." seconds! Teleport is Located in Boss area!", MESSAGE_STATUS_WARNING)
addEvent(remove,timetoclose*1000)
return true
end
globalevents/scripts/arena.lua:
Code:
local t = {
tmp = {
{x = 772, y = 1004, z = 8}, -- North west corner of Area where players must stand in order to join the event
{x = 778, y = 1008, z = 8} -- South east corner of Area
},
arena = {
{x = 770, y = 1003, z = 9}, -- North west Corner of Arena
{x = 780, y = 1011, z = 9}, -- South East corner of Arena
{x = 777, y = 1007, z = 9} -- Center of Arena
},

from = {x = 772, y = 1005, z = 9}, -- Top left cornor of the playground (random players teleportation)
to = {x = 777, y = 1007, z = 9}, -- 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 = {2160} -- Reward that player recives
}
local kick = 1

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.")
broadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")
doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 5)
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=1002, y=998, 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=1002, y=998, 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
globalevents.xml

Code:
<globalevent name="LastMan" interval="900000" script="LMS/lastman.lua"/>
    <globalevent name="arena" interval="1020000" script="LMS/arena.lua"/>
 
Try to change the arena script interval to 2 minutes

The arena script keeps checking to see how many players are left. So even after there is one player left you will have to wait until the script runs again for it to realize that there is only 1 player left.

I completely forgot about this problem it's been such a long time ago. It might be a better idea to separate the script so that the part where it teleports players form the waiting room to event room and the part where it checks for how many players left are not on the same script. This way you can change the CHECK script to an interval of 1000 so the winner doesn't have to stand there alone. Otherwise if you keep them on the same script and reduce the interval it will keep teleporting players from the waiting room at different times.

Code:
<globalevent name="arena" interval="120000" script="LMS/arena.lua"/>
 
Back
Top