Eduardo170
Well-Known Member
Thanks to StreamSide, I share the script I made.
Last edited:
function onTime(interval, lastExecution)
local minPlayers = 1
local maxPlayers = 2
local waitTime = 5
local playersOnline = getOnlinePlayers()
if playersOnline > maxPlayers then --How do I set this correctly?
-- If it's a staff member, just teleport inside and do not count as a participant
if player:getGroup():getAccess() then
player:teleportTo(ze_WaitingRoomStartPosition)
return false
end
-- If the state of the event is closed or started, stop them from join
if isInArray({ze_EVENT_CLOSED, ze_EVENT_STARTED}, getZombieEventState()) then
return false
end
-- If player got pz, forbid them to join
if player:isPzLocked() then
player:sendCancelMessage("You cannot join while your in a fight.")
return false
end
-- If there is max players joined, stop them from join
if getZombieEventJoinedCount() >= ze_maxPlayers then
player:sendCancelMessage("The event is already full.")
return false
end
-- Set the new variables and setup the event
setupZombieEvent(minPlayers, maxPlayers, waitTime)
end
return false
end
Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/zombie_arena.lua:onTime
data/globalevents/scripts/zombie_arena.lua:8: attempt to compare number with table
stack traceback:
[C]: in function '__lt'
data/globalevents/scripts/zombie_arena.lua:8: in function <data/globalevents/scripts/zombie_arena.lua:1>
local playersOnline = getOnlinePlayers()
local playersOnline = #getOnlinePlayers()
Update: I did it. Thank you.I guess this function "getOnlinePlayers" returns a table with the id and the name of the player, so maybe try change:
toLUA:local playersOnline = getOnlinePlayers()
LUA:local playersOnline = #getOnlinePlayers()
function onTime(interval, lastExecution)
local minPlayers = 3 --
local maxPlayers = 3 --
local waitTime = 1 --
local playersOnline = #getOnlinePlayers()
if playersOnline >= maxPlayers then
Game.broadcastMessage("Zombie Event it's coming...", MESSAGE_STATUS_WARNING)
print('...Game.broadcastMessage("Zombie Event Starting...", MESSAGE_STATUS_WARNING)...')
-- Set the new variables and setup the event
setupZombieEvent(minPlayers, maxPlayers, waitTime)
else
Game.broadcastMessage("[Zombie Event]: Insufficient online players to open the event", MESSAGE_STATUS_WARNING)
print('[Zombie Event]: Insufficient online players to open the event')
end
return false
end