lfnetwork.com mark read register faq members calendar

Thread: messagemodes
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 08-13-2006, 09:57 AM   #1
Dom_152
Rookie
 
Dom_152's Avatar
 
Join Date: Jan 2006
Location: England
Posts: 150
messagemodes

I have Clan Chat in my Mod but at the moment the only way to use it is to write /say_clan Your Message. Is terhe any way of making it so that messagemode4 is my clan chat. So /bind u messagemode4 would allow people to press U type their message and send it just like normal chat. How can i do it? I've looked for ages and I can't work it out.


-----------------------------------------------------
MultiPlayer Xtra
Jedi Academy MP Mod
(Released! Source Code and all!)

Jedi Academy - Xtra
Coming Soon...

-----------------------------------------------------
Dom_152 is offline   you may: quote & reply,
Old 08-13-2006, 11:57 AM   #2
ensiform
The Stig
 
ensiform's Avatar
 
Join Date: Nov 2004
Location: Sawtooth Cauldron
Posts: 1,241
Current Game: Borderlands 2
4 is already taken.

ofc you could write a way in cmd_say_f to intercept something like /clan from messagemode.

add this above cmd_say_f:

Code:
/*
==================
Cmd_Clan_f
==================
*/
void Cmd_Clan_f(gentity_t *ent) 
{
	char cmd[12];
	char *msg;
	int skipargs = 0;

	Q_SayArgv(0, cmd, sizeof(cmd));
	if(!Q_stricmp(cmd, "say") || !Q_stricmp(cmd, "say_team")) {
		skipargs = 1;
		Q_SayArgv(1, cmd, sizeof(cmd));
	}
	if(Q_SayArgc() < 3+skipargs) {
		SP(va2("Usage: %s [name|slot#] [message]\n\"", cmd));
		return;
	}
	Q_SayArgv(1+skipargs, name, sizeof(name));
	msg = Q_SayConcatArgs(2+skipargs);

	G_Say(ent, NULL, SAY_CLAN, msg);
}
replace the old cmd_say_f with this:

Code:
/*
==================
Cmd_Say_f
==================
*/
void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 )
{
	char *args;
//	char *msg;

	if(trap_Argc() < 2 && !arg0) return;
	args = Q_SayConcatArgs(0);

	if (!Q_stricmpn(args, "say /clan ", 8) ||
		 !Q_stricmpn(args, "say_team /clan ", 13)) {
		Cmd_Clan_f( ent );
	}
	else {
		G_Say(ent, NULL, mode, ConcatArgs(((arg0) ? 0 : 1)));
	}
}
make sure these are defined below ConcatArgs, and then add them to g_local.h somewhere so you can use them above and elsewhere.

Code:
// replaces all occurances of "\n" with '\n'
char *Q_AddCR(char *s)
{
	char *copy, *place, *start;

	if(!*s) return s;
	start = s;
	while(*s) {
		if(*s == '\\') {
			copy = s;
			place = s;
			*s++;
			if(*s && *s == 'n') {
				*copy = '\n';
				while(*++s) {
					*++copy = *s;
				}
				*++copy = '\0';
				s = place;
				continue;
			}
		}
		*s++;
	}
	return start;
}

// A replacement for trap_Argc() that can correctly handle
//   say "!cmd arg0 arg1"
// as well as
//   say !cmd arg0 arg1
// The client uses the latter for messages typed in the console
// and the former when the message is typed in the chat popup
int Q_SayArgc(void) 
{
	int c = 1;
	char *s;

	s = ConcatArgs(0);
	if(!*s) return 0;
	while(*s) {
		if(*s == ' ') {
			*s++;
			if(*s != ' ') {
				c++;
				continue;
			}
			while(*s && *s == ' ') *s++;  
			c++;
		}
		*s++;
	}
	return c;
}

// A replacement for trap_Argv() that can correctly handle
//   say "!cmd arg0 arg1"
// as well as
//   say !cmd arg0 arg1
// The client uses the latter for messages typed in the console
// and the former when the message is typed in the chat popup
qboolean Q_SayArgv(int n, char *buffer, int bufferLength)
{
	int bc = 1;
	int c = 0;
	char *s;

	if(bufferLength < 1) return qfalse;
	if(n < 0) return qfalse;
	*buffer = '\0';
	s = ConcatArgs(0);
	while(*s) {
		if(c == n) {
			while(*s && (bc < bufferLength)) {
				if(*s == ' ') {
					*buffer = '\0';
					return qtrue;
				}
				*buffer = *s;
				*buffer++;
				*s++;
				bc++;
			}
			*buffer = '\0';
			return qtrue;
		}
		if(*s == ' ') {
			*s++;
			if(*s != ' ') {
				c++;
				continue;
			}
			while(*s && *s == ' ') *s++;  
			c++;
		}
		*s++;
	}
	return qfalse;
}
Now, all you have to do is maybe add password support to cmd_clan_f and make sure msgs checks 3+skiparg, then just do the rest of the checking in g_say and g_sayto.

the only way you can make a new messagemode is to write a client hack to load a menu that has a textbox and allows you to press enter and close the menu and send your /say cmd. which imo is very difficult.


iojamp project lead / coder

Last edited by ensiform; 08-13-2006 at 12:13 PM.
ensiform 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 > messagemodes

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 07:57 PM.

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