To work at any stage of the game, with any bot spawn BotPopulate or createhero
I'm doing this right now, but I'm absolutely not sure about this method:
ListenToGameEvent('player_connect', Dynamic_Wrap(Players, 'OnBotConnected'), self)
function Players:OnBotConnected(event)
-- print(event.index, event.userid)
-- GameRules:SendCustomMessage(tostring(event.index).." "..tostring(event.userid), 0, 0)
table.insert(self.Dump, {
index = event.index,
userid = event.userid,
})
local PlayerID = event.userid-1
if IsLocalServer() then
PlayerID = event.userid
end
if (IsInToolsMode() or GameRules:IsCheatMode()) and PlayerID > -1 and event.bot == 1 and self.Players[PlayerID] == nil then
self:RegisterPlayer(PlayerID, true)
end
end