Raised This Month: $ Target: $400
 0% 

Is Player Controlling a Bot?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-24-2013 , 17:22   Re: Is Player Controlling a Bot?
Reply With Quote #9

Quote:
Originally Posted by 11530 View Post
I too tried using a static for it yesterday, as I like keeping scope limited, but the compiler throws up an error if you use it, stating "error 008: must be a constant expression; assumed zero". That's why I had to force it up to a generic global.

Using const is just good design practice. Stops people from making inadvertent mistakes.
Aha, I thought spcomp might have ignored that little bit of sanity. Oh well, hand rolling what a C++ compiler would generate is the way.

PHP Code:
bool:IsPlayerControllingBot(client
{
    static 
bool:hasChecked false;
    static 
bool:isAvailable false;
    if (!
hasChecked) {
        
isAvailable FindSendPropOffs("CBasePlayer""m_bIsControllingBot") != -1;
        
hasChecked true;
    }

    return 
isAvailable && GetEntProp(clientProp_Send"m_bIsControllingBot") == 1;

The const there was doing absolutely nothing.
__________________
asherkin is offline
 



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 18:35.


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