• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Gesior Bot scripts

Lightonia

Lightonia.servegame.com
Joined
Jun 4, 2007
Messages
492
Reaction score
9
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

Code:
<LuasetCombatArea> Area not found.
then when the server starts it spams:
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!
 
Solution
Replace correct part with this code (had the same problem as you):
LUA:
    elseif(#playersOnline+#botsOnline < keepOnline) then
       for i = 1, maxChange do
           if(#playersOnline + #botsOnline+i <= keepOnline) then
               for i, bot in pairs(botsOffline) do
                   setBotActive(bot, true)
                   table.remove(botsOffline, i)
                   break
               end
           end
       end
   end

#btw
By this script you can be banned on otserverlists, so remember to add few changes to prevent yourself ;)
Few years ago I had always 400 ppl online while starting the new server, no one could detect that Im cheating :D
Did you add the source code or lib code? Seeing as he is using custom functions here, Eg.
Code:
setBotActive()
is not in tfs by defult.
 
Found this in the bot lib, does it have to do with anything?
Can't post the whole lib as it is much more than 10 000 letters.
Code:
function getTries(cid)
   return math.max(0, getCreatureStorage(cid, 59431))
end

function setTries(cid, value)
   doCreatureSetStorage(cid, 59431, value)
end

function isBot(cid)
   return (getCreatureStorage(cid, 59432) ~= -1)
end

function setBot(cid, bot)
   setPlayerModes(cid, 1,1,1)
   return doCreatureSetStorage(cid, 59432, bot)
end

function isBotActive(cid)
   return (getCreatureStorage(cid, 59433) > -1)
end

function setBotActive(cid, active)
   setPlayerModes(cid, 1,1,1)
   if(active) then
     doCreatureSetSkullType(cid, SKULL_NONE)
     recalculateHPandMana(cid)
     doTeleportThing(cid, getTownTemplePosition(math.random(1, 6)))
     doCreatureSetStorage(cid, 59433, 1)
     db.executeQuery("UPDATE `players` SET `online` = 1 WHERE `id` = " .. getPlayerGUID(cid) .. ";")
   else
     recalculateHPandMana(cid)
     doTeleportThing(cid, {x = 12, y = 139, z = 5})
     doCreatureSetStorage(cid, 59433, -1)
     setTmpDeaths(cid, 0)
     setTmpAssists(cid, 0)
     setTmpFrags(cid, 0)
     setLastAssists(cid, 0)
     setLastFrags(cid, 0)
     doCreatureSetSkullType(cid, SKULL_NONE)
     db.executeQuery("UPDATE `players` SET `online` = 0, `tmp_kills` = 0, `tmp_deaths` = 0, `tmp_assists` = 0 WHERE `id` = " .. getPlayerGUID(cid) .. ";")
   end
end
 
Replace correct part with this code (had the same problem as you):
LUA:
    elseif(#playersOnline+#botsOnline < keepOnline) then
       for i = 1, maxChange do
           if(#playersOnline + #botsOnline+i <= keepOnline) then
               for i, bot in pairs(botsOffline) do
                   setBotActive(bot, true)
                   table.remove(botsOffline, i)
                   break
               end
           end
       end
   end

#btw
By this script you can be banned on otserverlists, so remember to add few changes to prevent yourself ;)
Few years ago I had always 400 ppl online while starting the new server, no one could detect that Im cheating :D
 
Last edited:
Solution
Back
Top