AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Concatenating strings, how to? (https://forums.alliedmods.net/showthread.php?t=76455)

carrasco 08-24-2008 18:26

Concatenating strings, how to?
 
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

Alka 08-24-2008 18:38

Re: Concatenating strings, how to?
 
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);


danielkza 08-24-2008 18:53

Re: Concatenating strings, how to?
 
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


carrasco 08-24-2008 19:10

Re: Concatenating strings, how to?
 
Thank you very much Alka, this works fine to me and saved much code lines ;D

danielkza, this method works with 3 variables too?

Arkshine 08-24-2008 19:11

Re: Concatenating strings, how to?
 
Or why not strcat() .

danielkza 08-24-2008 19:36

Re: Concatenating strings, how to?
 
Quote:

Originally Posted by carrasco (Post 675128)
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



All times are GMT -4. The time now is 03:11.

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