Raised This Month: $ Target: $400
 0% 

Solved need help in optimization [weird coding]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-20-2022 , 14:02   Re: need help in optimization [weird coding]
Reply With Quote #1

Code:
case NAME_ONLY: {     new szName[MAX_NAME_LENGTH]     get_user_name(iSender, szName, charsmax(szName))     formatex(szTemp, charsmax(szTemp), "%s ", szName) }

=>

Code:
case NAME_ONLY: {     get_user_name(iSender, szTemp, charsmax(szTemp)) }

If you're using AMXX 1.9 or 1.10, you don't even need to use get_user_name():

Code:
formatex(szTemp, charsmax(szTemp), "%n (ID: %i) ", iSender, iSender)
__________________

Last edited by OciXCrom; 01-20-2022 at 14:02.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 01-20-2022 , 16:22   Re: need help in optimization [weird coding]
Reply With Quote #2

Quote:
Originally Posted by OciXCrom View Post
Code:
case NAME_ONLY: {     new szName[MAX_NAME_LENGTH]     get_user_name(iSender, szName, charsmax(szName))     formatex(szTemp, charsmax(szTemp), "%s ", szName) }

=>

Code:
case NAME_ONLY: {     get_user_name(iSender, szTemp, charsmax(szTemp)) }
In this case i need that space after name

Quote:
Originally Posted by OciXCrom View Post
If you're using AMXX 1.9 or 1.10, you don't even need to use get_user_name():

Code:
formatex(szTemp, charsmax(szTemp), "%n (ID: %i) ", iSender, iSender)
At what moment we got this feature?
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951
kww is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-21-2022 , 22:14   Re: need help in optimization [weird coding]
Reply With Quote #3

Quote:
Originally Posted by kww View Post
In this case i need that space after name
No. The format string tells the code how to format the string so it will only replace the special formatting character sets (i.e. the "%s" or "%n").
(I guess I misinterpreted your post)



Quote:
Originally Posted by kww View Post
At what moment we got this feature?
He literally just told you in that same post.
__________________

Last edited by fysiks; 01-22-2022 at 14:45.
fysiks is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 01-22-2022 , 05:31   Re: need help in optimization [weird coding]
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
No. The format string tells the code how to format the string so it will only replace the special formatting character sets (i.e. the "%s" or "%n").
What do you mean? I know that. I wrote I need NOT only the name but a space after it too
Code:
formatex(szTemp, charsmax(szTemp), "%s ", szName)
                                      ^
If you know how to do it another way then please tell me

Sure, I can do this to add a space but what's the difference then:
Code:
case NAME_ONLY:
{
	get_user_name(iSender, szTemp, charsmax(szTemp))
	add(szTemp, charsmax(szTemp), " ")
}
__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 01-22-2022 at 05:35.
kww is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-22-2022 , 14:43   Re: need help in optimization [weird coding]
Reply With Quote #5

Quote:
Originally Posted by kww View Post
What do you mean? I know that. I wrote I need NOT only the name but a space after it too
Code:
formatex(szTemp, charsmax(szTemp), "%s ", szName)
                                      ^
If you know how to do it another way then please tell me

Sure, I can do this to add a space but what's the difference then:
Code:
case NAME_ONLY:
{
	get_user_name(iSender, szTemp, charsmax(szTemp))
	add(szTemp, charsmax(szTemp), " ")
}
I thought you were asking a question if you needed to add a space in the format string to make it work. Your sentence didn't end with any punctuation so I misinterpreted your post.
__________________

Last edited by fysiks; 01-22-2022 at 14:46.
fysiks 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 11:35.


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