Raised This Month: $32 Target: $400
 8% 

FormatEx vs ReplaceString vs strcopy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 02-15-2014 , 11:55   FormatEx vs ReplaceString vs strcopy
Reply With Quote #1

This is a performance question. I need to replace weapon classanmes in CS:GO to detect what weapon was used (you know those latest issues with retrieving m4a1/usp with silencer and cz75a too).
What way is the best?
Code:
decl String:classname[64]; GetEdictClassname(weapon, classname, sizeof(classname)); switch (GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex")) {     case 60:     {         FormatEx(classname, sizeof(classname), "weapon_m4a1_silencer");         ReplaceString(classname, sizeof(classname), classname, "weapon_m4a1_silencer");         strcopy(classname, sizeof(classname), "weapon_m4a1_silencer");     }     case 61:     {         FormatEx(classname, sizeof(classname), "weapon_usp_silencer");         ReplaceString(classname, sizeof(classname), classname, "weapon_usp_silencer");         strcopy(classname, sizeof(classname), "weapon_usp_silencer");     }     case 63:     {         FormatEx(classname, sizeof(classname), "weapon_cz75a");         ReplaceString(classname, sizeof(classname), classname, "weapon_cz75a");         strcopy(classname, sizeof(classname), "weapon_cz75a");     } }
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 02-15-2014 , 12:05   Re: FormatEx vs ReplaceString vs strcopy
Reply With Quote #2

I guess strcopy() is the best, because FormatEx first try to format string according to the SourceMod format rules and ReplaceString try to find substrings and then build new string..
KissLick is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 02-15-2014 , 12:27   Re: FormatEx vs ReplaceString vs strcopy
Reply With Quote #3

strcopy
__________________
11530 is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 02-15-2014 , 13:11   Re: FormatEx vs ReplaceString vs strcopy
Reply With Quote #4

Thanks KissLick & 11530
__________________


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



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode