View Single Post
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-31-2024 , 12:28   Re: [L4D|L4D2] Odin's Rock
Reply With Quote #2

PHP Code:
if (!IsFakeClient(tank) && !g_hOdinsHuman.BoolValue
Flip these checks around, more optimized.


PHP Code:
    if (IsTank(tank))
        
target GetClientAimTarget(tank); 
You already have the "IsTank" check above which will return if not. Again you have several "IsTank" checks below, these are not needed.


PHP Code:
    if (!IsTankRock(inflictor)) return Plugin_Continue;

    
damage g_hOdinsTrick.FloatValue;

    if (!
IsTank(attacker)) return Plugin_Continue
Put the two checks together, assigning a value that maybe never used is not optimized.


PHP Code:
for (int i 1MaxClientsi++) 
All loops like this should be: i <= MaxClients


PHP Code:
char classname[MAX_NAME_LENGTH]; 
You assign a random length, this is player name length not the targetname length. Then you're only checking a string that is 9 chars long, so you should set as "char classname[10]" and I would even set as "static char classname[10]" so it doesn't create the string each time, since you're filling it with data before reading ever reading it.


PHP Code:
SDKHook(targetSDKHook_OnTakeDamageOnTakeDamage); 
You will be hooking the same target multiple times on multiple throws. You never remove the damage hook. I suggest removing the hook in the post forward "L4D_TankRock_OnRelease_Post".
__________________

Last edited by Silvers; 01-31-2024 at 12:31.
Silvers is offline