Raised This Month: $ Target: $400
 0% 

Concatenating strings, how to?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
carrasco
New Member
Join Date: Aug 2008
Location: Foz do Iguaçu - Brasil
Old 08-24-2008 , 18:26   Concatenating strings, how to?
Reply With Quote #1

Hi there, sorry my english, im Brazilian,

I want to concatenate 3 strings into 1 variable, i find a way creating a new variable1 and putting add(variable1,lenght,variable2) and again for variable3 but this generate 3 lines of code in my script, have another way to concatenate strings

If any one can help me... thanks
carrasco is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-24-2008 , 18:38   Re: Concatenating strings, how to?
Reply With Quote #2

Use formatex() -> http://www.amxmodx.org/funcwiki.php?...atex&go=search

Code:
new szString[64];
formatex(szString, sizeof szString - 1, "%s %s %s", var1, var2, var3);
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-24-2008 , 18:53   Re: Concatenating strings, how to?
Reply With Quote #3

Also you can use add,which does not have the extra overhead of format:
PHP Code:
new string1[16]
new 
string2[32]

add(string2,charsmax(string2),string1
danielkza is offline
carrasco
New Member
Join Date: Aug 2008
Location: Foz do Iguaçu - Brasil
Old 08-24-2008 , 19:10   Re: Concatenating strings, how to?
Reply With Quote #4

Thank you very much Alka, this works fine to me and saved much code lines ;D

danielkza, this method works with 3 variables too?
carrasco is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-24-2008 , 19:11   Re: Concatenating strings, how to?
Reply With Quote #5

Or why not strcat() .
__________________
Arkshine is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-24-2008 , 19:36   Re: Concatenating strings, how to?
Reply With Quote #6

Quote:
Originally Posted by carrasco View Post
Thank you very much Alka, this works fine to me and saved much code lines ;D

danielkza, this method works with 3 variables too?
Just use it twice:
PHP Code:
new str_full[64]
new 
string1[16],string2[16]

add(str_full,charsmax(str_full),string1)
add(str_full,charsmax(str_full),string2
danielkza is offline
Reply


Thread Tools
Display Modes

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 03:11.


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