Raised This Month: $32 Target: $400

Plugin Code & Compile Help

Post New Thread Reply   
Thread Tools Display Modes
Author Message
Junior Member
Join Date: Feb 2022
Old 02-08-2024 , 18:04   Plugin Code & Compile Help
Reply With Quote #1

Hi All,

Looking for help with my plugin below, main goal is to add/remove bots based on wins and losses for the human team. I keep getting compile errors stating "plugin.sp(21) : fatal error 190: too many error messages on one line" so I am unsure of what is causing the issue. Looking for help from the community to explain and assist if they see anything?

I`m super new to scripting and pulled a bunch of this stuff from other scripts and am slowly researching what everything does so any additional explanations to the answer would be super helpful to me and my learning journey!

#include <sourcemod>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

// Configuration variables
ConVar g_iWinsToAddBot;
ConVar g_iWinsToRemoveBot;

// Plugin struct definition
public Plugin my_plugin =
    name = "Bot Manager",
    author = "Your Name",
    description = "Manages bots in Counter-Strike: Source based on player round outcomes.",
    version = "1.0"

// Event handler for player death
public Action Event_PlayerDeath(Handle:event, const char:eventName[], bool:dontBroadcast)
    int attacker = GetEventInt(event, "attacker");
    int victim = GetEventInt(event, "victim");
    if (IsClientInGame(attacker) && IsClientInGame(victim))
        bool isBotAttacker = IsFakeClient(attacker);
        bool isBotVictim = IsFakeClient(victim);
        if (!isBotAttacker)
            // Attacker is a human player
            int winningTeam = GetClientTeam(attacker);
            int losingTeam = GetClientTeam(victim);
            if (winningTeam != losingTeam)
                // The attacker's team won the round
                if (GetTeamRoundWins(losingTeam) >= g_iWinsToAddBot.GetInt())
                    ConVar_SetInt("bot_quota", GetMaxClients() - GetNumPlayers() + 1); // Increase bot quota by 1
                // The attacker's team lost the round
                if (!isBotVictim && GetTeamRoundWins(winningTeam) >= g_iWinsToRemoveBot.GetInt())
                    ConVar_SetInt("bot_quota", GetMaxClients() - GetNumPlayers() - 1); // Decrease bot quota by 1
    return Plugin_Continue;

// Plugin initialization function
public void OnPluginStart()
    g_iWinsToAddBot = FindConVar("sm_botmanager_wins_to_add_bot");
    g_iWinsToRemoveBot = FindConVar("sm_botmanager_wins_to_remove_bot");
    // Hook the player_death event
    HookEvent("player_death", Event_PlayerDeath, EventHookMode_Post);

// Plugin shutdown function
public void OnPluginEnd()
    // Unhook the player_death event
    UnhookEvent("player_death", Event_PlayerDeath);
Open to other suggestions as well! Thanks a bunch!
ChillyWilly is offline
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-08-2024 , 23:43   Re: Plugin Code & Compile Help
Reply With Quote #2

#pragma newdecls required

You have colons : added in event callback
// Event handler for player death
public Action Event_PlayerDeath(Handle:event, const char:eventName[], bool:dontBroadcast)

Please, do not generate code with AI, example ChatGPT
It just not work.
Do not Private Message @me

Last edited by Bacardi; 02-08-2024 at 23:46.
Bacardi is offline
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 02-10-2024 , 13:52   Re: Plugin Code & Compile Help
Reply With Quote #3

Translated into the SourcePawn programming language from the ChatGPT dialect:
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <cstrike>


Plugin myinfo =
name "Bot Manager",
author "Your Name",
description "Manages bots in Counter-Strike: Source based on player round outcomes.",
version "1.0"

void OnPluginStart()
hQuota FindConVar("bot_quota"))) SetFailState("Can't find convar 'bot_quota'");

ConVar cvar;
cvar CreateConVar("sm_botmanager_add""10""wins_to_add_bot"_true);
iAdd cvar.IntValue;

cvar CreateConVar("sm_botmanager_remove""8""wins_to_remove_bot"_true);
iRemove cvar.IntValue;


void CVarChange_Add(ConVar cvar, const char[] oldValue, const char[] newValue)
iAdd cvar.IntValue;

void CVarChange_Remove(ConVar cvar, const char[] oldValue, const char[] newValue)
iRemove cvar.IntValue;

void Event_Death(Event event, const char[] eventNamebool dontBroadcast)
int victim GetEventInt(event"victim");
victim || !IsClientInGame(victim))

int attacker GetEventInt(event"attacker");
attacker || attacker == victim || !IsClientInGame(attacker) || IsFakeClient(attacker))

int losingTeam GetClientTeam(victim), num hQuota.IntValue;
GetClientTeam(attacker) != losingTeam)
        if (
CS_GetTeamScore(losingTeam) >= iAdd)
    else if(!
IsFakeClient(victim) && CS_GetTeamScore(losingTeam) >= iRemove)

hQuota.IntValue num;

But the algorithm is still flawed, LOL.
Grey83 is offline

Thread Tools
Display Modes

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 01:49.

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