Yes, me again..
The lms script I'm using is not working. (cred to authors http://otland.net/threads/hot-last-man-standing-event.176894/page-1)
When I tried it yesterday the winner would not be teleported from the arena, he would remain there.
Today I don't get this problem since chars can't even die in the arena. They end up on 1hp stay alive. However, with every further hit they take, a corpse is created. And the tp animation is created.
Also I don't think players are supossed to get skull in this event?
Here comes all the scripts.
data\lib\lastmanstanding.lua
globalevents\scripts\onstartup.lua
creaturescripts\scripts\lms.lua
movements\scripts\onenter.lua
Thanks in advance!
The lms script I'm using is not working. (cred to authors http://otland.net/threads/hot-last-man-standing-event.176894/page-1)
When I tried it yesterday the winner would not be teleported from the arena, he would remain there.
Today I don't get this problem since chars can't even die in the arena. They end up on 1hp stay alive. However, with every further hit they take, a corpse is created. And the tp animation is created.
Also I don't think players are supossed to get skull in this event?
Here comes all the scripts.
data\lib\lastmanstanding.lua
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= 1823, y=1817, z=6} -- 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 = 1824, y = 1818, 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 = 1806, y = 1811, z = 7} -- north-left, top of the arena and lowest level of the arena
ZEA_spawnToPosition = {x = 1843, y = 1826, 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)
doTeleportPlayer(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
globalevents\scripts\onstartup.lua
Code:
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
creaturescripts\scripts\lms.lua
Code:
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 recognize "..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 #summons > 0 and getPlayerStorageValue(cid, ZEA_JOIN) == 1 then
for i = 1, #summons do
doRemoveCreature(summons)
end
end
return true
end
function onLogin(cid)
if getPlayerStorageValue(cid, ZEA_JOIN) == 1 then
setPlayerStorageValue(cid, ZEA_JOIN, 0)
end
return true
end
movements\scripts\onenter.lua
Code:
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
Last edited by a moderator: