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

[HOT] Last Man Standing Event!

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,286
Location
Sweden?
Tested On 0.3+
Tested On 0.4+

Hello Everyone,

Since, many people requested Last Man Standing Event For Free, i decide to make one. Its not 100% from scratch its based on Zombie Event By PhoOwned. But it required alot of edits.

Description: Event Starts by a Staff memeber using a command, players enter the arena, wait until the amout of players to join! the amout is decide by staff member. None can attack eachother, when they are waiting inside the arena. When everyone has joined. The fights begins immediately. Winner getting a golden trophy with his/her name description on it and some money also it will broadcast over the whole server.

*Start by using command!
*You have full control max and min players to join!
*Reward default (Money and golden thropy with your name description)
*Commands are anti-idiot protected, only way to destroy script is to teleport player (by gm command) from arena, but script will fix all values after server restart)
*Many broadcasts informing players what's going on!

Make sure not teleport someone inside or outside the arena.

Here is the Example of commands:
Lua:
/lms X -- X is number of players that can enter, for example:
/lms 15
 
/lms force -- force start, if you set for example 15 players limit, but there enter only 8 and you don't want to wait for more then you say it and it start arena

Here is the config:
Code:
-- CONFIG
ZEA_DEFAULT_NUMBER_OF_PLAYERS = 2 --default number of players that can enter arena
ZEA_ACCESS_TO_IGNORE_ARENA = 3 -- min. access of players that go arena, but are not counted as competitors
-- POSITIONS
ZEA_blockEnterItemPosition = {x= 987, y=997, z=7} -- position of item that block way to teleport to arena, even if item is not blocking way to TP, players cannot enter TP [blocked by script]
ZEA_enterPosition = {x = 965, y = 998, z = 7} -- position where spawn players when they enter teleport to arena
ZEA_kickPosition = {x=1000, y=1000, z=7} -- position where go players when they "die" by zombie or win arena (Default Temple)
ZEA_spawnFromPosition = {x = 957, y = 990, z = 7} -- north-left, top of the arena and lowest level of the arena
ZEA_spawnToPosition = {x = 975, y = 1007, z = 7} -- south-east, bottom of the arena and highest level of the arena
-- ITEM IDS
ZEA_blockEnterItemID = 1484 -- ID of item that block way to arena
-- STORAGES
-- - player
ZEA_isOnLMSArea = 24370 -- store information 'is player on lms arena'
-- - global
ZEA_STATUS = 24370 -- =< 0 - off, 1 - waiting for players, 2 - is running
ZEA_PLAYERS_NUMBER = 24371 -- store max. number of players on arena
ZEA_JOIN = 20010 --Storage to block players from attacking eachother, when the event is waiting for players!

Here is the script:

At creaturescripts/creaturescripts.xml paste these lines:
XML:
<event type="target" name="LMSTarget" event="script" value="lms.lua"/>
<event type="statschange" name="LMSAttack" event="script" value="lms.lua"/>
<event type="login" name="LMSLogout" event="script" value="lms.lua"/>
<event type="think" name="LMSSummon" event="script" value="lms.lua"/>

Now go into creaturescripts/scripts/login.lua and paste this into similar lines:
Lua:
registerCreatureEvent(cid, "LMSSummon")
registerCreatureEvent(cid, "LMSAttack")
registerCreatureEvent(cid, "LMSTarget")

Now go into creaturescripts/scripts folder and create new lua and name it "lms" and paste this code:
Lua:
function loseOnLMSArena(cid)
    kickPlayerFromLMSArea(cid)
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
    doCreatureAddMana(cid, getCreatureMaxMana(cid))
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "BOOM! You are dead.")
    setPlayerStorageValue(cid, ZEAA_JOIN, 0)
    local players = getLMSEventPlayers()
    if(#players <= 1) then
        local winner = players[1]
        if(winner) then
            doPlayerAddItem(winner, 2160, 5, true)
	    doCreatureAddHealth(winner, getCreatureMaxHealth(winner))
	    doCreatureAddMana(winner, getCreatureMaxMana(winner))
            local item = doPlayerAddItem(winner, 7369, 1, true)
            doItemSetAttribute(item, "description", getPlayerName(winner) .. " was the winner of Last Man Standing Event.")
	    setPlayerStorageValue(winner, ZEA_JOIN, 0)
            doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "You won Last Man Standing Event.")
            doBroadcastMessage("After " .. os.time() - getPlayerLMSEventStatus(winner) .. " seconds of fight " .. getCreatureName(winner) .. " won Last Man Standing Event in game versus " ..  getLMSEventPlayersLimit() - #getLMSEventPlayers() .. " players!")
            kickPlayerFromLMSArea(winner)
        else
            doBroadcastMessage("Last Man Standing Event finished! No one win?!?!?! WTF!")
        end
        doSetStorage(ZEA_STATUS, 0)
        doSetStorage(ZEA_PLAYERS_NUMBER, ZEA_DEFAULT_NUMBER_OF_PLAYERS)
        doSetStorage(ZEA_LMS_TO_SPAWN, 0)
        doSetStorage(ZEA_LMS_SPAWNED, 0)
        local width = (math.max(ZEA_spawnFromPosition.x, ZEA_spawnToPosition.x) - math.min(ZEA_spawnFromPosition.x, ZEA_spawnToPosition.x)) / 2 + 1
        local height = (math.max(ZEA_spawnFromPosition.y, ZEA_spawnToPosition.y) - math.min(ZEA_spawnFromPosition.y, ZEA_spawnToPosition.y)) / 2 + 1
        local centerPos = {x=math.min(ZEA_spawnFromPosition.x, ZEA_spawnToPosition.x)+width,y=math.min(ZEA_spawnFromPosition.y, ZEA_spawnToPosition.y)+height,z=ZEA_spawnFromPosition.z}
        for z = math.min(ZEA_spawnFromPosition.z, ZEA_spawnToPosition.z), math.max(ZEA_spawnFromPosition.z, ZEA_spawnToPosition.z) do
            centerPos.z = z
        end
    end
end
 
function onStatsChange(target, cid, changetype, combat, value)
    if isPlayer(target) and getPlayerStorageValue(target, ZEA_JOIN) == 1 then if(getStorage(ZEA_STATUS) == 1) then return false end end
    corpse_ids = {
        [0] = 3065, -- female
        [1] = 3058 -- male
}
    if((isInRange(getThingPosition(target), ZEA_spawnFromPosition, ZEA_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then 
        lose = addEvent(loseOnLMSArena, 1, target)
        corpse = doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(target))
        doCreateItem(2016, 2, getThingPos(target))
        doItemSetAttribute(corpse, "description", "You recogniZEA "..getCreatureName(target)..". He was killed by "..(isMonster(target) and "a "..string.lower(getCreatureName(cid)) or isCreature(cid) and getCreatureName(cid) or "a field item")..". In [LMS-Event]") 
        return false
    end
    return true
end
 
function onTarget(cid, target)
	if isPlayer(target) and getPlayerStorageValue(target, ZEA_JOIN) == 1 then
	if(getStorage(ZEA_STATUS) == 1) then
		doPlayerSendCancel(cid, "Wait until the Last Man Standing Event Starts.")
		return false
		end
	end
	return true
end
 
function onThink(cid)
	local summons = getCreatureSummons(cid)
	if not summons >= 1 then return true end
	if summons >= 1 then
	if isCreature(summons[1]) and getPlayerStorageValue(cid, ZEA_JOIN) == 1 then
		doRemoveCreature(summons[1])
		end
	return true
	end 
end
 
function onLogin(cid)
       if getPlayerStorageValue(cid, ZEA_JOIN) == 1 then
       	  setPlayerStorageValue(cid, ZEA_JOIN, 0)
     end
     return true
end

Now go into globalevents/globalevents.xml and post this line:
XML:
<globalevent name="LMSGlobalStartup" type="start" event="script" value="onstartup.lua"/>

Now go into globalevents/scripts and create new lua and name it "onstartup" and paste this code:
Lua:
function onStartup()
	db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. ZEA_isOnLMSArea .. ";")
	db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = " .. ZEA_JOIN .. ";")
	doSetStorage(ZEA_STATUS, 0)
	doSetStorage(ZEA_PLAYERS_NUMBER, ZEA_DEFAULT_NUMBER_OF_PLAYERS)
	addLMSEventBlockEnterPosition()
	return true
end

Now go into lib folder and create new lua and name it "lastmanstanding"
Lua:
-- CONFIG
ZEA_DEFAULT_NUMBER_OF_PLAYERS = 2 --default number of players that can enter arena
ZEA_ACCESS_TO_IGNORE_ARENA = 3 -- min. access of players that go arena, but are not counted as competitors
-- POSITIONS
ZEA_blockEnterItemPosition = {x= 987, y=997, z=7} -- position of item that block way to teleport to arena, even if item is not blocking way to TP, players cannot enter TP [blocked by script]
ZEA_enterPosition = {x = 965, y = 998, z = 7} -- position where spawn players when they enter teleport to arena
ZEA_kickPosition = {x=1000, y=1000, z=7} -- position where go players when they "die" by zombie or win arena (Default Temple)
ZEA_spawnFromPosition = {x = 957, y = 990, z = 7} -- north-left, top of the arena and lowest level of the arena
ZEA_spawnToPosition = {x = 975, y = 1007, z = 7} -- south-east, bottom of the arena and highest level of the arena
-- ITEM IDS
ZEA_blockEnterItemID = 1484 -- ID of item that block way to arena
-- STORAGES
-- - player
ZEA_isOnLMSArea = 24370 -- store information 'is player on lms arena'
-- - global
ZEA_STATUS = 24370 -- =< 0 - off, 1 - waiting for players, 2 - is running
ZEA_PLAYERS_NUMBER = 24371 -- store max. number of players on arena
ZEA_JOIN = 20010 --Storage to block players from attacking eachother, when the event is waiting for players!
 
-- FUNCTION
 
function setLMSEventPlayersLimit(value)
	doSetStorage(ZEA_PLAYERS_NUMBER, value)
end
 
function getLMSEventPlayersLimit()
	return getStorage(ZEA_PLAYERS_NUMBER)
end
 
function addPlayerToLMSArea(cid)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	doTeleportThing(cid, ZEA_enterPosition, true)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	if(getPlayerAccess(cid) < ZEA_ACCESS_TO_IGNORE_ARENA) then
		setPlayerLMSEventStatus(cid, os.time())
	end
end
 
function kickPlayerFromLMSArea(cid)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	doTeleportThing(cid, ZEA_kickPosition, true)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	setPlayerLMSEventStatus(cid, 0)
end
 
function getPlayerLMSEventStatus(cid)
	return getCreatureStorage(cid, ZEA_isOnLMSArea)
end
 
function setPlayerLMSEventStatus(cid, value)
	doCreatureSetStorage(cid, ZEA_isOnLMSArea, value)
end
 
function getLMSEventPlayers()
	local players = {}
	for i, cid in pairs(getPlayersOnline()) do
		if(getPlayerLMSEventStatus(cid) > 0) then
			table.insert(players, cid)
		end
	end
	return players
end
 
function addLMSEventBlockEnterPosition()
	if(getTileItemById(ZEA_blockEnterItemPosition, ZEA_blockEnterItemID).uid == 0) then
		doCreateItem(ZEA_blockEnterItemID, 1, ZEA_blockEnterItemPosition)
	end
end
 
function removeLMSEventBlockEnterPosition()
	local item = getTileItemById(ZEA_blockEnterItemPosition, ZEA_blockEnterItemID)
	if(item.uid ~= 0) then
		doRemoveItem(item.uid)
	end
end

Now go into movements/movements.xml and paste t
XML:
<movevent type="StepIn" actionid="3333" event="script" value="onenter.lua"/>

Now go into movements/scripts and create new lua and name it "onenter" and paste this code:
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if(not isPlayer(cid)) then
		return true
	end
	if(getPlayerAccess(cid) >= ZEA_ACCESS_TO_IGNORE_ARENA) then
		addPlayerToLMSArea(cid)
	elseif(#getLMSEventPlayers() < getLMSEventPlayersLimit() and getStorage(ZEA_STATUS) == 1) then
		addPlayerToLMSArea(cid)
		local players_on_arena_count = #getLMSEventPlayers()
		if(players_on_arena_count == getLMSEventPlayersLimit()) then
			addLMSEventBlockEnterPosition()
			doSetStorage(ZEA_STATUS, 2)
			doBroadcastMessage("Last Man Standing Arena Event started.")
		else
			doBroadcastMessage(getCreatureName(cid) .. " has entered a Last Man Standing Arena. We still need " .. getLMSEventPlayersLimit() - players_on_arena_count .. " players.")
			setPlayerStorageValue(cid, ZEA_JOIN, 1)
		end
	else
		doTeleportThing(cid, fromPosition, true)
		addLMSEventBlockEnterPosition()
	end
	return true
end

Now go into talkactions/talkactions.xml and paste this line:
XML:
<talkaction log="yes" words="/lms" access="4" event="script" value="lmscommand.lua"/>

Now go into talkactions/scripts and create new lua and name it "lmscommand" and paste this line:
Lua:
function onSay(cid, words, param, channel)
	if(getStorage(ZEA_STATUS) ~= 2) then
		local players_on_arena_count = #getLMSEventPlayers()
		if(param == 'force') then
			if(players_on_arena_count > 0) then
				setLMSEventPlayersLimit(players_on_arena_count  )
				addLMSEventBlockEnterPosition()
				doSetStorage(ZEA_STATUS, 2)
				doBroadcastMessage("Last Man Standing Event started.")
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last Man Standing event started.")
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Cannot start Last Man Standing event. There is no players on arena.")
			end
		else
			if(param ~= '' and tonumber(param) > 0) then
				setLMSEventPlayersLimit(tonumber(param))
			end
			removeLMSEventBlockEnterPosition()
			doSetStorage(ZEA_STATUS, 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Event started.")
			doBroadcastMessage( "Last Man Standing teleport is opened. We are waiting for " .. getLMSEventPlayersLimit() - players_on_arena_count .. " players to start.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last Man Standing is already running.")
	end
	return true
end

Download map:
Mirror 1: lms.otbm

Enjoy!
 
Last edited:
Ive tested it on 0.3+
 
I have problem with it, when im trying to enter the teleport and instead to teleport me to lms arena im get teeported to zombie events and zombie event is starting :s I fixed all pos and configuration but dosn't work im using 0.4

I have my zombie event in lib to :s
 
I have problem with it, when im trying to enter the teleport and instead to teleport me to lms arena im get teeported to zombie events and zombie event is starting :s I fixed all pos and configuration but dosn't work im using 0.4

I have my zombie event in lib to :s

Fixed, make sure to recopy all the scripts!
 
MMM... How i do for the event started auto?
This event found 100% Thanks team!
+REP and LIKE!

Thanks!
 
MMM... How i do for the event started auto?
This event found 100% Thanks team!
+REP and LIKE!

Thanks!

Asfar its now, its only starts by command.
 
Getting this popping up, even when the event is not in use. I havent started it at all and I get these stupid errors. Rev. 3884 - 0.4

Code:
[12:55:37.299] [Error - CreatureScript Interface]
[12:55:37.299] data/creaturescripts/scripts/lms.lua:onThink
[12:55:37.300] Description:
[12:55:37.301] (luaGetCreatureSummons) Creature not found

[12:55:37.302] [Error - CreatureScript Interface]
[12:55:37.302] data/creaturescripts/scripts/lms.lua:onThink
[12:55:37.303] Description:
[12:55:37.304] data/creaturescripts/scripts/lms.lua:64: attempt to get length of
 local 'summons' (a boolean value)
[12:55:37.304] stack traceback:
[12:55:37.305]  data/creaturescripts/scripts/lms.lua:64: in function <data/creat
urescripts/scripts/lms.lua:62>

So beware, dont bother using this with 0.4 until its fixed unless you want an unstable event.
 
Last edited:
Getting this popping up, even when the event is not in use. I havent started it at all and I get these stupid errors. Rev. 3884 - 0.4

Code:
[12:55:37.299] [Error - CreatureScript Interface]
[12:55:37.299] data/creaturescripts/scripts/lms.lua:onThink
[12:55:37.300] Description:
[12:55:37.301] (luaGetCreatureSummons) Creature not found

[12:55:37.302] [Error - CreatureScript Interface]
[12:55:37.302] data/creaturescripts/scripts/lms.lua:onThink
[12:55:37.303] Description:
[12:55:37.304] data/creaturescripts/scripts/lms.lua:64: attempt to get length of
 local 'summons' (a boolean value)
[12:55:37.304] stack traceback:
[12:55:37.305]  data/creaturescripts/scripts/lms.lua:64: in function <data/creat
urescripts/scripts/lms.lua:62>

So beware, dont bother using this with 0.4 until its fixed unless you want an unstable event.

Sorry for not answering. Retry.
 
Still errors.. it spams it at like 10 per second.

Code:
[23:0:15.482] [Error - CreatureScript Interface]
[23:0:15.482] data/creaturescripts/scripts/lms.lua:onThink
[23:0:15.482] Description:
[23:0:15.482] data/creaturescripts/scripts/lms.lua:64: attempt to compare number with boolean
[23:0:15.482] stack traceback:
[23:0:15.482]   data/creaturescripts/scripts/lms.lua:64: in function <data/creaturescripts/scripts/lms.lua:62>

[23:0:15.532] [Error - CreatureScript Interface]
[23:0:15.532] data/creaturescripts/scripts/lms.lua:onThink
[23:0:15.532] Description:
[23:0:15.532] data/creaturescripts/scripts/lms.lua:64: attempt to compare number with boolean
[23:0:15.532] stack traceback:
[23:0:15.532]   data/creaturescripts/scripts/lms.lua:64: in function <data/creaturescripts/scripts/lms.lua:62>

Its the same as before. It works, it just SPAMS errors upon errors and I had to remove it at risk it would crash the server!
 
I dont know why 0.4 cant read this line:
Lua:
function onThink(cid)
	local summons = getCreatureSummons(cid)
	if not summons >= 1 then return true end
	if summons >= 1 then
	if isCreature(summons[1]) and getPlayerStorageValue(cid, ZEA_JOIN) == 1 then
		doRemoveCreature(summons[1])
		end
	return true
	end 
end
 
So you're saying there isn't a fix? Hopefully you can find a way around it!
 
Either you adding wrong or just remove the line.
 
I copied everything exact, so if I just remove everything in your previous post it should be fine?
 
Back
Top