Raised This Month: $ Target: $400
 0% 

CZ Bots + AMXX 1.70 + auto bot script = crashing


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Blaza
Member
Join Date: May 2005
Old 03-16-2006 , 00:53   CZ Bots + AMXX 1.70 + auto bot script = crashing
Reply With Quote #1

Hello. I am attempting to write a script, fairly simple at the moment.

Basically, it sets a task for every 5 seconds in the plugin_init() function.

It seems pretty stable; bots coem and leave as humans enter/leave the CT/T teams. But it does seem to crash our server every dozen or so maps, but no crashing seems to happen if its stopped.

Code:
#include <amxmod>
#include <amxmisc>
#include <cstrike>

new STRING_VERSION[] = "1.00B6";
new BOT_MAX_CVAR[] = "bot_max";
new EXEC_SERVER_CFG = 1

public plugin_init() {
   register_plugin(
      "blz's CZBot Automation Plugin for AMXModX", STRING_VERSION, "blz");
   register_cvar(BOT_MAX_CVAR, "14", FCVAR_SERVER);

   register_concmd("amx_bot_max", "amx_bot_max", ADMIN_BAN, 
      "<value>: -1 = Disable, 0 = No bots, 1 and higher = Max # of bots");
      
   if (EXEC_SERVER_CFG == 1) register_event("30", "on_map_end", "a");

   set_task(5.0, "check_bots", 8001, _, _, "b"); 

   return PLUGIN_CONTINUE;
}
/*----------------------------------------------------------------------------*/

public count_playing_humans() {
   new HumanCount = 0;
   new PlayerList[32]; 
   new PlayerCount = 0;
   
   get_players(PlayerList, PlayerCount, "c"); 
   for (new i=0; i<PlayerCount; i++) {
     new CsTeams:PlayerTeam = cs_get_user_team(PlayerList[i]);
     if (PlayerTeam == CS_TEAM_T || PlayerTeam == CS_TEAM_CT) HumanCount++;
   }
   
   return HumanCount;
}

public remove_bots() { server_cmd("bot_quota 0"); }

public check_bots() {
   new bot_max = get_cvar_num(BOT_MAX_CVAR);
   new old_bots = get_cvar_num("bot_quota");
   new new_bots = 0;
   
   if (bot_max == -1) return;
   if (bot_max == 0) {
      remove_bots();
      return;
   }

   new humans = count_playing_humans();
                                        
   if (humans > bot_max) new_bots = 0;
   else new_bots = bot_max - humans;
     
   if (old_bots != new_bots) {
      new temp[16];
      format(temp, 15, "bot_quota %d", new_bots);
      server_cmd(temp);
   }
}

public on_map_end() {
   new nextmap[31];
   get_cvar_string("amx_nextmap", nextmap, 30);
   server_cmd("exec server.cfg");
   server_cmd("exec %s.cfg", nextmap);
} 
// *** To fix unexplained amxx related issue that for some reason
// *** prevents the server.cfg/<mapname>.cfg from executing.
Is there something I'm missing? I am a long time programmer, but I've come to find that HL based scripting can be a bit tricky to debug and perfect.

Thanks.

-blz
Blaza is offline
Send a message via ICQ to Blaza Send a message via AIM to Blaza Send a message via MSN to Blaza Send a message via Yahoo to Blaza
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode