Is Player Controlling a Bot?
Thought I posted this before in here, but I think I've only posted it in the CSS Bank plugin thread... Anyways, for CS:GO (and maybe others), here's a good way to check if a client is controlling a bot (thanks asherkin):
bad way
PHP Code:
|
Re: Is Player Controlling a Bot?
Just use GetEntProp, what you're doing is dangerous if a non-client index is ever passed to that function by mistake, and gives you no benefit at all.
|
Re: Is Player Controlling a Bot?
Adjusted the code, thanks for the heads up asherkin :)
|
Re: Is Player Controlling a Bot?
Might still be prudent to check if the netprop exists in the first place, at the expense of using OnPluginStart too (unless you don't mind checking it's availability every use). Also handles FindSendPropInfo returning 0 too, though this code could be used for any boolean netprop, mind you. :bee:
PHP Code:
|
Re: Is Player Controlling a Bot?
Quote:
|
Re: Is Player Controlling a Bot?
Quote:
|
Re: Is Player Controlling a Bot?
Quote:
FindSendPropOffs is also more performant for this case. const-qualifying the param also means nothing. PHP Code:
|
Re: Is Player Controlling a Bot?
Quote:
Using const is just good design practice. Stops people from making inadvertent mistakes. |
Re: Is Player Controlling a Bot?
Quote:
PHP Code:
|
Re: Is Player Controlling a Bot?
Quote:
PHP Code:
PHP Code:
|
| All times are GMT -4. The time now is 18:35. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.