AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Adding quotes in string (https://forums.alliedmods.net/showthread.php?t=205562)

hypheni 01-11-2013 23:26

Adding quotes in string
 
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>""

fysiks 01-11-2013 23:40

Re: Adding quotes in string
 
You have done it correctly, ^" everywhere you want a quote. Just print it somewhere to test it.

hypheni 01-12-2013 03:34

Re: Adding quotes in string
 
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 01-12-2013 11:05

Re: Adding quotes in string
 
Okay. Something I missed in hurry I guess. Now its working as expected.

THREAD CLOSED!

YamiKaitou 01-12-2013 13:08

Re: Adding quotes in string
 
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.

hypheni 01-12-2013 13:14

Re: Adding quotes in string
 
^ Yes correct, I found my it working when I used client_print(print_console, ...) instead echo


All times are GMT -4. The time now is 13:40.

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