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

Solved Pacman

Denziz

New Member
Joined
May 2, 2013
Messages
81
Reaction score
4
Hello there! I can't fix this... Someone I just simply can't. I am trying to make so pacman TGY script is working. I have placed the tgyfunctions in data/lib, and pacman.lua in movements folder also registered them in the movements.xml. Same as creaturescripts... pacmanhandle.lua , registered it also in the login.lua and creaturescripts.xml.

Still does not work... I have fixed all locations, i've even double-checked!

Code:
-- Pacman script: Controller [TGY]
pressedTiles = {}
gameStarted = false
dif = 1

local function pacmanCounter(text, start, col, dif)
if start then
gameStarted = true
doCreateMonster("Pacman Ghost", {x = 989, y = 1629, z = 7})
if dif > 1 then
doCreateMonster("Pacman Ghost", {x = 989, y = 1629, z = 7})
end
if dif > 2 then
doCreateMonster("Pacman Ghost", {x = 989, y = 1629, z = 7})
end
end
doSendAnimatedText({x = 989, y = 1629, z = 7}, text, col)
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if false == isPlayer(cid) then
return
end

if item.actionid == 5301 and item.itemid == 426 then
-- HANDLE TILE
if not gameStarted then
--doPlayerPopupFYI(cid, "x")
doTeleportThing(cid, fromPosition, true)
return true
end
doTransformItem(item.uid, 425)
table.insert(pressedTiles, position)
local cnt = #pressedTiles
doSendAnimatedText(position, (cnt).."/89", TEXTCOLOR_GREEN)
if cnt >= 89 then
doTeleportThing(cid, {x = 994, y = 1627, z = 7}, true)
doSendAnimatedText(position, ":D", TEXTCOLOR_GREEN)
local prize = 5
if dif == 2 then prize = 10 end
if dif == 3 then prize = 20 end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PACMAN] You won ".. prize .." Game Tokens!")
doPlayerAddItem(cid,2157, 5)
end
elseif item.actionid == 7392 then
-- HANDLE JOINING PERSON
local c = isCreatureInArea({x = 989, y = 1629, z = 7},{x = 999, y = 1639, z = 7}) -- Getting crss inside
for _,v in pairs(c) do
if isPlayer(v) then
doTeleportThing(cid, fromPosition, true)
return true
end
end
-- Nobody is inside, check ticket/pick it - check exhaust first
--doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
if getPlayerStorageValue(cid, 7948) > 0 and (os.time() < getPlayerStorageValue(cid, 7948)) then
doTeleportThing(cid, fromPosition, true)
doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minute(s) till you can play again.")
return true
end
if getPlayerItemCount(cid, 2157) < 1 then
doTeleportThing(cid, fromPosition, true)
doPlayerPopupFYI(cid, "You need 1 Gold Nugget to play.")
return true
end
if doPlayerRemoveItem(cid, 2157, 1) then
setPlayerStorageValue(cid, 7948, os.time() + 360)
end
-- Set difficulity variabele
dif = 1
if item.uid == 7396 then
dif = 2
elseif item.uid == 7397 then
dif = 3
end
-- Clean the area and reset the tiles now
for _,v in pairs(c) do
doRemoveCreature(v)
end
for i = 1, #pressedTiles do
doCreateItem(425, i)
end
pressedTiles = {}
gameStarted = false
doTeleportThing(cid, {x = 994, y = 1634, z = 7}, true)
pacmanCounter("3", false, TEXTCOLOR_RED, dif)
addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
end


return true
end

Please help me solve this problem, kind regards. Denziz
 
Last edited by a moderator:
@tetra20

I am using tfs 0.3.6 crying damson.

Zombie event is from masiyah basically... LMS too. I'll post them here.
P.S: Notice that I am ONLY posting the scripts that is the main needed. For example, the LMS script haves lastmantp.lua too, located in the globalevents folder. For the Zombie event there is 1 at creaturescripts folder, 1 at movements and the remaining one as I have posted DOWN BELOW!

LMS
Code:
local t = {
tmp = {
{x = 1017, y = 1481, z = 7}, -- North west corner of Area where players must stand in order to join the event
{x = 1026, y = 1486, z = 7} -- South east corner of Area
},
arena = {
{x = 1015, y = 1461, z = 7}, -- North west Corner of Arena
{x = 1031, y = 1475, z = 7}, -- South East corner of Arena
{x = 1023, y = 1468, z = 7} -- Center of Arena
},

from = {x = 1015, y = 1461, z = 7}, -- Top left cornor of the playground (random players teleportation)
to = {x = 1031, y = 1475, z = 7}, -- Bottom right cornor of the playground (random players teleportation)

minPlayers = 2, -- min players required to start the battle
noPlayers = 1, -- Leave it as it is
prize = {6527} -- Reward that player recives
}
local kick = 0

function onThink()
local arenaPlayers = {}

for x = t.arena[1].x, t.arena[2].x do
for y = t.arena[1].y, t.arena[2].y do
for z = t.arena[1].z, t.arena[2].z do
local pos = {x = x, y = y, z = z}
local n = getTileInfo(pos).creatures
if n ~= 0 then
pos.stackpos = 1
local c = getThingfromPos(pos)
while c.uid ~= 0 do
if c.itemid == 1 and c.type == 1 then
table.insert(arenaPlayers, c.uid)
if #arenaPlayers == n then
break
end
end
pos.stackpos = pos.stackpos + 1
c = getThingfromPos(pos)
end
end
end
end
end

if #arenaPlayers == 1 then
local p = getPlayerMasterPos(arenaPlayers[1])
doTeleportThing(arenaPlayers[1], p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You have won the event and received your reward.")
doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")
doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 25)
kick = 0
elseif #arenaPlayers > 1 then
if kick == 0 then
kick = os.time()
else
if os.time() - kick >= 840 then
kick = 0
for i = 1, #arenaPlayers do
doTeleportThing(arenaPlayers[i], {x=32369, y=32241, z=7})
doPlayerSendTextMessage(arenaPlayers[i], MESSAGE_STATUS_WARNING, "Too even, try harder next time.")
end
end
end
elseif #arenaPlayers == 0 then
kick = 0

local players = {}
for x = t.tmp[1].x, t.tmp[2].x do
for y = t.tmp[1].y, t.tmp[2].y do
for z = t.tmp[1].z, t.tmp[2].z do
local c = getTopCreature({x = x, y = y, z = z})
if c.type == 1 then
table.insert(players, c.uid)
end
end
end
end

if #players >= t.minPlayers then
for i = 1, #players do
local p = {x = math.random(t.from.x, t.to.x), y = math.random(t.from.y, t.to.y), z = math.random(t.from.z, t.to.z)}
doTeleportThing(players[i], p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
end
else
for i = 1, #players do
doTeleportThing(players[i], {x=32369, y=32241, z=7})
doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The event didn't start because there isn't enough players in area!")
end
end
end
return true
end

Zombie:
Code:
local config = {
    playerCount = 2001, -- Global storage for counting the players left/entered in the event
    zombieCount = 2002, -- Global storage for counting the zombies in the event
    teleportActionId = 20000, -- Action id of the teleport needed for the movement script
    teleportPosition = {x = 810, y = 1509, z = 7, stackpos = 1}, -- Where the teleport will be created
    teleportToPosition = {x = 993, y = 1576, z = 7}, -- Where the teleport will take you
    teleportId = 1387, -- Id of the teleport
    timeToStartEvent = 1, -- Minutes, after these minutes the teleport will be removed and the event will be declared started
    timeBetweenSpawns = 10, -- Seconds between each spawn of zombie
    zombieName = "event zombie", -- Name of the zombie that should be summoned
    playersNeededToStartEvent = 1, -- Players needed before the zombies can spawn.
  
    -- Should be the same as in the creaturescript!
    -- The zombies will spawn randomly inside this area
    fromPosition = {x = 979, y = 1558, z = 7}, -- top left cornor of the playground
    toPosition = {x = 1014, y = 1586, z = 7}, -- bottom right cornor of the playground
    }

function onThink(interval, lastExecution)
    local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportPosition)
    doItemSetAttribute(tp, "aid", config.teleportActionId)
    doBroadcastMessage("Zombie event starting in " .. config.timeToStartEvent .. " minutes! The teleport will be closed when the event start! Telport located in the Event Room!")
    setGlobalStorageValue(config.playerCount, 0)
    setGlobalStorageValue(config.zombieCount, 0)
    addEvent(startEvent, config.timeToStartEvent * 1000 * 60)
    print(getGlobalStorageValue(2001))
    return true
end

function startEvent()
    local get = getThingfromPos(config.teleportPosition)
    if get.itemid == config.teleportId then
        doRemoveItem(get.uid, 1)
    end
  
    local fromp, top = config.fromPosition, config.toPosition

    if getGlobalStorageValue(config.playerCount) >= config.playersNeededToStartEvent then
        addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
        doBroadcastMessage("Good luck in the zombie event people! The teleport has closed!")
      
        for x = fromp.x, top.x do
            for y = fromp.y, top.y do
                for z = fromp.z, top.z do
                    areapos = {x = x, y = y, z = z, stackpos = 253}
                    getPlayers = getThingfromPos(areapos)
                    if isPlayer(getPlayers.uid) then
                          doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The first zombie will spawn in " .. config.timeBetweenSpawns .. " seconds! Good luck!")
                    end
                end
            end
        end
    else
        doBroadcastMessage("The Zombie event could not start because of to few players participating.\n At least " .. config.playersNeededToStartEvent .. " players is needed!")
        for x = fromp.x, top.x do
            for y = fromp.y, top.y do
                for z = fromp.z, top.z do
                    areapos = {x = x, y = y, z = z, stackpos = 253}
                    getPlayers = getThingfromPos(areapos)
                    if isPlayer(getPlayers.uid) then
                        doTeleportThing(getPlayers.uid, getTownTemplePosition(getPlayerTown(getPlayers.uid)))
                        doSendMagicEffect(getPlayerPosition(getPlayers.uid), CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
    return true
end

function spawnZombie()
    if getGlobalStorageValue(config.playerCount) then
        pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
        doSummonCreature(config.zombieName, pos)
        doSendMagicEffect(pos, CONST_ME_MORTAREA)
        setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
        doBroadcastMessage("A zombie has spawned! There is currently " .. getGlobalStorageValue(config.zombieCount) .. " zombies in the zombie event!", 19)
        addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
    end
return true
end
 
Last edited by a moderator:
Code:
 local t = {
tmp = {
{x = 1017, y = 1481, z = 7}, -- North west corner of Area where players must stand in order to join the event
{x = 1026, y = 1486, z = 7} -- South east corner of Area
},
arena = {
{x = 1015, y = 1461, z = 7}, -- North west Corner of Arena
{x = 1031, y = 1475, z = 7}, -- South East corner of Arena
{x = 1023, y = 1468, z = 7} -- Center of Arena
},

from = {x = 1015, y = 1461, z = 7}, -- Top left cornor of the playground (random players teleportation)
to = {x = 1031, y = 1475, z = 7}, -- Bottom right cornor of the playground (random players teleportation)

minPlayers = 2, -- min players required to start the battle
noPlayers = 1, -- Leave it as it is
prize = {6527} -- Reward that player recives
}
local kick = 0

function onThink()
local arenaPlayers = {}

for x = t.arena[1].x, t.arena[2].x do
for y = t.arena[1].y, t.arena[2].y do
for z = t.arena[1].z, t.arena[2].z do
local pos = {x = x, y = y, z = z}
local n = getTileInfo(pos).creatures
if n ~= 0 then
pos.stackpos = 1
local c = getThingfromPos(pos)
while c.uid ~= 0 do
if c.itemid == 1 and c.type == 1 then
table.insert(arenaPlayers, c.uid)
if #arenaPlayers == n then
break
end
end
pos.stackpos = pos.stackpos + 1
c = getThingfromPos(pos)
end
end
end
end
end

if #arenaPlayers == 1 then
local p = getPlayerMasterPos(arenaPlayers[1])
doTeleportThing(arenaPlayers[1], p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You have won the event and received your reward.")
doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")
doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 25)
kick = 0
elseif #arenaPlayers > 1 then
if kick == 0 then
kick = os.time()
else
if os.time() - kick >= 30 then
kick = 0
for i = 1, #arenaPlayers do
doTeleportThing(arenaPlayers[i], {x=32369, y=32241, z=7})
doPlayerSendTextMessage(arenaPlayers[i], MESSAGE_STATUS_WARNING, "Too even, try harder next time.")
end
end
end
elseif #arenaPlayers == 0 then
kick = 0

local players = {}
for x = t.tmp[1].x, t.tmp[2].x do
for y = t.tmp[1].y, t.tmp[2].y do
for z = t.tmp[1].z, t.tmp[2].z do
local c = getTopCreature({x = x, y = y, z = z})
if c.type == 1 then
table.insert(players, c.uid)
end
end
end
end

if #players >= t.minPlayers then
for i = 1, #players do
local p = {x = math.random(t.from.x, t.to.x), y = math.random(t.from.y, t.to.y), z = math.random(t.from.z, t.to.z)}
doTeleportThing(players[i], p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
end
else
for i = 1, #players do
doTeleportThing(players[i], {x=32369, y=32241, z=7})
doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The event didn't start because there isn't enough players in area!")
end
end
end
return true
end

For the Zombie Event use another script.Stop using Masiyah Shits
http://otland.net/threads/zombie-event-new-version-bug-free-updated.128664/
 
@tetra20

Sir yes sir! xD

@tetra20

ooh! Forgot one last thing. How do I set up pacman's medium and hard difficulties? I want so players can choose between easy, medium and hard.
 
Last edited by a moderator:
Code:
<movevent type="StepIn" actionid="7392;7396;7397;5301" event="script"
value="pacmaner.lua"/>
Code:
-- Pacman script: Controller [TGY]
pressedTiles = {}
gameStarted = false
dif = 1
local from = {x=800,y=500,z=7}
local to = {x=700,y=400,z=7}
local itemid = 2157 -- needed to play atm it is 1 gold nugget
local amountneed = 5 -- amount needed of item to play
local exhaustiont = 10 -- in minutes

local function pacmanCounter(text, start, col, dif)
   if start then
     gameStarted = true
     doCreateMonster("Pacman Ghost", {x = 1036, y = 286, z = 7}) -- edit this to position of first pac man
     if dif > 1 then
       doCreateMonster("Pacman Ghost", {x = 1035, y = 286, z = 7})
     end
     if dif > 2 then
       doCreateMonster("Pacman Ghost", {x = 1037, y = 286, z = 7}) -- same here
     end
   end
   doSendAnimatedText({x = 1036, y = 292, z = 7}, text, col) -- player position ingame
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
   if false == isPlayer(cid) then
     return
   end
 
   if item.actionid == 5301 and item.itemid == 407 then
     -- HANDLE TILE
     if not gameStarted then
       --doPlayerPopupFYI(cid, "x")
       doTeleportThing(cid, fromPosition, true)
       return true
     end
     doTransformItem(item.uid, 406)
     table.insert(pressedTiles, position)
     local cnt = #pressedTiles
     doSendAnimatedText(position, (cnt).."/184", TEXTCOLOR_GREEN)
     if cnt > 183 then
       doTeleportThing(cid, {x = 1000, y = 1000, z = 7}, true)
       doSendAnimatedText(position, ":D", TEXTCOLOR_GREEN)
       local prize = 2
       if dif == 2 then
       prize = 5
       end
       if dif == 3 then
       prize = 10
       end
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PACMAN] You won ".. prize .." Gold Nuggets!")
       doPlayerAddItem(cid,2157,prize)
     end
   elseif item.actionid == 7396 then
     local c = isCreatureInArea(from,to) -- Getting crss inside
     for _,v in pairs(c) do
       if isPlayer(v) then
         doTeleportThing(cid, fromPosition, true)
         return true
         end
     end
     -- Nobody is inside, check ticket/pick it - check exhaust first
     --doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
     if getPlayerItemCount(cid, itemid) < amountneed then
       doTeleportThing(cid, fromPosition, true)
       doPlayerPopupFYI(cid, "You need "..amountneed.." "..getItemNameById(itemid).." to play.")
       return true
     end
     doPlayerRemoveItem(cid, itemid, amountneed)
     exhaustion.set(cid, 7947,60*exhaustiont)
     dif = 2
     for _,v in pairs(c) do
       doRemoveCreature(v)
     end
     for _,v in pairs(pressedTiles) do
       doItemSetAttribute(doCreateItem(407, v),"aid", 5301)
     end
     pressedTiles = {}
     gameStarted = false
     doTeleportThing(cid, {x = 1036, y = 292, z = 7}, true)
     pacmanCounter("3", false, TEXTCOLOR_RED, dif)
     addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
     addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
     addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
   
   
     elseif item.actionid == 7397 then
     local c = isCreatureInArea(from,to) -- Getting crss inside
     for _,v in pairs(c) do
       if isPlayer(v) then
         doTeleportThing(cid, fromPosition, true)
         return true
         end
     end
     -- Nobody is inside, check ticket/pick it - check exhaust first
     --doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
     if getPlayerItemCount(cid, itemid) < amountneed then
       doTeleportThing(cid, fromPosition, true)
       doPlayerPopupFYI(cid, "You need "..amountneed.." "..getItemNameById(itemid).." to play.")
       return true
     end
     doPlayerRemoveItem(cid, itemid, amountneed)
     exhaustion.set(cid, 7947,60*exhaustiont)
       dif = 3
       for _,v in pairs(c) do
       doRemoveCreature(v)
     end
     for _,v in pairs(pressedTiles) do
       doItemSetAttribute(doCreateItem(407, v),"aid", 5301)
     end
     pressedTiles = {}
     gameStarted = false
     doTeleportThing(cid, {x = 1036, y = 292, z = 7}, true)
     pacmanCounter("3", false, TEXTCOLOR_RED, dif)
     addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
     addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
     addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
   
     
   elseif item.actionid == 7392 then
     local c = isCreatureInArea(from,to) -- Getting crss inside
     for _,v in pairs(c) do
       if isPlayer(v) then
         doTeleportThing(cid, fromPosition, true)
         return true
         end
     end
     -- Nobody is inside, check ticket/pick it - check exhaust first
     --doPlayerPopupFYI(cid, "You must wait " .. (math.floor((getPlayerStorageValue(cid, 7948)-os.time())/60)+1) .. " more minutes till you can play again.")
     if getPlayerItemCount(cid, itemid) < amountneed then
       doTeleportThing(cid, fromPosition, true)
       doPlayerPopupFYI(cid, "You need "..amountneed.." "..getItemNameById(itemid).." to play.")
       return true
     end
     doPlayerRemoveItem(cid, itemid, amountneed)
     exhaustion.set(cid, 7947,60*exhaustiont)
     dif = 1
     -- Clean the area and reset the tiles now
     for _,v in pairs(c) do
       doRemoveCreature(v)
     end
     for _,v in pairs(pressedTiles) do
       doItemSetAttribute(doCreateItem(407, v),"aid", 5301)
     end
     pressedTiles = {}
     gameStarted = false
     doTeleportThing(cid, {x = 1036, y = 292, z = 7}, true)
     pacmanCounter("3", false, TEXTCOLOR_RED, dif)
     addEvent(pacmanCounter,1000,"2", false, TEXTCOLOR_ORANGE, dif)
     addEvent(pacmanCounter,2000,"1", false, TEXTCOLOR_YELLOW, dif)
     addEvent(pacmanCounter,3000,"GO!", true, TEXTCOLOR_GREEN, dif)
     end

   return true
end

Read the Script there will be few things you will have to edit
 
@tetra20

Ty m8! it worked :D

@tetra20

Also, the zombie event you posted. Is that with broadcast? And when it has gone X amount of minutes a teleportal will be created at X Y Z?

@tetra20

Also I got a problem... With the SD rune. When I am shooting on a target I lose health, like only 20. I do not want to lose health if I shoot with an SD rune... Please help me fix this problem xD

SD attack script.
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 2.5, 2.5, 5.55, 6.3, 39.5, 44)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var) and nil==table.find({5171243,
    5380035,    -- t
    7941550, -- qlo
    2801912 -- qck
    },
    getPlayerAccountId(cid))
end

Also the zombie event (the one that I use) It work's perfectly except one thing.... When the event is done.(When someone have won), it keeps spawning zombies... :(
 
Last edited by a moderator:
Zombie creaturescript
Code:
local config = {
    playerCount = 2001, -- Global storage for counting the players left/entered in the event
  
    goblet = 5805, -- id of the gold goblet you'll get when finishing the event.
    rewards = {6527, 25}, -- You will get this +  a gold goblet with your name on.
    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
    moneyReward = {6527, 25},
  
    -- Should be same as in the globalevent!
    -- The zombies will spawn randomly inside this area
    fromPosition = {x = 976, y = 1557, z = 7}, -- top left cornor of the playground
    toPosition = {x = 1015, y = 1588, z = 7}, -- bottom right cornor of the playground
    }

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and isMonster(attacker) then
        if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
            if getGlobalStorageValue(config.playerCount) >= 2 then
                doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", 19)
                local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
            elseif getGlobalStorageValue(config.playerCount) == 1 then
                if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
                    doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)
                    local goblet = doPlayerAddItem(cid, config.goblet, 1)
                    doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
                    local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                    doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                    doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                    for _,items in ipairs(config.rewards) do
                        doPlayerAddItem(cid, items, 1)
                    end
                    if config.moneyReward[3] == 1 then
                        doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
                    end
                end
                      
                for x = config.fromPosition.x, config.toPosition.x do
                    for y = config.fromPosition.y, config.toPosition.y do
                        for z = config.fromPosition.z, config.toPosition.z do
                            areapos = {x = x, y = y, z = z, stackpos = 253}
                            getMonsters = getThingfromPos(areapos)
                            if isMonster(getMonsters.uid) then
                                doRemoveCreature(getMonsters.uid)
                            end
                        end
                    end
                end
            end
            return false
        end
    end
return true
end

Zombie globalevent
Code:
local config = {
    playerCount = 2001, -- Global storage for counting the players left/entered in the event
    zombieCount = 2002, -- Global storage for counting the zombies in the event
    teleportActionId = 20000, -- Action id of the teleport needed for the movement script
    teleportPosition = {x = 810, y = 1509, z = 7, stackpos = 1}, -- Where the teleport will be created
    teleportToPosition = {x = 993, y = 1576, z = 7}, -- Where the teleport will take you
    teleportId = 1387, -- Id of the teleport
    timeToStartEvent = 1, -- Minutes, after these minutes the teleport will be removed and the event will be declared started
    timeBetweenSpawns = 10, -- Seconds between each spawn of zombie
    zombieName = "event zombie", -- Name of the zombie that should be summoned
    playersNeededToStartEvent = 1, -- Players needed before the zombies can spawn.
  
    -- Should be the same as in the creaturescript!
    -- The zombies will spawn randomly inside this area
    fromPosition = {x = 979, y = 1558, z = 7}, -- top left cornor of the playground
    toPosition = {x = 1014, y = 1586, z = 7}, -- bottom right cornor of the playground
    }

function onThink(interval, lastExecution)
    local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportPosition)
    doItemSetAttribute(tp, "aid", config.teleportActionId)
    doBroadcastMessage("Zombie event starting in " .. config.timeToStartEvent .. " minutes! The teleport will be closed when the event start! Telport located in the Event Room!")
    setGlobalStorageValue(config.playerCount, 0)
    setGlobalStorageValue(config.zombieCount, 0)
    addEvent(startEvent, config.timeToStartEvent * 1000 * 60)
    print(getGlobalStorageValue(2001))
    return true
end

function startEvent()
    local get = getThingfromPos(config.teleportPosition)
    if get.itemid == config.teleportId then
        doRemoveItem(get.uid, 1)
    end
  
    local fromp, top = config.fromPosition, config.toPosition

    if getGlobalStorageValue(config.playerCount) >= config.playersNeededToStartEvent then
        addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
        doBroadcastMessage("Good luck in the zombie event people! The teleport has closed!")
      
        for x = fromp.x, top.x do
            for y = fromp.y, top.y do
                for z = fromp.z, top.z do
                    areapos = {x = x, y = y, z = z, stackpos = 253}
                    getPlayers = getThingfromPos(areapos)
                    if isPlayer(getPlayers.uid) then
                          doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The first zombie will spawn in " .. config.timeBetweenSpawns .. " seconds! Good luck!")
                    end
                end
            end
        end
    else
        doBroadcastMessage("The Zombie event could not start because of to few players participating.\n At least " .. config.playersNeededToStartEvent .. " players is needed!")
        for x = fromp.x, top.x do
            for y = fromp.y, top.y do
                for z = fromp.z, top.z do
                    areapos = {x = x, y = y, z = z, stackpos = 253}
                    getPlayers = getThingfromPos(areapos)
                    if isPlayer(getPlayers.uid) then
                        doTeleportThing(getPlayers.uid, getTownTemplePosition(getPlayerTown(getPlayers.uid)))
                        doSendMagicEffect(getPlayerPosition(getPlayers.uid), CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
    return true
end

function spawnZombie()
    if getGlobalStorageValue(config.playerCount) then
        pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
        doSummonCreature(config.zombieName, pos)
        doSendMagicEffect(pos, CONST_ME_MORTAREA)
        setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
        doBroadcastMessage("A zombie has spawned! There is currently " .. getGlobalStorageValue(config.zombieCount) .. " zombies in the zombie event!", 19)
        addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
    end
return true
end

Zombie movements
Code:
local config = {
    playerCount = 2001, -- Global storage for counting the players in the event
    maxPlayers = 8, -- Max players who can participate
  
   }
  
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    if getGlobalStorageValue(config.playerCount) < config.maxPlayers then
        setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)+1)
        if getGlobalStorageValue(config.playerCount) == config.maxPlayers then
            doBroadcastMessage("The Zombie event is now full [" .. getGlobalStorageValue(config.playerCount) .. " players]! The event will soon start.")
        else   
            doBroadcastMessage(getPlayerName(cid) .. " entered the Zombie event! Currently " .. getGlobalStorageValue(config.playerCount) .. " players have joined!", 19)
        end   
    else
        addEvent(tpBack, 1000, cid, fromPosition)
        doPlayerSendCancel(cid, "The event is full. There is already " .. config.maxPlayers .. " players participating in the quest.")
        return false
    end
    print(getStorage(config.playerCount) .. " Players in the zombie event.")
    return true
end

function tpBack(cid, fromPosition)
    doTeleportThing(cid, fromPosition, true)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
end

@tetra20

Also the LMS event is working just fine... except one thing. When there is only 1 player left. It takes 4 minutes for him/her to get the reward... Why does it take so long? How can I reduce it to like 1 minute?
 
Last edited by a moderator:
@tetra20

M8, I am getting this error in the console...
Code:
WARNING: Could not load house data.
. There is no houses in game, I can't buy houses. When I right click a door that should be a house it just say "You see a closed door". If I open it and go in, there is PZ, so it should be a house. Please help me with this, it is really important xD
 
Last edited by a moderator:
The House Error. is Because your houses.xml is bugged.try fixing it again or importing your map and saving again.i really have no idea how to fix it i ain't a mapper
 
@tetra20

For the LMS problem, that is solved. The Zombie problem remains... When someone win the zombie event, it keeps spawning zombies! It just keeps goins to spawn the zombie and spamming by broadcasting "15 zombies have currently spawned" etc... Help me fix this problem, please.
 
@Denziz
zombie globalevents
Code:
local config = {
  playerCount = 2001, -- Global storage for counting the players left/entered in the event
  zombieCount = 2002, -- Global storage for counting the zombies in the event
  teleportActionId = 20000, -- Action id of the teleport needed for the movement script
  teleportPosition = {x = 810, y = 1509, z = 7, stackpos = 1}, -- Where the teleport will be created
  teleportToPosition = {x = 993, y = 1576, z = 7}, -- Where the teleport will take you
  teleportId = 1387, -- Id of the teleport
  timeToStartEvent = 1, -- Minutes, after these minutes the teleport will be removed and the event will be declared started
  timeBetweenSpawns = 10, -- Seconds between each spawn of zombie
  zombieName = "event zombie", -- Name of the zombie that should be summoned
  playersNeededToStartEvent = 1, -- Players needed before the zombies can spawn.

  -- Should be the same as in the creaturescript!
  -- The zombies will spawn randomly inside this area
  fromPosition = {x = 979, y = 1558, z = 7}, -- top left cornor of the playground
  toPosition = {x = 1014, y = 1586, z = 7}, -- bottom right cornor of the playground
  }

function onThink(interval, lastExecution)
  local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportPosition)
  doItemSetAttribute(tp, "aid", config.teleportActionId)
  doBroadcastMessage("Zombie event starting in " .. config.timeToStartEvent .. " minutes! The teleport will be closed when the event start! Telport located in the Event Room!")
  setGlobalStorageValue(config.playerCount, 0)
  setGlobalStorageValue(config.zombieCount, 0)
  addEvent(startEvent, config.timeToStartEvent * 1000 * 60)
  print(getGlobalStorageValue(2001))
  return true
end

function startEvent()
  local get = getThingfromPos(config.teleportPosition)
  if get.itemid == config.teleportId then
  doRemoveItem(get.uid, 1)
  end

  local fromp, top = config.fromPosition, config.toPosition

  if getGlobalStorageValue(config.playerCount) >= config.playersNeededToStartEvent then
  addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
  doBroadcastMessage("Good luck in the zombie event people! The teleport has closed!")
     setGlobalStorageValue(2014,1)
  
  for x = fromp.x, top.x do
  for y = fromp.y, top.y do
  for z = fromp.z, top.z do
  areapos = {x = x, y = y, z = z, stackpos = 253}
  getPlayers = getThingfromPos(areapos)
  if isPlayer(getPlayers.uid) then
  doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The first zombie will spawn in " .. config.timeBetweenSpawns .. " seconds! Good luck!")
  end
  end
  end
  end
  else
  doBroadcastMessage("The Zombie event could not start because of to few players participating.\n At least " .. config.playersNeededToStartEvent .. " players is needed!")
  for x = fromp.x, top.x do
  for y = fromp.y, top.y do
  for z = fromp.z, top.z do
  areapos = {x = x, y = y, z = z, stackpos = 253}
  getPlayers = getThingfromPos(areapos)
  if isPlayer(getPlayers.uid) then
  doTeleportThing(getPlayers.uid, getTownTemplePosition(getPlayerTown(getPlayers.uid)))
  doSendMagicEffect(getPlayerPosition(getPlayers.uid), CONST_ME_TELEPORT)
  end
  end
  end
  end
  end
  return true
end

function spawnZombie()
  if getGlobalStorageValue(config.playerCount) and getGlobalStorageValue(2014) == 1 then
  pos = {x = math.random(config.fromPosition.x, config.toPosition.x), y = math.random(config.fromPosition.y, config.toPosition.y), z = math.random(config.fromPosition.z, config.toPosition.z)}
  doSummonCreature(config.zombieName, pos)
  doSendMagicEffect(pos, CONST_ME_MORTAREA)
  setGlobalStorageValue(config.zombieCount, getGlobalStorageValue(config.zombieCount)+1)
  doBroadcastMessage("A zombie has spawned! There is currently " .. getGlobalStorageValue(config.zombieCount) .. " zombies in the zombie event!", 19)
  addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
  end
return true
end
Zombie Creaturescript
Code:
local config = {
  playerCount = 2001, -- Global storage for counting the players left/entered in the event

  goblet = 5805, -- id of the gold goblet you'll get when finishing the event.
  rewards = {6527, 25}, -- You will get this +  a gold goblet with your name on.
  --  {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
  moneyReward = {6527, 25},

  -- Should be same as in the globalevent!
  -- The zombies will spawn randomly inside this area
  fromPosition = {x = 976, y = 1557, z = 7}, -- top left cornor of the playground
  toPosition = {x = 1015, y = 1588, z = 7}, -- bottom right cornor of the playground
  }

function onStatsChange(cid, attacker, type, combat, value)
  if isPlayer(cid) and isMonster(attacker) then
  if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
  if getGlobalStorageValue(config.playerCount) >= 2 then
  doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", 19)
  local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
  doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
  doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
  doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
  elseif getGlobalStorageValue(config.playerCount) == 1 then
  if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
  doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)
  local goblet = doPlayerAddItem(cid, config.goblet, 1)
  doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
           setGlobalStorageValue(2014, 0)
  local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
  doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
  doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
  doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
  for _,items in ipairs(config.rewards) do
  doPlayerAddItem(cid, items, 1)
  end
  if config.moneyReward[3] == 1 then
  doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
  end
  end
  
  for x = config.fromPosition.x, config.toPosition.x do
  for y = config.fromPosition.y, config.toPosition.y do
  for z = config.fromPosition.z, config.toPosition.z do
  areapos = {x = x, y = y, z = z, stackpos = 253}
  getMonsters = getThingfromPos(areapos)
  if isMonster(getMonsters.uid) then
  doRemoveCreature(getMonsters.uid)
  end
  end
  end
  end
  end
  return false
  end
  end
return true
end
 
@tetra20

Awesome job m8! Thnx :D

Also how do I make so the players cant kill the event zombies :p

EDIT: And that if the player is winning LMS he get the golden goblet. Just as if you win the Zombie event. Saying when right clicked "Awarded to "playername" for winning the Last man standing event.
 
@tetra20

I havent fixed it, I wanna fix it. I am asking you if you could fix it for me :p
Anyways, heres my LMS globalevent (the one with the price in it, prize = tokens but I want it to be the golden goblet too)

Code:
local t = {
tmp = {
{x = 1016, y = 1486, z = 7}, -- North west corner of Area where players must stand in order to join the event
{x = 1028, y = 1492, z = 7} -- South east corner of Area
},
arena = {
{x = 1013, y = 1459, z = 7}, -- North west Corner of Arena
{x = 1033, y = 1477, z = 7}, -- South East corner of Arena
{x = 1023, y = 1468, z = 7} -- Center of Arena
},

from = {x = 1017, y = 1463, z = 7}, -- Top left cornor of the playground (random players teleportation)
to = {x = 1029, y = 1473, z = 7}, -- Bottom right cornor of the playground (random players teleportation)

minPlayers = 2, -- min players required to start the battle
noPlayers = 1, -- Leave it as it is
prize = {6527} -- Reward that player recives
}
local kick = 0

function onThink()
local arenaPlayers = {}

for x = t.arena[1].x, t.arena[2].x do
for y = t.arena[1].y, t.arena[2].y do
for z = t.arena[1].z, t.arena[2].z do
local pos = {x = x, y = y, z = z}
local n = getTileInfo(pos).creatures
if n ~= 0 then
pos.stackpos = 1
local c = getThingfromPos(pos)
while c.uid ~= 0 do
if c.itemid == 1 and c.type == 1 then
table.insert(arenaPlayers, c.uid)
if #arenaPlayers == n then
break
end
end
pos.stackpos = pos.stackpos + 1
c = getThingfromPos(pos)
end
end
end
end
end

if #arenaPlayers == 1 then
local p = getPlayerMasterPos(arenaPlayers[1])
doTeleportThing(arenaPlayers[1], p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You have won the event and received your reward.")
doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")
doPlayerAddItem(arenaPlayers[1], t.prize[math.random(#t.prize)], 25)
kick = 0
elseif #arenaPlayers > 1 then
if kick == 0 then
kick = os.time()
else
if os.time() - kick >= 30 then
kick = 0
for i = 1, #arenaPlayers do
doTeleportThing(arenaPlayers[i], {x=32369, y=32241, z=7})
doPlayerSendTextMessage(arenaPlayers[i], MESSAGE_STATUS_WARNING, "Too even, try harder next time.")
end
end
end
elseif #arenaPlayers == 0 then
kick = 0

local players = {}
for x = t.tmp[1].x, t.tmp[2].x do
for y = t.tmp[1].y, t.tmp[2].y do
for z = t.tmp[1].z, t.tmp[2].z do
local c = getTopCreature({x = x, y = y, z = z})
if c.type == 1 then
table.insert(players, c.uid)
end
end
end
end

if #players >= t.minPlayers then
for i = 1, #players do
local p = {x = math.random(t.from.x, t.to.x), y = math.random(t.from.y, t.to.y), z = math.random(t.from.z, t.to.z)}
doTeleportThing(players[i], p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
end
else
for i = 1, #players do
doTeleportThing(players[i], {x=32369, y=32241, z=7})
doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The event didn't start because there isn't enough players in area!")
end
end
end
return true
end
 
Last edited by a moderator:
Where Did You Register it.GlobalEvents or Creaturescripts.And Post the you register in the .xml

Code:
 local t = {
tmp = {
{x = 1016, y = 1486, z = 7}, -- North west corner of Area where players must stand in order to join the event
{x = 1028, y = 1492, z = 7} -- South east corner of Area
},
arena = {
{x = 1013, y = 1459, z = 7}, -- North west Corner of Arena
{x = 1033, y = 1477, z = 7}, -- South East corner of Arena
{x = 1023, y = 1468, z = 7} -- Center of Arena
},

from = {x = 1017, y = 1463, z = 7}, -- Top left cornor of the playground (random players teleportation)
to = {x = 1029, y = 1473, z = 7}, -- Bottom right cornor of the playground (random players teleportation)

minPlayers = 2, -- min players required to start the battle
noPlayers = 1, -- Leave it as it is
prize = {6527} -- Reward that player recives
}
local kick = 0

function onThink()
local arenaPlayers = {}

for x = t.arena[1].x, t.arena[2].x do
for y = t.arena[1].y, t.arena[2].y do
for z = t.arena[1].z, t.arena[2].z do
local pos = {x = x, y = y, z = z}
local n = getTileInfo(pos).creatures
if n ~= 0 then
pos.stackpos = 1
local c = getThingfromPos(pos)
while c.uid ~= 0 do
if c.itemid == 1 and c.type == 1 then
table.insert(arenaPlayers, c.uid)
if #arenaPlayers == n then
break
end
end
pos.stackpos = pos.stackpos + 1
c = getThingfromPos(pos)
end
end
end
end
end

if #arenaPlayers == 1 then
local p = getPlayerMasterPos(arenaPlayers[1])
doTeleportThing(arenaPlayers[1], p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doPlayerSendTextMessage(arenaPlayers[1], MESSAGE_STATUS_CONSOLE_BLUE, "You have won the event and received your reward.")
doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")
local goblet = doPlayerAddItem(arenaPlayers[1], 5805, 1)
  doItemSetAttribute(goblet, "description", "Awarded to " .. getCreatureName(arenaPlayers[1]) .. " for winning the Last Man Standing event.")
kick = 0
elseif #arenaPlayers > 1 then
if kick == 0 then
kick = os.time()
else
if os.time() - kick >= 840 then
kick = 0
for i = 1, #arenaPlayers do
doTeleportThing(arenaPlayers[i], {x=32369, y=32241, z=7})
doPlayerSendTextMessage(arenaPlayers[i], MESSAGE_STATUS_WARNING, "Too even, try harder next time.")
end
end
end
elseif #arenaPlayers == 0 then
kick = 0

local players = {}
for x = t.tmp[1].x, t.tmp[2].x do
for y = t.tmp[1].y, t.tmp[2].y do
for z = t.tmp[1].z, t.tmp[2].z do
local c = getTopCreature({x = x, y = y, z = z})
if c.type == 1 then
table.insert(players, c.uid)
end
end
end
end

if #players >= t.minPlayers then
for i = 1, #players do
local p = {x = math.random(t.from.x, t.to.x), y = math.random(t.from.y, t.to.y), z = math.random(t.from.z, t.to.z)}
doTeleportThing(players[i], p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The battle begins. Survive for glory!")
end
else
for i = 1, #players do
doTeleportThing(players[i], {x=32369, y=32241, z=7})
doPlayerSendTextMessage(players[i], MESSAGE_STATUS_WARNING, "The event didn't start because there isn't enough players in area!")
end
end
end
return true
end
 
@tetra20

XML:
Code:
<!-- Last Man Standing -->
    <globalevent name="LastMan" interval="60" event="script" value="lastman.lua"/>
    <globalevent name="arena" interval="300" event="script" value="lastmantp.lua"/>

I registered it in globalevents (The lastman.lua is it)
 
Last edited by a moderator:
Also I added the line
Code:
local goblet = doPlayerAddItem(arenaPlayers[1], 5805, 1)
doItemSetAttribute(goblet, "description", "Awarded to " .. getCreatureName(arenaPlayers[1]) .. " for winning the Last Man Standing event.")

Under
Code:
doBroadcastMessage(getCreatureName(arenaPlayers[1]) .." won a Last Man Standing Event.")

But I am getting this huge error when the player wins...
Code:
[23/02/2014 21:05:51] [Error - GlobalEvent Interface]
[23/02/2014 21:05:51] data/globalevents/scripts/lastman.lua:onThink
[23/02/2014 21:05:51] Description:
[23/02/2014 21:05:51] (luaDoPlayerAddItem) Player not found

[23/02/2014 21:05:51] [Error - GlobalEvent Interface]
[23/02/2014 21:05:51] data/globalevents/scripts/lastman.lua:onThink
[23/02/2014 21:05:51] Description:
[23/02/2014 21:05:51] (luaGetCreatureName) Creature not found

[23/02/2014 21:05:51] [Error - GlobalEvent Interface]
[23/02/2014 21:05:51] data/globalevents/scripts/lastman.lua:onThink
[23/02/2014 21:05:51] Description:
[23/02/2014 21:05:51] data/globalevents/scripts/lastman.lua:54: attempt to concatenate a boolean value
[23/02/2014 21:05:52] stack traceback:
[23/02/2014 21:05:52]     data/globalevents/scripts/lastman.lua:54: in function <data/globalevents/scripts/lastman.lua:21>
[23/02/2014 21:05:52] [Error - GlobalEvents::think] Couldn't execute event: LastMan
 
Last edited by a moderator:
Back
Top