Raised This Month: $51 Target: $400
 12% 

Kick bots plugin issue , source,error code inside.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wazer
Senior Member
Join Date: Oct 2011
Old 05-25-2017 , 07:33   Kick bots plugin issue , source,error code inside.
Reply With Quote #1

Having an issue, no clue how to fix it.

Code:
L 05/25/2017 - 13:28:43: [SM] Exception reported: Invalid convar handle 0 (error 4)
L 05/25/2017 - 13:28:43: [SM] Blaming: kick_bots.smx
L 05/25/2017 - 13:28:43: [SM] Call stack trace:
L 05/25/2017 - 13:28:43: [SM]   [0] GetConVarInt
L 05/25/2017 - 13:28:43: [SM]   [1] Line 24, kick_bots.sp::OnClientPutInServer

I provided compiled and script.

Script by Sylwester posted in this thread
Attached Files
File Type: smx kick_bots.smx (4.1 KB, 101 views)
File Type: sp Get Plugin or Get Source (kick_bots.sp - 276 views - 1.0 KB)
wazer is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 05-26-2017 , 00:19   Re: Kick bots plugin issue , source,error code inside.
Reply With Quote #2

Move the bot_quota convar lookup into OnPluginStart like this
PHP Code:
public OnPluginStart(){
    
g_Cvar_bot_quota FindConVar("bot_quota");

__________________
Peace-Maker is offline
wazer
Senior Member
Join Date: Oct 2011
Old 05-26-2017 , 19:46   Re: Kick bots plugin issue , source,error code inside.
Reply With Quote #3

Quote:
Originally Posted by Peace-Maker View Post
Move the bot_quota convar lookup into OnPluginStart like this
PHP Code:
public OnPluginStart(){
    
g_Cvar_bot_quota FindConVar("bot_quota");


Oh I just noticed its you the creator of the scrds auto complete addon, I made an issue to on github the other night ..



So Like this?


PHP Code:
#include <sourcemod>

public Plugin:myinfo = {
    
name "Bot Crash Prevention",
    
author "Sylwester, Peace-Maker",
    
description "prevents server from adding too many bots when players switch teams",
    
version "2.0",
    
url "https://forums.alliedmods.net/showthread.php?t=297839"
}


new 
Handle:g_Cvar_bot_quota INVALID_HANDLE;
new 
g_bot_quota
new g_max_players

public OnPluginStart(){
    
g_Cvar_bot_quota FindConVar("bot_quota");


public 
OnConfigsExecuted(){
    
g_bot_quota GetConVarInt(g_Cvar_bot_quota);
    
g_max_players GetMaxClients();
}

public 
OnClientPutInServer(client){
    if(!
IsFakeClient(client))
        return;
        
    if(
g_bot_quota GetConVarInt(g_Cvar_bot_quota))
        
SetConVarInt(g_Cvar_bot_quotag_bot_quota);
    
    new 
icount;
    for(
1i<=g_max_playersi++)
        if(
IsClientInGame(i) && GetClientTeam(i)>1)
            
count++;
            
    if(
count<=g_bot_quota)
        return;
    
    new 
String:name[32]
    if(!
GetClientName(clientname31))
        return;
    
ServerCommand("bot_kick %s"name);


Last edited by wazer; 05-26-2017 at 19:58.
wazer is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 05-27-2017 , 00:14   Re: Kick bots plugin issue , source,error code inside.
Reply With Quote #4

Yes. You could remove the g_max_players variable too and replace it with the built in MaxClients variable.
__________________
Peace-Maker is offline
wazer
Senior Member
Join Date: Oct 2011
Old 05-27-2017 , 18:48   Re: Kick bots plugin issue , source,error code inside.
Reply With Quote #5

Quote:
Originally Posted by Peace-Maker View Post
Yes. You could remove the g_max_players variable too and replace it with the built in MaxClients variable.
I dont know how to ;D
wazer is offline
fiction
Member
Join Date: May 2017
Old 05-28-2017 , 10:37   Re: Kick bots plugin issue , source,error code inside.
Reply With Quote #6

Quote:
Originally Posted by wazer View Post
I dont know how to ;D
Spoiler
fiction is offline
wazer
Senior Member
Join Date: Oct 2011
Old 05-29-2017 , 12:10   Re: Kick bots plugin issue , source,error code inside.
Reply With Quote #7

Quote:
Originally Posted by fiction View Post
Spoiler


Thanks will test :=)
wazer is offline
Reply



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 12:15.


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