Raised This Month: $32 Target: $400
 8% 

Solved [CS:GO] How can I adapt this code for bots?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 12-18-2018 , 17:31   [CS:GO] How can I adapt this code for bots?
Reply With Quote #1

As the title suggests I'd like to know how do I adapt this code so that not only it auths real players but also bots.

PHP Code:
public void OnClientPostAdminCheck(int client)
{
    if(
IsValidClient(client))
    {
        
char steam32[20];
        
char temp[20];
        
GetClientAuthId(clientAuthId_Steam3steam32sizeof(steam32));
        
strcopy(tempsizeof(temp), steam32[5]);
        
int index;
        if((
index StrContains(temp"]")) > -1)
        {
            
temp[index] = '\0';
        }
        
g_iSteam32[client] = StringToInt(temp);
        
GetPlayerData(client);
        
QueryClientConVar(client"cl_language"ConVarCallBack);
    }


Last edited by manicogaming; 11-04-2020 at 14:45.
manicogaming is offline
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 12-18-2018 , 18:22   Re: [CS:GO] How can I adapt this code for bots?
Reply With Quote #2

edit your fuction IsValidClient
__________________
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 12-18-2018 , 18:31   Re: [CS:GO] How can I adapt this code for bots?
Reply With Quote #3

Quote:
Originally Posted by _GamerX View Post
edit your fuction IsValidClient
This is my IsValidClient function:

PHP Code:
stock bool IsValidClient(int client)
{
    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || IsClientSourceTV(client) || IsClientReplay(client))
    {
        return 
false;
    }
    return 
true;

What else do I need to change here?
manicogaming is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 12-18-2018 , 22:53   Re: [CS:GO] How can I adapt this code for bots?
Reply With Quote #4

Quote:
Originally Posted by manicogmaing View Post
This is my IsValidClient function:

PHP Code:
stock bool IsValidClient(int client)
{
    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || IsClientSourceTV(client) || IsClientReplay(client))
    {
        return 
false;
    }
    return 
true;

What else do I need to change here?
hi
try this:
PHP Code:
/*********************************
 *  IsValidClient
 *********************************/
stock bool IsValidClient(int client)
{
    if(
client <= 0)
        return 
false;
    if(
client MaxClients)
        return 
false;
    if(!
IsClientInGame(client))
        return 
false;
    if(
IsFakeClient(client))
        return 
false
    return 
true;

Dr.Mohammad is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 12-19-2018 , 10:26   Re: [CS:GO] How can I adapt this code for bots?
Reply With Quote #5

PHP Code:
public void OnClientPostAdminCheck(int client)
{
    if (
IsFakeClient(client))
    {
        return; 
// we let them on the server;
    
}

    
char steam32[20]; 
    
char temp[20]; 
    
GetClientAuthId(clientAuthId_Steam3steam32sizeof(steam32)); 
    
strcopy(tempsizeof(temp), steam32[5]); 
    
int index
    if((
index StrContains(temp"]")) > -1
    { 
        
temp[index] = '\0'
    } 
    
g_iSteam32[client] = StringToInt(temp); 
    
GetPlayerData(client); 
    
QueryClientConVar(client"cl_language"ConVarCallBack);

OnClientPostAdminCheck doesn't have clients < 1 or clients > maxclients. Also, the clients are always in-game in this function. So your IsValidClient function is useless and a waste of sources.

Also, use GetSteamAccountID to get the numbers from AuthId_Steam3.

PHP Code:
public void OnClientPostAdminCheck(int client)
{
    if (
IsFakeClient(client))
    {
        return; 
// we let them on the server;
    
}

    
g_iSteam32[client] = GetSteamAccountID(client); 
    
GetPlayerData(client); 
    
QueryClientConVar(client"cl_language"ConVarCallBack);

__________________

Last edited by Ilusion9; 12-19-2018 at 10:29.
Ilusion9 is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 12-19-2018 , 11:33   Re: [CS:GO] How can I adapt this code for bots?
Reply With Quote #6

What I really wanted is to get the accountid for bots so that way when they have a StatTrak weapon that is theirs it doesn't show USER UNKNOWN but I've realised that bots don't have a m_iAccountID, so I don't think there's anything more I can do.
manicogaming 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 19:56.


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