lfnetwork.com mark read register faq members calendar

Thread: Announcement command
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 09-07-2009, 04:43 PM   #1
Unreliable
Lurker
 
Join Date: Sep 2009
Posts: 7
Announcement command

I was wondering how you could make an announcement pop up on the screen, such as

/bigtext i am bigtext hear me roar

arbitraryprint does that, but it's predefined print and you can't edit it (without editing the cmd itself).

Thanks!
Unreliable is offline   you may: quote & reply,
Old 09-07-2009, 06:56 PM   #2
-=*Raz0r*=-
Rookie
 
-=*Raz0r*=-'s Avatar
 
Join Date: Oct 2006
Location: Australia
Posts: 243
What do you mean you can't edit it?
There's no basejka way, unless someone's built it under debug mode.
Replicate that command is the easiest thing you can do.
Not sure what you're asking, seeing as you're afraid of editing anything.. =\

-=*Raz0r*=- is offline   you may: quote & reply,
Old 09-07-2009, 07:23 PM   #3
Unreliable
Lurker
 
Join Date: Sep 2009
Posts: 7
Nono, i mean.

You can't do

/arbitraryprint i will display on the screen

because it will still pop up with
"Blah blah blah"

I wanted to make a command that does that but displays what you type on the screen, and not the same thing whenever you use a command, like this.

/bigtext I will be displayed on the big screen
"I will be displayed on the big screen"
Unreliable is offline   you may: quote & reply,
Old 09-08-2009, 04:01 AM   #4
-=*Raz0r*=-
Rookie
 
-=*Raz0r*=-'s Avatar
 
Join Date: Oct 2006
Location: Australia
Posts: 243
First, here's your function you'll want to call

Code:
void Cmd_announce_f( gentity_t *ent )
{
	char p[1024];//This buffer will fit ~1024 characters
	if ( trap_Argc () < 2 )
	{//if there are less than 2 args print help (the actual command counts as an arg)
		trap_SendServerCommand( ent-g_entities, va( "print \"^5Command Usage: ^7announce <message> ^3Prints a message to every client\n\"" ) );
		return; //if there are less than 2 args print help (the actual command counts as an arg)
	}

	strcpy(p, ConcatArgs(1)); //Grab the second arg and put it in our buffer (the actual command counts as an arg)

	//TODO: insert line-feed handling stuff here

	G_LogPrintf( "announce: %s: %s\n", ent->client->pers.netname, p ); //log the action in the server console
	trap_SendServerCommand( -1, va("cp \"%s\"", p) ); //print it on-screen

	return;
}
Then chuck in this code in the ClientCommand function appropriately
Code:
	else if (!Q_stricmp(cmd, "announce"))
	{
		Cmd_announce_f(ent);
		return;
	}
I haven't implemented handling line feeds into that yet, so if you want that you'll have to do it yourself I'm afraid. (A line feed goes to the next line by using '\n')
Sorry for not understanding earlier, I hadn't poked around 'arbitraryprint' in a while and thought it automatically did this =P

Feel free to use this code. I'm not gonna ask for money

-=*Raz0r*=- is offline   you may: quote & reply,
Old 09-08-2009, 06:17 PM   #5
Unreliable
Lurker
 
Join Date: Sep 2009
Posts: 7
Thank you!

And it's ok :3 I could have used a better example than arbitraryprint
Unreliable is offline   you may: quote & reply,
Old 09-12-2009, 10:24 PM   #6
-=*Raz0r*=-
Rookie
 
-=*Raz0r*=-'s Avatar
 
Join Date: Oct 2006
Location: Australia
Posts: 243
Well okay, I found a way to get line-feeds working =P
Code:
	p = G_NewString(p);		//insert line-breaks and stuff

	G_LogPrintf( "announce: %s: %s\n", ent->client->pers.netname, p ); //log the action in the server console
	trap_SendServerCommand( -1, va("cp \"%s\"", p) ); //print it on-screen

	free(p);

	return;
Mind you, I use a custom version of G_NewString which uses 'newb = (char*)malloc(l);' rather than 'newb = (char *) G_Alloc( l );'
You must free your memory! otherwise the server will crash after the function is called too many times.


Last edited by -=*Raz0r*=-; 09-26-2009 at 03:20 PM.
-=*Raz0r*=- is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > Announcement command

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 Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:12 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.