Hello!
The story behind (please don't sue me, TechAltar):
I have a VAC ban for almost a year now and i still enjoy playing CS:GO here and then playing against bots. But recently it became pretty boring to have the same game over and over again so i first started spicing it up with different botprofiles i found on the Internet. That brought some fresh wind into my sessions but it also made me thirsty for more so i first i set up my own dedicated server with sourcemod on my RaspberryPi 4 but since it needed a x86->ARM emulator i had such a shitty performance and i really wasn't ready to rent a server for offline play so i looked into getting SM to work on my local listen server which works great <3 I started looking at some other plugin's code to get familiar with the APIs provided but since pawn is mostly C/C++ with which i don't have a lot of (good) experience i was only able to get as far as the code i attached on the end of this post.
The request:
I want a plugin that randomly sets various things for each new bot on creation. In particular:
All these should be contained within one plugin with admin vars for each to toggle.
The plugin should be released here and on github open-source so everyone has the chance of improving it or fixing it once a method has been patched so you as original author won't have to provide support later on.
What i've got so far (i know it's not much and highly depends on other plugins working, that's why i created this request):
PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdkhooks>
#include <sdktools>
#include <clientprefs>
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1.0"
ConVar g_sm_betterbots_version;
ConVar g_sm_betterbots_neverdefergoals;
public Plugin myinfo = {
name = "Better Bots",
author = "Bluscream",
description = "Requires Franc1sco-Franug/Competitive-Rank-and-Coins",
version = PLUGIN_VERSION,
url = ""
};
public void OnPluginStart() {
g_sm_betterbots_version = CreateConVar("sm_betterbots_version", PLUGIN_VERSION, "Better Bots SM plugin version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
g_sm_betterbots_version.SetString(PLUGIN_VERSION);
g_sm_betterbots_neverdefergoals = CreateConVar("sm_betterbots_neverdefergoals", "1", "Always execute \"bot_defer_to_human_goals 0;bot_defer_to_human_items 0\" on map start", _, true, 0.0, true, 1.0);
}
public void OnMapStart() {
if (GetConVarBool(g_sm_betterbots_neverdefergoals)){
ServerCommand("bot_defer_to_human_goals 0");
ServerCommand("bot_defer_to_human_items 0");
}
}
public void OnClientPutInServer(int client) {
}
public void OnClientPostAdminCheck(int client) {
if (!IsFakeClient(client)) return;
OnBotCreated(client);
}
public void OnBotCreated(int botId) {
if (!IsFakeClient(botId)) return;
int userId = GetClientUserId(botId);
int elo = GetRandomInt(0, 18);
int pro = GetRandomInt(0, 40);
int emb = GetRandomInt(0, 1) ? GetRandomInt(874, 6011) : 0;
PrintToServer("Giving ranks to bot \"%N\" (#%i). Elo: %i Profile: %i Emblem: %i", botId, userId, elo, pro, emb);
ServerCommand("sm_elorank #%i %i", userId, elo);
ServerCommand("sm_prorank #%i %i", userId, pro);
ServerCommand("sm_emblem #%i %i", userId, emb);
}
// OnClientConnected doesnt get called for bots afaik, you'd be better off using OnClientPutInServer or OnClientPostAdminCheck