Raised This Month: $32 Target: $400
 8% 

client_cmd echo with newline


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KrazyKat
Member
Join Date: Mar 2021
Old 03-17-2021 , 14:46   client_cmd echo with newline
Reply With Quote #1

Hi guys,

I was working on sending a large message to console using client_cmd, but I don't want to use it multiple times. For example:

client_cmd(id, "echo ^"Welcome to my server!^nYou can type /help for help regarding this game.^"")

instead of

client_cmd(id, "echo ^"Welcome to my server!^"")
client_cmd(id, "echo ^"You can type /help for help regarding this game.^"")

When I tried the 1st example, I received invalid character constant error, and I don't know how to rectify this. Can anyone help me please?

Last edited by KrazyKat; 03-17-2021 at 14:46.
KrazyKat is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-17-2021 , 14:53   Re: client_cmd echo with newline
Reply With Quote #2

Why would you use "client_cmd" with "echo" instead of console_print/client_print? That's ridiculous.

PS: echo doesn't even support newline.
__________________

Last edited by OciXCrom; 03-17-2021 at 14:54.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
KrazyKat
Member
Join Date: Mar 2021
Old 03-17-2021 , 14:58   Re: client_cmd echo with newline
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
Why would you use "client_cmd" with "echo" instead of console_print/client_print? That's ridiculous.

PS: echo doesn't even support newline.
Thank you, that makes much more sense. I didn't think of it earlier and went about using client_cmd after seeing it being used in another plugin. Appreciate your help.
KrazyKat is offline
KrazyKat
Member
Join Date: Mar 2021
Old 03-17-2021 , 23:09   Re: client_cmd echo with newline
Reply With Quote #4

Hey OciX, I tried using console_print, but it doesn't work even though I've placed it as a function that loads in client_putinserver. How should I allow the commands to work as soon as someone joins the server?
KrazyKat is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-17-2021 , 23:15   Re: client_cmd echo with newline
Reply With Quote #5

That should work. Show your code so we can see if maybe there is a mistake causing this. You could also do a little debugging by adding in a delay with set_task() to see if there is anyhing weird going on.
__________________

Last edited by fysiks; 03-17-2021 at 23:16.
fysiks is offline
KrazyKat
Member
Join Date: Mar 2021
Old 03-18-2021 , 00:39   Re: client_cmd echo with newline
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
That should work. Show your code so we can see if maybe there is a mistake causing this. You could also do a little debugging by adding in a delay with set_task() to see if there is anyhing weird going on.
I tried doing these:

new message[512];
formatex(message, 511, "============================================ ^n
Welcome to %s ^n
Type /help to receive more help about the mod.^n
Type /commands to receive the set of commands for this server.^n
Type /info to receive your statistics [Rank, Kills, Deaths]^n
Type /rtv to change the mod.^n
============================================" , hostname);
console_print(id, "%s", message)

And this:
console_print(id, "============================================ ")
console_print(id, "Welcome to %s ", hostname)
console_print(id, "Type /help to receive more help about the mod.")
console_print(id, "Type /commands to receive the set of commands for this server.")
console_print(id, "Type /info to receive your statistics [Rank, Kills, Deaths]")
console_print(id, "Type /rtv to change the mod.")
console_print(id, "============================================ ")

These were put in a function consoleinfo(id) that was loaded in client_putinserver(id). I'll try using set_task for this to check if it works.
KrazyKat is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-18-2021 , 10:30   Re: client_cmd echo with newline
Reply With Quote #7

Post the full code. There's no reason for it not to work from what you told us. Check if you spelled client_putinserver() correctly.

PS: don't hardcode buffer lengths. Use charsmax(message) instead of 511.
PS2: no reason to use formatex() and a variable since console_print() supports direct string formatting.
__________________

Last edited by OciXCrom; 03-18-2021 at 10:31.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 23:09.


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