Raised This Month: $51 Target: $400
 12% 

String problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LaGgLs
Senior Member
Join Date: Apr 2015
Location: sweden
Old 04-17-2015 , 09:04   String problem
Reply With Quote #1

I have two string and I want to add one string in another string.


Code:
new sting:test[32];
new sting:test2[32];

test2 = "godis";

test = "name: "<test2>"";

PrintToServer(test);
print: name: "<godis>"
LaGgLs is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-17-2015 , 09:16   Re: String problem
Reply With Quote #2

Moved to SM section.
__________________
Bugsy is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 04-17-2015 , 09:20   Re: String problem
Reply With Quote #3

try the format native:
PHP Code:
Format(testsizeof(test), "name: \"%s\""test2); //test will be formatted to be: name: godis 
__________________

Last edited by WildCard65; 04-17-2015 at 12:28.
WildCard65 is offline
Dr!fter
The Salt Boss
Join Date: Mar 2007
Old 04-17-2015 , 11:52   Re: String problem
Reply With Quote #4

https://sm.alliedmods.net/new-api/string/StrCat
Dr!fter is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 04-17-2015 , 12:41   Re: String problem
Reply With Quote #5

Simplest to just:
PHP Code:
PrintToServer("name: \"%s\""test2); 

Last edited by necavi; 04-17-2015 at 12:41.
necavi is offline
BAILANDO
Senior Member
Join Date: Feb 2015
Location: Slovakia
Old 04-17-2015 , 14:12   Re: String problem
Reply With Quote #6

First problem, its a :
Code:
new String:something[255];
not a "new sting:something[255]"

As WildCard65 say, best way to declare String with value, its Format function or StrCat. This is not same as C/C++

Last edited by BAILANDO; 04-17-2015 at 14:12.
BAILANDO is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-17-2015 , 15:53   Re: String problem
Reply With Quote #7

On a side note, Format class functions (which also include things like PrintToServer) accept %N as a formatting construct. You pass a client index and %N will print the name for that client.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
LaGgIs
Junior Member
Join Date: May 2011
Old 04-17-2015 , 17:53   Re: String problem
Reply With Quote #8

thx for the help guys rly help me alot<3
LaGgIs 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 10:14.


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