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

[REQ] Hibernate and Allow bots


Post New Thread Reply   
 
Thread Tools Display Modes
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 01-19-2017 , 20:06   Re: [REQ] Hibernate and Allow bots
Reply With Quote #21

In the code I gave you, OnClientAuthorized will turn bots on if a player joins, and OnClientDisconnect will turn bots off when everyone has left. I don't know when you want bots, change the cvars around if you want the inverse.

I added fake client checks which were missing.

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

int g_iPlayerCount 0;

public 
void OnClientAuthorized(int client, const char[] auth)
{
    if (
client && client <= MaxClients && !IsFakeClient(client)) {
        
g_iPlayerCount++;
        
SetConVarInt(FindConVar("sb_all_bot_game"), 1);
    }
}

public 
void OnClientDisconnect(int client)
{
    if (
client && client <= MaxClients && !IsFakeClient(client)) {
        if (--
g_iPlayerCount == 0)
            
SetConVarInt(FindConVar("sb_all_bot_game"), 0);
    }


Last edited by Kolapsicle; 01-19-2017 at 21:18.
Kolapsicle is offline
jgbc3d
Junior Member
Join Date: Apr 2011
Old 01-19-2017 , 23:43   Re: [REQ] Hibernate and Allow bots
Reply With Quote #22

Quote:
Originally Posted by Kolapsicle View Post
In the code I gave you, OnClientAuthorized will turn bots on if a player joins, and OnClientDisconnect will turn bots off when everyone has left. I don't know when you want bots, change the cvars around if you want the inverse.

I added fake client checks which were missing.

[PHP]#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

int g_iPlayerCount = 0;

public void OnClientAuthorized(int client, const char[] auth)
{
if (client > 0 && client <= MaxClients && !IsFakeClient(client)) {
g_iPlayerCount++;
SetConVarInt(FindConVar("sb_all_bot_game"), 1);
}
}

public void OnClientDisconnect(int client)
{
if (client > 0 && client <= MaxClients && !IsFakeClient(client)) {
if (--g_iPlayerCount == 0)
SetConVarInt(FindConVar("sb_all_bot_game"), 0);
}
}
Thanks man I will check this one and see how it works, anyway by looking for others plugins codes I made something that is working for me
this one
PHP Code:
#include <sourcemod>

public Plugin myinfo =
{
    
name "sb all bot game auto ON/OFF",
    
author "test",
    
description "test",
    
version "2.1",
    
url "test"
};

public 
OnPluginStart()

{
    
HookEvent("player_disconnect"Event_PlayerDisconnect);
}

public 
OnClientPutInServer(client)

{
    
SetConVarInt(FindConVar("sb_all_bot_game"), 1);
}

public 
Action:Event_PlayerDisconnect(Handle:hEvent, const String:strName[], bool:bDontBroadcast)

{
    new 
ccount=0;
    
    for (new 
1<= MaxClientsi++)
        if (
IsClientInGame(i) && !IsFakeClient(i))
        {
            
ccount++;
        }
         
    if (
ccount == 0)
    {    
        
SetConVarInt(FindConVar("sb_all_bot_game"), 0);
    }

for now I only wanted something that turns "sb_all_bot_game 1" when the first player joins and changes it back to "sb_all_bot_game 0" when the last player leaves the server. maybe your code works better than mine

Last edited by jgbc3d; 01-19-2017 at 23:48.
jgbc3d is offline
sam063rus
Junior Member
Join Date: Aug 2014
Old 01-20-2017 , 01:11   Re: [REQ] Hibernate and Allow bots
Reply With Quote #23

and now,
you should add checking for director_no_death_check.
so, if in the survivorteam no more alive humans (but dead only) and survivorbots are incapped and not dead - then switch off deathcheck
or
if survivorteam are filled by survivorbots and no any humans and all bots are incapped or dead - then switch on deatheck.
And...
after all this steps - add takeover plugin and incapped crawling plugin for your new versus core.

<just my ideas for future and no more>

Last edited by sam063rus; 01-20-2017 at 01:13.
sam063rus is offline
jgbc3d
Junior Member
Join Date: Apr 2011
Old 01-20-2017 , 11:42   Re: [REQ] Hibernate and Allow bots
Reply With Quote #24

Quote:
Originally Posted by sam063rus View Post
and now,
you should add checking for director_no_death_check.
so, if in the survivorteam no more alive humans (but dead only) and survivorbots are incapped and not dead - then switch off deathcheck
or
if survivorteam are filled by survivorbots and no any humans and all bots are incapped or dead - then switch on deatheck.
And...
after all this steps - add takeover plugin and incapped crawling plugin for your new versus core.

<just my ideas for future and no more>
Bro you know what you saying I think is already working that way, at least the first case am not sure about the second, another reason I wanted this plugin is when there is only 1 human player keep the game up til someone else joins. Also I want to keep the game as "vanilla" as possible but I will consider your idea
jgbc3d is offline
jgbc3d
Junior Member
Join Date: Apr 2011
Old 01-21-2017 , 14:57   Re: [REQ] Hibernate and Allow bots
Reply With Quote #25

Quote:
Originally Posted by Kolapsicle View Post
In the code I gave you, OnClientAuthorized will turn bots on if a player joins, and OnClientDisconnect will turn bots off when everyone has left. I don't know when you want bots, change the cvars around if you want the inverse.

I added fake client checks which were missing.

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

int g_iPlayerCount 0;

public 
void OnClientAuthorized(int client, const char[] auth)
{
    if (
client && client <= MaxClients && !IsFakeClient(client)) {
        
g_iPlayerCount++;
        
SetConVarInt(FindConVar("sb_all_bot_game"), 1);
    }
}

public 
void OnClientDisconnect(int client)
{
    if (
client && client <= MaxClients && !IsFakeClient(client)) {
        if (--
g_iPlayerCount == 0)
            
SetConVarInt(FindConVar("sb_all_bot_game"), 0);
    }

this code is working so far, and in a better way
jgbc3d 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 22:19.


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