Nice!
There's also a list of cvars that can be changed to make bots respond faster in various situations. I don't have the list here but can probably be found easily on google.
Some notes on code:
- "PrefetchSound" - don't see the point of this when you have "PrecacheSound".
- "PrecacheSound" - should be moved to OnMapStart().
- "OnEntityCreated" - Don't use "StrContains" this is very inefficient especially in this function that's triggered so often. Use: if (g_hEnabled && strcmp(classname, "witch") == 0)
- You'll probably want to add the g_hEnabled check to make it more efficient when the plugins disabled.
- "OnEntityDestroyed" - I personally prefer to do "static char classname[32];" instead of creating the string every time to avoid creating a null string each time. This kind of optimization is noticeable on servers near the bottleneck of their CPU with lots of plugins, and best when those plugins are also optimized as such.
- "SetCommandFlags(command, flags^FCVAR_CHEAT);" is wrong, you're flipping the bit, some servers might have removed the cheat flag and you've just added it back. Do "SetCommandFlags(command, flags & ~FCVAR_CHEAT);"
- Instead of "SetCommandFlags(command, flags | FCVAR_CHEAT);" just do "SetCommandFlags(command, flags)" because some servers might have stripped the cheat flag which you've just added back when it didn't exist.
- "if (staggerPos[0] != 0.0 && staggerPos[1] != 0.0 && staggerPos[2] != 0.0) return true;" - seems wrong, maybe sometimes a player can stagger and one of the variables is exactly 0.0, however rare that maybe. I would put || instead of && for the checks.
- Things like "new String:sub_weapon[128];" is inefficient, again you could use "static" instead of "new" to stop creating them over and over in expensive functions like the one being used, and also 128 is overkill when the longest string is 12 characters or something, the longest weapon classname is 29, so put [32] instead.
- Same as "decl String:sWeaponName[256];" and probably other strings.
- You have lots of these types of checks:
PHP Code:
GetEntityClassname(weapon, classname, sizeof(classname));
if (StrContains(classname, "weapon_melee", false) > -1
Since you're pulling the weapon name from the players equipped weapon you can skip "weapon_" and match the last part, such as: strcmp(classname[7], "melee") == 0. Again, don't use StrContains for this, inefficient and poor coding.
PHP Code:
// You can replace all the:
new weapon = GetEntDataEnt2(client, g_ActiveWeapon);
// Stuff with
int weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- Your "Timer_ShoveChance" function never checks if the plugins enabled cvar is on. Suggest killing the timer if the plugins disabled, and enable when it's enabled so it doesn't run forever.
- You have many things like "Format(bufferChat, 512", instead of hard coding 512, do "sizeof(bufferChat)" instead. The compiler then changes that to 512, so if someone wants to modify the string size they only need to change 512 once.
- In "AskPluginLoad2" you may want to restrict the plugin to L4D2 like my plugins do for example.
- You can change the whole "PrimaryExtraAmmoCheck" function with what I use in the "Switch Upgrade Ammo Types" plugin - the "GetOrSetPlayerAmmo" function. It's not necessary to check all the weapon strings and hard code the offsets.
- Lastly, using old syntax
why are you writing that?
These are just some of the things I checked while skimming through, not everything.
__________________