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:
new g_bIsControllingBot = -1;
public OnPluginStart() { g_bIsControllingBot = FindSendPropInfo("CCSPlayer", "m_bIsControllingBot");
if (g_bIsControllingBot == -1) { // This is optional, maybe you don't want to set the plugin as failed, maybe just log the issue. SetFailState("Unable to locate m_bIsControllingBot"); } }
/** * Check if a player is controlling a bot * @param client Player's client index * @return True if player is controlling a bot, false otherwise */ bool:IsPlayerControllingBot(client) { if (GetEntData(client, g_bIsControllingBot , 1) == 1) { return true; }
return false; }
PHP Code:
/** * Check if a player is controlling a bot * @param client Player's client index * @return True if player is controlling a bot, false otherwise */ bool:IsPlayerControllingBot(client) { static bool:hasChecked = false; static bool:isAvailable = false; if (!hasChecked) { isAvailable = FindSendPropOffs("CBasePlayer", "m_bIsControllingBot") != -1; hasChecked = true; }