View Single Post
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 12-17-2020 , 06:11   Re: Left 4 Dead 2 - CreateSurvivorBot
Reply With Quote #9

Quote:
Originally Posted by Dragokas View Post
OMG, so difficult. My mind refuses to understand what is happening there.
Code:
int fakebot = FindBotToTakeOver(); //search fake bot again
Can you, please, show what is that?
PHP Code:
int FindBotToTakeOver()
{
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i))
        {
            if (
IsFakeClient(i) && GetClientTeam(i)==TEAM_SURVIVORS && !HasIdlePlayer(i) && IsPlayerAlive(i))
                return 
i;
        }
    }
    return 
0;
}

bool HasIdlePlayer(int bot)
{
    if(
HasEntProp(botProp_Send"m_humanSpectatorUserID"))
    {
        
int client GetClientOfUserId(GetEntProp(botProp_Send"m_humanSpectatorUserID"));        
        if(
client && client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client) && IsClientObserver(client))
        {
            return 
true;
        }
    }
    
    return 
false;

__________________

Last edited by HarryPotter; 12-17-2020 at 06:12.
HarryPotter is offline