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: