View Single Post
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 01-26-2014 , 19:06   Re: [ANY] Simple Only Headshot
Reply With Quote #3

Nice plugin!
I have some recommendations about the code.
1) At first dont use GetGameFolderName to detect game, use GetEngineVersion() instead (or this stock).
2) Then OnPluginStart at line 70 add IsClientInGame(i), otherwise you may have some errors if no players on a server and you decided to reload plgin.
3) TraceAttack differs from OnTakeDamage not only by different parameters, but also it can make bullets go through player - this way you should return Plugin_Handled instead of doing damage = 0.0 and returning Plugin_Changed.
4) You can ignore weapon_ prefix due to performance purposes using this way
Code:
if(StrEqual(weapon[7], "knife"))
Or for TF2 use this
Code:
if(StrEqual(weapon[10], "bat")
Or you can try to check if (inflictor == GetPlayerWeaponSlot(attacker, 2)), which is melee weapon and not compare melee classnames at all.
5) Use global strings for weapons instead of declaring it all the time from ConVar within TraceAttack hook.
6) For DoD:S you can add one more melee weapon: weapon_punch.
7) At line 214 use damage = float(GetClientHealth(victim)) instead of current one.
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline