Raised This Month: $ Target: $400
 0% 

Adding quotes in string


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-11-2013 , 23:26   Adding quotes in string
Reply With Quote #1

How do I add quotes into my formatted string ?

my output should be like: sample "quoted text". actually this will go to server console to execute a server cmd. Below code is not working

PHP Code:
new szStr1[11], szStr2[25]
formatex(Str225"sample_cmd ^"%s^""Str1
client_cmd(id, "echo %s", Str2); -- shows sample_cmd <value>
or
client_cmd(id, "echo ^"%s^"", Str2); --shows sample_cmd <value>""

Last edited by hypheni; 01-11-2013 at 23:28.
hypheni is offline
Send a message via Skype™ to hypheni
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-11-2013 , 23:40   Re: Adding quotes in string
Reply With Quote #2

You have done it correctly, ^" everywhere you want a quote. Just print it somewhere to test it.
__________________

Last edited by fysiks; 01-11-2013 at 23:41.
fysiks is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-12-2013 , 03:34   Re: Adding quotes in string
Reply With Quote #3

Yes, that what should be but I found it not working.

Output is

PHP Code:
client_cmd(id"echo %s"Str2); -- shows sample_cmd <value>
or 
client_cmd(id"echo ^"%s^""Str2); --shows sample_cmd <value>"" 
hypheni is offline
Send a message via Skype™ to hypheni
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-12-2013 , 11:05   Re: Adding quotes in string
Reply With Quote #4

Okay. Something I missed in hurry I guess. Now its working as expected.

THREAD CLOSED!
hypheni is offline
Send a message via Skype™ to hypheni
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-12-2013 , 13:08   Re: Adding quotes in string
Reply With Quote #5

It depends on the rest of your command. Echo is a client command and a special command. It will print the next parameter passed into the client's console. When you add quotes, it makes that entire string a single parameter and the quotes are stripped upon printing. As such, echo displaying quotes since it assumes they are the start or end of a parameter, so it is best to use client_print or console_print if you want to print stuff to the client's console.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-12-2013 , 13:14   Re: Adding quotes in string
Reply With Quote #6

^ Yes correct, I found my it working when I used client_print(print_console, ...) instead echo
hypheni is offline
Send a message via Skype™ to hypheni
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 13:40.


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