• 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 Zombile event

when added this in globalevent under fuction statevent()
player can tp to event area without launching event :S
 
Did you change anything in the talkaction? Player should only be able to join if the storage value is 1, not if it's 0 or 2.
 
talkaction
Code:
local config = {
     playerCount = 2001, -- Global storage for counting the players in the event
     maxPlayers = 15 -- Max players who can participate
}
 
function onSay(cid, words, param)
     if getGlobalStorageValue(80001) ~= 1 then
         doPlayerSendCancel(cid, "There is no event launching.")
         return false
     end
              if getCreatureCondition(cid, CONDITION_INFIGHT) then
     return doPlayerSendCancel(cid, "You can't join the event when you're in a fight.")
end
     if getGlobalStorageValue(config.playerCount) < config.maxPlayers then
         setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)+1)
         doTeleportThing(cid, {x = math.random(978, 1077), y = math.random(1870, 1954), z = 7}) -- waiting room position
         if getGlobalStorageValue(config.playerCount) == config.maxPlayers then
             doBroadcastMessage("The Zombie event is now full [" .. getGlobalStorageValue(config.playerCount) .. " players]! The event will soon start.")
         else 
         end 
     else
         doPlayerSendCancel(cid, "The event is full. There is already " .. config.maxPlayers .. " players participating in the quest.")
         return false
     end
     return true
end

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 = 2000, -- Action id of the teleport needed for the movement script
    teleportPosition = {x = 1003, y = 996, z = 7, stackpos = 1}, -- Where the teleport will be created
    teleportsPosition = {x = 997, y = 996, z = 7, stackpos = 1}, -- Where the teleport will be created
    teleportToPosition = {x = 1050, y = 1919, z = 7}, -- Where the teleport will take you
    teleportId = 1387, -- Id of the teleport
    timeToStartEvent = 3, -- Minutes, after these minutes the teleport will be removed and the event will be declared started
    timeBetweenSpawns = 20, -- Seconds between each spawn of zombie
    zombieName = "Big foot", -- Name of the zombie that should be summoned
    playersNeededToStartEvent = 2, -- 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 = 978, y = 1870, z = 7}, -- top left cornor of the playground
    toPosition = {x = 1077, y = 1954, z = 7}, -- bottom right cornor of the playground
    }
  
    local function doBroadcastAmount(x)
     return doBroadcastMessage("Big foot event starting in " .. (config.timeToStartEvent - x) .. " minutes " .. getGlobalStorageValue(config.playerCount) .. " players have joined The teleport will be closed when the event start!", MESSAGE_STATUS_WARNING)
end

function onThink(interval, lastExecution, thinkInterval)
    local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportPosition)
    doItemSetAttribute(tp, "aid", config.teleportActionId)
    local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportsPosition)
doItemSetAttribute(tp, "aid", config.teleportActionId)
    doBroadcastMessage("Big foot event starting in " .. config.timeToStartEvent .. " minutes. The teleport will be closed when the event start!", MESSAGE_STATUS_WARNING)
for x = 1, config.timeToStartEvent - 1 do
     addEvent(doBroadcastAmount, x * 60 * 1000, x)
end
    setGlobalStorageValue(config.playerCount, 0)
    setGlobalStorageValue(config.zombieCount, 0)
    addEvent(startEvent, config.timeToStartEvent * 1000 * 60)
    setGlobalStorageValue(80001, 1)
    return true
end

function startEvent()
setGlobalStorageValue(80001, 2)
    local get = getTileItemById(config.teleportPosition, config.teleportId).uid
if get > 0 then
     doRemoveItem(get, 1)
end
local get = getTileItemById(config.teleportsPosition, config.teleportId).uid
if get > 0 then
     doRemoveItem(get, 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 Big foot event " .. getGlobalStorageValue(config.playerCount) .. " players have joined. The teleport has closed!", MESSAGE_STATUS_WARNING)
      
        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 = getTopCreature(areapos)
                    if isPlayer(getPlayers.uid) then
                        doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The first Big foot will spawn in " .. config.timeBetweenSpawns .. " seconds! Good luck!")
                    end
                end
            end
        end
    else
        doBroadcastMessage("The Big foot event could not start because of to few players participating.\n At least " .. config.playersNeededToStartEvent .. " players is needed!", MESSAGE_STATUS_WARNING)
        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 = getTopCreature(areapos)
                    if isPlayer(getPlayers.uid) then
                        doTeleportThing(getPlayers.uid, getTownTemplePosition(getPlayerTown(getPlayers.uid)), false)
                        doSendMagicEffect(getPlayerPosition(getPlayers.uid), CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
end

function spawnZombie()
    if getGlobalStorageValue(config.playerCount) >= 2 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)
        for _, pid in ipairs(getPlayersOnline()) do
     if isInRange(getPlayerPosition(pid), config.fromPosition, config.toPosition) then
         doPlayerSendChannelMessage(pid, "", "A Big foot has spawned! There is currently " .. getGlobalStorageValue(config.zombieCount) .. " Big foot in the Big foot event!", TALKTYPE_CHANNEL_O,12)
     end
end
        addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
    end
end


??????????
 
Last edited:
The script says if the storage value isn't 1 then players can't join.
If you add this under function onSay if there is no event running and you can still join, what does it show in your console?
Code:
print(getGlobalStorageValue(80001))
You can also add an extra message for if it's 2.

Under function onSay.
Code:
if getGlobalStorageValue(80001) == 2 then
     doPlayerSendCancel(cid, "The event already started, you can't join anymore.")
     return false
end
 
Code:
local config = {
     playerCount = 2001, -- Global storage for counting the players in the event
     maxPlayers = 15 -- Max players who can participate
}
function onSay(cid, words, param)
print(getGlobalStorageValue(80001))
if getGlobalStorageValue(80001) == 2 then
     doPlayerSendCancel(cid, "The event already started, you can't join anymore.")
     return false
end
     if getGlobalStorageValue(80001) ~= 1 then
         doPlayerSendCancel(cid, "There is no event launching.")
         return false
     end
              if getCreatureCondition(cid, CONDITION_INFIGHT) then
     return doPlayerSendCancel(cid, "You can't join the event when you're in a fight.")
end
     if getGlobalStorageValue(config.playerCount) < config.maxPlayers then
         setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)+1)
         doTeleportThing(cid, {x = math.random(978, 1077), y = math.random(1870, 1954), z = 7}) -- waiting room position
         if getGlobalStorageValue(config.playerCount) == config.maxPlayers then
             doBroadcastMessage("The Zombie event is now full [" .. getGlobalStorageValue(config.playerCount) .. " players]! The event will soon start.")
         else
         end
     else
         doPlayerSendCancel(cid, "The event is full. There is already " .. config.maxPlayers .. " players participating in the quest.")
         return false
     end
     return true
end

no thing player can tp to event area without launching event :S

and no error in console :S
 
I mean, do you get this message: "The event already started, you can't join anymore." and then you can join the event?
Or which message do you get when you can join the event when it shouldn't?
 
when i say !joinevent get this msg The event already started, you can't join anymore and i don't tp and event don't launching
 
when no launching event say " no event lauching in moment" nd when die in event and say !joinevent again say "you can't join anymore" and when try to say !joinevent after lauch event say "The event already started, you can't join anymore"

its now say "The event already started, you can't join anymore
if there event launching or no
 
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 = {2195, 2152, 2160}, -- You will get this +  a gold goblet with your name on.
    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
    moneyReward = {2160, 10, 1},
   
    -- Should be same as in the globalevent!
    -- The zombies will spawn randomly inside this area
    fromPosition = {x = 978, y = 1870, z = 7}, -- top left cornor of the playground
    toPosition = {x = 1077, y = 1954, 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
                 for _, pid in ipairs(getPlayersOnline()) do
     if isInRange(getPlayerPosition(pid), config.fromPosition, config.toPosition) then
         doPlayerSendChannelMessage(getPlayerName(cid) .. " have been eated by Big foot!", TALKTYPE_CHANNEL_W,12)
     end
end
                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) == 2 then
                if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
                            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
                            setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
for _, pid in ipairs(getPlayersOnline()) do
     if isInRange(getPlayerPosition(pid), config.fromPosition, config.toPosition) then
         cid = pid
     end
end
                    doBroadcastMessage(getPlayerName(cid) .. " won the Big foot event! Congratulations!", MESSAGE_STATUS_WARNING)
                    setGlobalStorageValue(80001, 0)
                    local goblet = doPlayerAddItem(cid, config.goblet, 1)
                    doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Big foot event.")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                     doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
                    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 = getTopCreature(areapos)
                            if isMonster(getMonsters.uid) then
                                doRemoveCreature(getMonsters.uid)
                            end
                        end
                    end
                end
            end
            return false
        end
    end
return true
end

and now when say !joinevent and event is launching say "The event already started, you can't join anymore" and don't tp me to event area :S
 
If the event started people shouldn't be able to join right? Or do you mean people can join even when it's started but just not join again when they died?
 
the event started people shouldn't be able to join....now i seen brodcast "event start in balalalalalalalal." and when player say !joinevent ""The event already started, you can't join anymore" and don't tp player
 
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 = 2000, -- Action id of the teleport needed for the movement script
    teleportPosition = {x = 1003, y = 996, z = 7, stackpos = 1}, -- Where the teleport will be created
    teleportsPosition = {x = 997, y = 996, z = 7, stackpos = 1}, -- Where the teleport will be created
    teleportToPosition = {x = 1050, y = 1919, z = 7}, -- Where the teleport will take you
    teleportId = 1387, -- Id of the teleport
    timeToStartEvent = 3, -- Minutes, after these minutes the teleport will be removed and the event will be declared started
    timeBetweenSpawns = 20, -- Seconds between each spawn of zombie
    zombieName = "Big foot", -- Name of the zombie that should be summoned
    playersNeededToStartEvent = 2, -- 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 = 978, y = 1870, z = 7}, -- top left cornor of the playground
    toPosition = {x = 1077, y = 1954, z = 7}, -- bottom right cornor of the playground
    }
   
    local function doBroadcastAmount(x)
     return doBroadcastMessage("Big foot event starting in " .. (config.timeToStartEvent - x) .. " minutes " .. getGlobalStorageValue(config.playerCount) .. " players have joined The teleport will be closed when the event start!", MESSAGE_STATUS_WARNING)
end

function onThink(interval, lastExecution, thinkInterval)
    local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportPosition)
    doItemSetAttribute(tp, "aid", config.teleportActionId)
    local tp = doCreateTeleport(config.teleportId, config.teleportToPosition, config.teleportsPosition)
doItemSetAttribute(tp, "aid", config.teleportActionId)
    doBroadcastMessage("Big foot event starting in " .. config.timeToStartEvent .. " minutes. The teleport will be closed when the event start!", MESSAGE_STATUS_WARNING)
for x = 1, config.timeToStartEvent - 1 do
     addEvent(doBroadcastAmount, x * 60 * 1000, x)
end
    setGlobalStorageValue(config.playerCount, 0)
    setGlobalStorageValue(config.zombieCount, 0)
    addEvent(startEvent, config.timeToStartEvent * 1000 * 60)
    setGlobalStorageValue(80001, 1)
    return true
end

function startEvent()
setGlobalStorageValue(80001, 2)
    local get = getTileItemById(config.teleportPosition, config.teleportId).uid
if get > 0 then
     doRemoveItem(get, 1)
end
local get = getTileItemById(config.teleportsPosition, config.teleportId).uid
if get > 0 then
     doRemoveItem(get, 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 Big foot event " .. getGlobalStorageValue(config.playerCount) .. " players have joined. The teleport has closed!", MESSAGE_STATUS_WARNING)
       
        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 = getTopCreature(areapos)
                    if isPlayer(getPlayers.uid) then
                        doPlayerSendTextMessage(getPlayers.uid, MESSAGE_EVENT_ADVANCE, "The first Big foot will spawn in " .. config.timeBetweenSpawns .. " seconds! Good luck!")
                    end
                end
            end
        end
    else
        doBroadcastMessage("The Big foot event could not start because of to few players participating.\n At least " .. config.playersNeededToStartEvent .. " players is needed!", MESSAGE_STATUS_WARNING)
        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 = getTopCreature(areapos)
                    if isPlayer(getPlayers.uid) then
                        doTeleportThing(getPlayers.uid, getTownTemplePosition(getPlayerTown(getPlayers.uid)), false)
                        doSendMagicEffect(getPlayerPosition(getPlayers.uid), CONST_ME_TELEPORT)
                    end
                end
            end
        end
    end
end

function spawnZombie()
    if getGlobalStorageValue(config.playerCount) >= 2 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)
        for _, pid in ipairs(getPlayersOnline()) do
     if isInRange(getPlayerPosition(pid), config.fromPosition, config.toPosition) then
         doPlayerSendChannelMessage(pid, "", "A Big foot has spawned! There is currently " .. getGlobalStorageValue(config.zombieCount) .. " Big foot in the Big foot event!", TALKTYPE_CHANNEL_O,12)
     end
end
        addEvent(spawnZombie, config.timeBetweenSpawns * 1000)
    end
end

talkaction
Code:
local config = {
     playerCount = 2001, -- Global storage for counting the players in the event
     maxPlayers = 15 -- Max players who can participate
}
function onSay(cid, words, param)
print(getGlobalStorageValue(80001))
if getGlobalStorageValue(80001) == 2 then
     doPlayerSendCancel(cid, "The event already started, you can't join anymore.")
     return false
end
     if getGlobalStorageValue(80001) ~= 1 then
         doPlayerSendCancel(cid, "There is no event launching.")
     end
              if getCreatureCondition(cid, CONDITION_INFIGHT) then
     return doPlayerSendCancel(cid, "You can't join the event when you're in a fight.")
end
     if getGlobalStorageValue(config.playerCount) < config.maxPlayers then
         setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)+1)
         doTeleportThing(cid, {x = math.random(978, 1077), y = math.random(1870, 1954), z = 7}) -- waiting room position
         if getGlobalStorageValue(config.playerCount) == config.maxPlayers then
             doBroadcastMessage("The Zombie event is now full [" .. getGlobalStorageValue(config.playerCount) .. " players]! The event will soon start.")
         else
         end
     else
         doPlayerSendCancel(cid, "The event is full. There is already " .. config.maxPlayers .. " players participating in the quest.")
         return false
     end
     return true
end


and creature up
 
Back
Top