View Single Post
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 04-09-2022 , 06:02   Re: is_user_bot check problem
Reply With Quote #6

The worst way I can suggest is to use preThink.
Make something like random command execution.
Code below will check if player is a bot. If it is a bot then generate random number from 1 to 100 and if number is in range of USAGE_CHANCE then execute your function
PHP Code:
// IMHO USAGE_CHANCE should be pretty small
#define USAGE_CHANCE 1..5

new bool:g_bBot[MAX_PLAYERS+1]

// when client connects to server
public client_putinserver(id)
{
    
// cache bots to probably decrease CPU usage
    
g_bBot[id] = bool:is_user_bot(id)
}

public 
client_PreThink(id)
{
    if(
g_bBot[id])
    {
        switch(
random_num(1100))
        {
            case 
USAGE_CHANCE:
            {
                
// run heal function
                
give_health(id)
            }
        }
    }

__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 04-09-2022 at 06:09.
kww is offline