Raised This Month: $51 Target: $400
 12% 

Centered message with color


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
spiider
AlliedModders Donor
Join Date: Jan 2010
Old 03-08-2012 , 18:22   Centered message with color
Reply With Quote #1

Hello,

i'm want write a simple function to display a centered message with color in-game.
I have get from base plugin code and try reused in my plugin

Code:
#include <amxmodx>
#include <amxmisc>
#include <csx>

#define PLUGIN "uniPlay.eu Plugin"
#define VERSION "1.0"
#define AUTHOR "spiider"

new g_msgChannel
new amx_show_activity;

#define MAX_CLR 10

new g_Colors[MAX_CLR][] = {"COL_WHITE", "COL_RED", "COL_GREEN", "COL_BLUE", "COL_YELLOW", "COL_MAGENTA", "COL_CYAN", "COL_ORANGE", "COL_OCEAN", "COL_MAROON"}
new g_Values[MAX_CLR][] = {{255, 255, 255}, {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 0}, {255, 0, 255}, {0, 255, 255}, {227, 96, 8}, {45, 89, 116}, {103, 44, 38}}
new Float:g_Pos[4][] = {{0.0, 0.0}, {0.05, 0.55}, {-1.0, 0.2}, {-1.0, 0.7}}


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	// execute on client

	// send message centered message
	register_srvcmd("amx_cssay","cmd_cssay")

	// is running uniPlay Plugin ? 1 yes :)
	register_cvar("amx_upplugin","1") // done :)
	
		amx_show_activity = get_cvar_pointer("amx_show_activity");
	
	if (amx_show_activity == 0)
	{
		amx_show_activity = register_cvar("amx_show_activity", "2");
	}
}






public cmd_cssay(id, level, cid)
{
	//if (!cmd_access(id, level, cid, 3))
	//	return PLUGIN_HANDLED
	
	new cmd[16], color[16], color2[16], message[192], name[32], authid[32], userid = 0
	
	read_argv(0, cmd, 15)
	new bool:tsay = (tolower(cmd[4]) == 't')
	
	read_args(message, 191)
	remove_quotes(message)
	parse(message, color, 15)
	
	new found = 0, a = 0
	new lang[3], langnum = get_langsnum()
	
	for (new i = 0; i < MAX_CLR; ++i)
	{
		for (new j = 0; j < langnum; j++)
		{
			get_lang(j, lang)
			format(color2, 15, "%L", lang, g_Colors[i])
			
			if (equali(color, color2))
			{
				a = i
				found = 1
				break
			}
		}
		if (found == 1)
			break
	}
	
	new length = found ? (strlen(color) + 1) : 0
	
	if (++g_msgChannel > 6 || g_msgChannel < 3)
		g_msgChannel = 3
	
	new Float:verpos = (tsay ? 0.55 : 0.1) + float(g_msgChannel) / 35.0
	
	get_user_authid(id, authid, 31)
	get_user_name(id, name, 31)
	userid = get_user_userid(id)
	set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], tsay ? 0.05 : -1.0, verpos, 0, 6.0, 6.0, 0.5, 0.15, -1)
	replace_all(message,551,"%n","\n")
	replace_all(message,551,"\n","^n")
	switch ( get_pcvar_num(amx_show_activity) )
	{
		case 3, 4:
		{
			new maxpl = get_maxplayers();
			for (new pl = 1; pl <= maxpl; pl++)
			{
				if (is_user_connected(pl) && !is_user_bot(pl))
				{
					if (is_user_admin(pl))
					{
						show_hudmessage(pl, "%s :   %s", name, message[length])
						client_print(pl, print_notify, "%s :   %s", name, message[length])
					}
					else
					{
						show_hudmessage(pl, "%s", message[length])
						client_print(pl, print_notify, "%s", message[length])
					}
				}
			}
			console_print(id, "%s", message[length])
		}
		case 2:
		{
			show_hudmessage(0, "%s", message[length])
			client_print(0, print_notify, "%s", message[length])
			console_print(id, "%s", name, message[length])
		}
		default:
	{
		show_hudmessage(0, "%s", message[length])
		client_print(0, print_notify, "%s", message[length])
		console_print(id, "%s", message[length])
	}
}

//	log_amx("Chat: ^"%s<%d><%s><>^" %s ^"%s^"", name, userid, authid, cmd[4], message[length])
//	log_message("^"%s<%d><%s><>^" triggered ^"%s^" (text ^"%s^") (color ^"%s^")", name, userid, authid, cmd, message[length], color2)

return PLUGIN_HANDLED
}
But when i disable all other plugin and load my if i use amx_cssay white "this is a test" in-game show white this is a test
spiider is offline
spiider
AlliedModders Donor
Join Date: Jan 2010
Old 03-09-2012 , 20:09   Re: Centered message with color
Reply With Quote #2

fixed, thanks anyway
spiider is offline
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 17:14.


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