local area =
{
frompos = {x=89, y=128, z=7},
topos = {x=96, y=134, z=7}
}
local reward = 2160
count = 5
tppos = {x=98, y=122, z=7, stackpos=1}
local CHECK_STORAGE = 20088
local function check1(cid)
local players = 0
if isPlayer(cid) and getCreatureStorage(cid, CHECK_STORAGE) > 0 then
for _, pid in ipairs(getPlayersOnline()) do
if pid ~= cid and isInRange(getCreaturePosition(pid), area.frompos, area.topos) then
players = players + 1
end
end
if players < 1 then
doPlayerAddItem(cid, reward, count)
doSetStorage(74999, -1)
db.executeQuery("UPDATE `player_storage` SET `value` = '-1' WHERE `key` = '74910'")
db.executeQuery("UPDATE `player_storage` SET `value` = '-1' WHERE `key` = '74911'")
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doRemoveCondition(cid, CONDITION_INFIGHT)
doBroadcastMessage(getCreatureName(cid) .. " won!", MESSAGE_EVENT_ADVANCE)
rtp = getThingFromPos(tppos)
if rtp.itemid > 0 then
doRemoveItem(rtp.uid)
end
else
return doPlayerSendTextMessage(cid, 22, "You aren't the only survivor. Only one can win this event!")
end
end
return true
end
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if isPlayer(cid) then
doCreatureSetStorage(cid, CHECK_STORAGE, 1)
addEvent(check1, 10 * 1000, cid)
doSendMagicEffect(getCreaturePosition(cid), 34)
end
return true
end
function onStepOut(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if isPlayer(cid) then
doCreatureSetStorage(cid, CHECK_STORAGE, 0)
end
return true
end