Raised This Month: $ Target: $400
 0% 

What operator i have to use to join few strings?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
orglee
Member
Join Date: Dec 2005
Old 05-03-2006 , 22:20   What operator i have to use to join few strings?
Reply With Quote #1

What operator i have to use to join 3 string?
Example:
Code:
client_print(id,print_chat,hostname)
I want this code to display =
* [hostname] Some msg.
Ive tried to join them like this:
Code:
client_print(id,print_chat,"["+hostname+"]")
Please tell me how i can join strings.
Best Regards
orglee is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-03-2006 , 22:34  
Reply With Quote #2

Did u want it to actually display your hostname?




Code:
new HName[32] get_cvar_string("hostname",HName,31) client_print(id,print_chat,"%s",HName)
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Smokey485
Senior Member
Join Date: Dec 2004
Location: Newt 'Ellin
Old 05-03-2006 , 22:38  
Reply With Quote #3

Code:
new hostname = get_cvar_string("hostname") client_print(id,print_chat,"Welcome to %s!", hostname)
Would display the server name where %s is.[/small]
__________________
+karma if I am helpful to you.
I am one in a few million.
Smokey485 is offline
Send a message via AIM to Smokey485 Send a message via MSN to Smokey485
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 05-03-2006 , 22:39  
Reply With Quote #4

Im sorry...I wrote the wrong thing..

I just edited it lol..

Thanks for the post after mine
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Smokey485
Senior Member
Join Date: Dec 2004
Location: Newt 'Ellin
Old 05-03-2006 , 23:11  
Reply With Quote #5

Quote:
Originally Posted by SweatyBanana
Im sorry...I wrote the wrong thing..

I just edited it lol..

Thanks for the post after mine
Im good.
__________________
+karma if I am helpful to you.
I am one in a few million.
Smokey485 is offline
Send a message via AIM to Smokey485 Send a message via MSN to Smokey485
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-03-2006 , 23:40  
Reply With Quote #6

Quote:
Originally Posted by Smokey485
Quote:
Originally Posted by SweatyBanana
Im sorry...I wrote the wrong thing..

I just edited it lol..

Thanks for the post after mine :)
Then give me karma, its the only correct way to thank me!
Don't be cocky/silly.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
FatalisDK
Senior Member
Join Date: Mar 2006
Location: bacon
Old 05-04-2006 , 00:35  
Reply With Quote #7

@ Original question:

If your function doesn't have formatting built into it(as seen in client_print), you can use format.

Here's an example.

Code:
new szName[32], szHostname[32], szOutput[64]     get_user_name(id, szName, 31) get_cvar_string("hostname", szHostname, 31)     format(szOutput, 63, "Hello %s, Welcome to %s. You are player #%i.", szName, szHostname, get_user_userid(id))
__________________
FatalisDK is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 05-04-2006 , 01:22  
Reply With Quote #8

Quote:
Originally Posted by Smokey485
Code:
new hostname = get_cvar_string("hostname") client_print(id,print_chat,"Welcome to %s!", hostname)
Would display the server name where %s is.[/small]
This is a bad way to do this. You didn't even set the array size. Probably get a out of bound error to.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 05-04-2006 , 02:23  
Reply With Quote #9

it just wouldn't even compile. get_cvar_string() requires more fields than given here.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
orglee
Member
Join Date: Dec 2005
Old 05-04-2006 , 06:58  
Reply With Quote #10

I thought there is some operator like in PHP where i can join two string with
dot like this
Code:
PHP CODE:
<?php
$someVar = "some text".$someOtherVar."Some text";
?>
I just dont understand what means thous:
%s
#%i
I coldnt find it in help.
Can you tell me where is explanation to thous ...
hmm i dont know even what they are.
orglee 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 05:12.


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