Raised This Month: $ Target: $400
 0% 

Plugin Code & Compile Help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ChillyWilly
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!

Code:
#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
                }
            }
            else
            {
                // 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
 



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 04:07.


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