Quote:
Originally Posted by Kolapsicle
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 i = 1; i <= MaxClients; i++)
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