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

Lua People can't die in LMS

Finduz

New Member
Joined
Nov 13, 2014
Messages
40
Reaction score
0
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?
yrIMsBWEm.png

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
Thanks in advance!
 
Last edited by a moderator:
I did not get any error messages yesterday.
However I jsut noticed that I got it today with the new problem.
Code:
[19/11/2014 17:36:59] [Error - CreatureScript Interface]
[19/11/2014 17:36:59] In a timer event called from:
[19/11/2014 17:36:59] data/creaturescripts/scripts/lms.lua:onStatsChange
[19/11/2014 17:36:59] Description:
[19/11/2014 17:36:59] data/lib/lastmanstanding.lua:41: attempt to call global 'doTeleportPlayer' (a nil value)
[19/11/2014 17:36:59] stack traceback:
[19/11/2014 17:36:59]     data/lib/lastmanstanding.lua:41: in function 'kickPlayerFromLMSArea'
[19/11/2014 17:36:59]     data/creaturescripts/scripts/lms.lua:2: in function <data/creaturescripts/scripts/lms.lua:1>
 
The event won't start.
I type /lms and the item blocking the tp disappears.
However it doesn't seem to react on players walking in the tp. It thinks the arena is empty.
Typed this with 2 chars in arena.
18:20 /lms force
18:20 Cannot start Last Man Standing event. There is no players on arena.
 
Code:
[19/11/2014 18:23:32] [Error - CreatureScript Interface]
[19/11/2014 18:23:32] data/creaturescripts/scripts/lms.lua:onStatsChange
[19/11/2014 18:23:32] Description:
[19/11/2014 18:23:32] (luaGetPlayerSex) Player not found

[19/11/2014 18:23:32] [Error - CreatureScript Interface]
[19/11/2014 18:23:32] data/creaturescripts/scripts/lms.lua:onStatsChange
[19/11/2014 18:23:32] Description:
[19/11/2014 18:23:32] (luaDoCreateItem) Item not found

[19/11/2014 18:23:32] [Error - CreatureScript Interface]
[19/11/2014 18:23:32] data/creaturescripts/scripts/lms.lua:onStatsChange
[19/11/2014 18:23:32] Description:
[19/11/2014 18:23:32] (luaDoItemSetAttribute) Item not found

[19/11/2014 18:23:32] [Error - CreatureScript Interface]
[19/11/2014 18:23:32] In a timer event called from:
[19/11/2014 18:23:32] data/creaturescripts/scripts/lms.lua:onStatsChange
[19/11/2014 18:23:32] Description:
[19/11/2014 18:23:32] data/creaturescripts/scripts/lms.lua:8: attempt to compare table with number
[19/11/2014 18:23:32] stack traceback:
[19/11/2014 18:23:32]     data/creaturescripts/scripts/lms.lua:8: in function <data/creaturescripts/scripts/lms.lua:1>

Movements.xml
Code:
<movevent type="StepIn" actionid="3333" event="script" value="onenter.lua"/>
 
Above corpse = doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(target)), add this
Code:
if not isPlayer(cid) then return true end
 
Above corpse = doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(target)), add this
Code:
if not isPlayer(cid) then return true end
This sorted the thing with the bodies and the killed player will get tp'd to temple.

I have this error code after I killed one of the chars
Code:
[19/11/2014 19:51:31] [Error - CreatureScript Interface]
[19/11/2014 19:51:31] In a timer event called from:
[19/11/2014 19:51:31] data/creaturescripts/scripts/lms.lua:onStatsChange
[19/11/2014 19:51:31] Description:
[19/11/2014 19:51:31] data/creaturescripts/scripts/lms.lua:8: attempt to compare table with number
[19/11/2014 19:51:31] stack traceback:
[19/11/2014 19:51:31]     data/creaturescripts/scripts/lms.lua:8: in function <data/creaturescripts/scripts/lms.lua:1>

I don't think the script starts as it's supossed to do. Somehow it doesn't realise that players have entered the arena maybe?
When I try to force start it with /lms force
I still get this in my deafult chat
19:51 Cannot start Last Man Standing event. There is no players on arena.
^ And that is with players in arena
 
Still nothing happens when players enter the tp
and I get this error upon someone getting killed
Code:
[19/11/2014 20:02:54] [Error - CreatureScript Interface]
[19/11/2014 20:02:54] In a timer event called from:
[19/11/2014 20:02:54] data/creaturescripts/scripts/lms.lua:onStatsChange
[19/11/2014 20:02:54] Description:
[19/11/2014 20:02:54] data/creaturescripts/scripts/lms.lua:9: attempt to index local 'players' (a number value)
[19/11/2014 20:02:54] stack traceback:
[19/11/2014 20:02:54]     data/creaturescripts/scripts/lms.lua:9: in function <data/creaturescripts/scripts/lms.lua:1>
 
The server still wont register that players have entered the arena :p
And got error message
Code:
[19/11/2014 20:12:05] [Error - CreatureScript Interface]
[19/11/2014 20:12:05] In a timer event called from:
[19/11/2014 20:12:05] data/creaturescripts/scripts/lms.lua:onStatsChange
[19/11/2014 20:12:05] Description:
[19/11/2014 20:12:05] data/creaturescripts/scripts/lms.lua:8: attempt to get length of local 'players' (a number value)
[19/11/2014 20:12:05] stack traceback:
[19/11/2014 20:12:05]     data/creaturescripts/scripts/lms.lua:8: in function <data/creaturescripts/scripts/lms.lua:1>
 
It still say no players in arena when I type /lms force and it won't notice the players in arena from just entering the tp
However when there is only one player left this message comes
"Last Man Standing Event finished! No one win?!?!?! WTF!".
He won't get tp'd out from there tho

But hey, atleast no error message this time lol
 
This is my first ot and I'm completly new to .lua so please correct me if I'm wrong!
But could it not be global storage that is the problem? Since the script don't know that people entered the tp? :p
 
You can do some tests with prints in the movement script, see if it loads, whichs parts are loaded etc.
Code:
print("test1")
You can add textmessages like that in the movement script, call it something like test1, test2, test3 etc. and then look which messages you get in your console when people step on it, this way you can find out which part isn't working properly.
 
I noticed that I had messed up with the action id's.... lol
As I said, still really new to this :p


Maybe you can help me with one more thing in this script. If a player is killed by a player he won't loose bless, however he will if he get's killed by a monster and his corpse with loot will end up in temple.
Is there any way to make players killed by monster in the event not loose bless?
 
Back
Top