Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2021
1,198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <amxmisc>
  4.  
  5. #define PLUGIN "Spec-Bots"
  6. #define VERSION "1.0"
  7. #define AUTHOR "Author"
  8.  
  9. new g_pEnable;
  10. new g_pMaxPlayers;
  11. new g_pBotName, g_pBotName2, g_pBotName3
  12. new bool:bot_on, bot_on2, bot_on3;
  13.  
  14. public plugin_init() {
  15. // Plugin registration
  16. register_plugin(PLUGIN, VERSION, AUTHOR);
  17.  
  18. // Plugin OFF-ON on values 0-1
  19. g_pEnable = register_cvar("bs_enable", "1");
  20.  
  21. // Bot nicknames
  22. g_pBotName = register_cvar("bs_botname", "RESPAWN.OLDGODS.RO (dns)");
  23. g_pBotName2 = register_cvar("bs_botname2", "89.40.233.100:27015 (IP)");
  24. g_pBotName3 = register_cvar("bs_botname3", "forum: oldgods.ro/forum");
  25.  
  26. // Min-Max values 5 & 29 - Disconnect happens at value + 1
  27. g_pMaxPlayers = create_cvar("bs_maxplayers", "29.0", FCVAR_NONE, _, true, 5.0, true, 29.0);
  28.  
  29. // Sets bot connection confirmations off on each map change
  30. bot_on = false;
  31. bot_on2 = false;
  32. bot_on3 = false;
  33.  
  34. // Checks and connects bots every 60s if requirements are met
  35. if(get_pcvar_num(g_pEnable)) {
  36. set_task(60.0, "AddBots", 0, _, _, "b");
  37. }
  38.  
  39. }
  40.  
  41. // On every client connection removes bots if threshold + 1 has been reached or surpassed
  42. public client_connect(id) {
  43. if(get_pcvar_num(g_pEnable)) {
  44. if(get_playersnum(1) >= get_pcvar_num(g_pMaxPlayers) + 1) {
  45. RemoveBots();
  46. }
  47. }
  48. }
  49.  
  50. // Removal of bots
  51. public RemoveBots() {
  52. new szBotName[35];
  53. get_pcvar_string(g_pBotName, szBotName, charsmax(szBotName));
  54. server_cmd("kick ^"%s^"", szBotName);
  55. bot_on = false;
  56. new szBotName2[35];
  57. get_pcvar_string(g_pBotName2, szBotName2, charsmax(szBotName2));
  58. server_cmd("kick ^"%s^"", szBotName2);
  59. bot_on2 = false;
  60. new szBotName3[35];
  61. get_pcvar_string(g_pBotName3, szBotName3, charsmax(szBotName3));
  62. server_cmd("kick ^"%s^"", szBotName3);
  63. bot_on3 = false;
  64. }
  65.  
  66. // Adds up to 3 bots if they're not connected and there's less players than the threshold
  67. public AddBots() {
  68. if(get_playersnum(1) < get_pcvar_num(g_pMaxPlayers) && !bot_on) {
  69. AddBot();
  70. if(get_playersnum(1) < get_pcvar_num(g_pMaxPlayers) && !bot_on2) {
  71. AddBot2();
  72. if(get_playersnum(1) < get_pcvar_num(g_pMaxPlayers) && !bot_on3) {
  73. AddBot3();
  74. }
  75. }
  76. }
  77. }
  78.  
  79. /* ------------- BOT CREATION ------------- */
  80. public AddBot() {
  81. new szBotName[35];
  82. get_pcvar_string(g_pBotName, szBotName, charsmax(szBotName));
  83.  
  84. new id = engfunc(EngFunc_CreateFakeClient, szBotName);
  85. if(!id) {
  86. return;
  87. }
  88. engfunc(EngFunc_FreeEntPrivateData, id);
  89. set_pev(id, pev_flags, pev(id, pev_flags) | FL_FAKECLIENT);
  90.  
  91. new szMsg[128];
  92. dllfunc(DLLFunc_ClientConnect, id, szBotName, "127.0.0.1", szMsg);
  93. dllfunc(DLLFunc_ClientPutInServer, id);
  94.  
  95. bot_on = true;
  96. }
  97.  
  98. public AddBot2() {
  99. new szBotName2[35];
  100. get_pcvar_string(g_pBotName2, szBotName2, charsmax(szBotName2));
  101.  
  102. new id = engfunc(EngFunc_CreateFakeClient, szBotName2);
  103. if(!id) {
  104. return;
  105. }
  106. engfunc(EngFunc_FreeEntPrivateData, id);
  107. set_pev(id, pev_flags, pev(id, pev_flags) | FL_FAKECLIENT);
  108.  
  109. new szMsg[128];
  110. dllfunc(DLLFunc_ClientConnect, id, szBotName2, "127.0.0.1", szMsg);
  111. dllfunc(DLLFunc_ClientPutInServer, id);
  112.  
  113. bot_on2 = true;
  114. }
  115.  
  116. public AddBot3() {
  117. new szBotName3[35];
  118. get_pcvar_string(g_pBotName3, szBotName3, charsmax(szBotName3));
  119.  
  120. new id = engfunc(EngFunc_CreateFakeClient, szBotName3);
  121. if(!id) {
  122. return;
  123. }
  124. engfunc(EngFunc_FreeEntPrivateData, id);
  125. set_pev(id, pev_flags, pev(id, pev_flags) | FL_FAKECLIENT);
  126.  
  127. new szMsg[128];
  128. dllfunc(DLLFunc_ClientConnect, id, szBotName3, "127.0.0.1", szMsg);
  129. dllfunc(DLLFunc_ClientPutInServer, id);
  130.  
  131. bot_on3 = true;
  132. }
  133. /* ------------- END BOT CREATION ------------- */
  134.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement