Hi there, im really trying to make it work and i honestly have no idea where or what the issue is.
If anyone cares to help me, i would really appreciate it
then when the server starts it spams:
I use rev 3777 on client 8.6
botmanager.lua
Thanks!
If anyone cares to help me, i would really appreciate it
Code:
<LuasetCombatArea> Area not found.
Code:
[Error - GlobalEvent Interface]
data/globalevents/scripts/botmanager.lua:onThink
Description:
data/globalevents/scripts/botmanager.lua:57: bad argument #2 to 'random' <interval is not empty>
[C]: in function ' random'
data/globalevents/scripts/botmanager.lua:57: in function <data/globalevents/scripts/botmanager.lua:7>
[Error - Globalevents::think] Couldn't execute event: botmanager
I use rev 3777 on client 8.6
botmanager.lua
Code:
local keepOnline = 23
local maxChange = 2
local minOnline = 2
local maxOnline = 35
function onThink(interval, lastExecution, thinkInterval)
if(getStorage(81666) ~= -1) then
keepOnline = getStorage(81666)
doSetStorage(81666, -1)
print("Changed bots number to: " .. keepOnline)
end
if(getStorage(81667) ~= -1) then
minOnline = getStorage(81667)
doSetStorage(81667, -1)
print("Changed min bots number to: " .. minOnline)
end
if(getStorage(81668) ~= -1) then
maxOnline = getStorage(81668)
doSetStorage(81668, -1)
print("Changed max bots number to: " .. maxOnline)
end
if(math.random(1,4) == 2) then
keepOnline = math.min(maxOnline, math.max(keepOnline+math.random(-1,1), minOnline))
end
local online = getPlayersOnline()
local botsOnline = {}
local botsOffline = {}
local playersOnline = {}
for _, cid in pairs(online) do
doPlayerFeed(cid, 9999)
if(isBot(cid) and isBotActive(cid)) then
table.insert(botsOnline, cid)
elseif(not isBot(cid)) then
table.insert(playersOnline, cid)
else
table.insert(botsOffline, cid)
end
end
print("BOTS: " .. #botsOnline .. " (" .. keepOnline .. "), P: " .. #playersOnline)
if(#playersOnline+#botsOnline > keepOnline) then
if(#botsOnline > 0) then
local toRemove = math.min(maxChange, #playersOnline+#botsOnline-keepOnline)
for i = 1, toRemove do
for i, bot in pairs(botsOnline) do
if(getTileInfo(getThingPosition(bot)).protection) then
setBotActive(bot, false)
table.remove(botsOnline, i)
break
end
end
end
end
elseif(#playersOnline+#botsOnline < keepOnline) then
for i = 1, maxChange do
if(#playersOnline+#botsOnline+i <= keepOnline) then
local bot = botsOffline[math.random(1,#botsOffline)]
setBotActive(bot, true)
end
end
end
return true
end
function setBotDelayed(name)
setBot(getPlayerByName(name), 1)
setBotActive(getPlayerByName(name), false)
end
function onStartup()
for i=1,200 do
loadPlayer(getBotNameByID(i))
addEvent(setBotDelayed, 1000, getBotNameByID(i))
end
return true
end
Thanks!