Raised This Month: $89 Target: $400
 22% 

Sending say's Area Text


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeetleFart
SourceMod Donor
Join Date: Apr 2004
Old 12-06-2004 , 13:57   Sending say's Area Text
Reply With Quote #1

Does anyone know how to send text to a client that will display in the
say text area?

i dont think the helpers->CreateMessage( pEntity, DIALOG_MSG, kv, this ); does this.
BeetleFart is offline
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 12-06-2004 , 16:25  
Reply With Quote #2

I use this as a member function of my plugin's class:
Code:
	void ClientMsg(edict_t* pEntity, const unsigned int TIME, const DIALOG_TYPE TYPE, const char* FORMAT, ...) {
		tchar szBuf[256];
		va_list arg_ptr;
		va_start(arg_ptr, FORMAT);
		_vsntprintf(szBuf, sizeof(szBuf)-1, FORMAT, arg_ptr);
		va_end(arg_ptr);

		szBuf[sizeof(szBuf)-1] = 0;

		KeyValues *kv = new KeyValues("msg");
		kv->SetString("title", szBuf);
		kv->SetString("msg", "This is the msg");
		kv->SetColor("color", Color(10, 240, 10, 255));
		kv->SetInt("level", 5);
		kv->SetInt("time", TIME);
		helpers->CreateMessage(pEntity, TYPE, kv, this);
		kv->deleteThis();
	}
Example use:
Code:
ClientMsg(pEntity, 5, DIALOG_MSG, "You have %d turtles", turtlesCount)
Can't be used for console messages though. But it would be easy to make it work for that also, altering the third parameter. Maybe creating a new enum:
Code:
	typedef enum
	{
		MSG_CHAT = 0, // just an on screen message
		MSG_MENU, // an options menu
		MSG_RICH, // a richtext dialog
		MSG_CONSOLE,
	} DIALOG_TYPE_EXTENDED;
	void ClientMsg(edict_t* pEntity, const unsigned int TIME, const DIALOG_TYPE_EXTENDED TYPE, const char* FORMAT, ...) {
		tchar szBuf[256];
		va_list arg_ptr;
		va_start(arg_ptr, FORMAT);
		_vsntprintf(szBuf, sizeof(szBuf)-1, FORMAT, arg_ptr);
		va_end(arg_ptr);

		switch (TYPE) {
			case MSG_CONSOLE: {
				szBuf[sizeof(szBuf) - 1] = '\n';
				szBuf[sizeof(szBuf)] = 0;

				engine->ClientPrintf(pEntity, szBuf);
				break;
			}
			default: {
				szBuf[sizeof(szBuf)-1] = 0;
				KeyValues *kv = new KeyValues("msg");
				kv->SetString("title", szBuf);
				kv->SetString("msg", "This is the msg");
				kv->SetColor("color", Color(10, 240, 10, 255));
				kv->SetInt("level", 5);
				kv->SetInt("time", TIME);
				helpers->CreateMessage(pEntity, (DIALOG_TYPE)TYPE, kv, this);
				kv->deleteThis();
			 }
		}
	}
Johnny got his gun is offline
Reply


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

Forum Jump


All times are GMT -4. The time now is 16:52.


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