2014-08-04 12:12:15 +00:00
|
|
|
// vim: set ts=4 sw=4 tw=99 noet:
|
|
|
|
//
|
|
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
|
|
//
|
|
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
|
|
// https://alliedmods.net/amxmodx-license
|
|
|
|
|
|
|
|
//
|
|
|
|
// Scrolling Message Plugin
|
|
|
|
//
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2004-03-05 19:35:38 +00:00
|
|
|
#include <amxmodx>
|
2004-03-07 14:30:53 +00:00
|
|
|
#include <amxmisc>
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
const SCROLLMSG_SIZE = 512;
|
|
|
|
const SCROLLMSG_TASK = 123;
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
new g_hostname[64];
|
|
|
|
new g_amx_scrollmsg_color_red;
|
|
|
|
new g_amx_scrollmsg_color_green;
|
|
|
|
new g_amx_scrollmsg_color_blue;
|
|
|
|
new g_amx_scrollmsg_only_dead;
|
|
|
|
new Float:g_amx_scrollmsg_speed;
|
|
|
|
new Float:g_amx_scrollmsg_x_move_amount;
|
|
|
|
new Float:g_amx_scrollmsg_x_start_pos;
|
|
|
|
new Float:g_amx_scrollmsg_x_end_pos;
|
|
|
|
new Float:g_amx_scrollmsg_y_pos;
|
|
|
|
|
|
|
|
new g_start_pos;
|
|
|
|
new g_end_pos;
|
|
|
|
new g_scroll_msg[SCROLLMSG_SIZE];
|
|
|
|
new g_display_msg[SCROLLMSG_SIZE];
|
|
|
|
new g_length;
|
|
|
|
new g_frequency;
|
|
|
|
new g_hud_object;
|
|
|
|
new Float:g_x_pos;
|
2004-01-31 20:56:22 +00:00
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public plugin_init()
|
|
|
|
{
|
2022-07-11 13:18:27 +00:00
|
|
|
register_plugin("Scrolling Message", AMXX_VERSION_STR, "AMXX Dev Team");
|
|
|
|
|
|
|
|
register_dictionary("scrollmsg.txt");
|
|
|
|
register_dictionary("common.txt");
|
|
|
|
|
|
|
|
register_srvcmd("amx_scrollmsg", "setMessage", _, "<message> <frequency>");
|
|
|
|
bind_pcvar_string(get_cvar_pointer("hostname"), g_hostname, charsmax(g_hostname));
|
|
|
|
|
|
|
|
bind_pcvar_num(create_cvar( "amx_scrollmsg_color_red", "200", _, "Red color amount", true, 0.0, true, 255.0), g_amx_scrollmsg_color_red);
|
|
|
|
bind_pcvar_num(create_cvar( "amx_scrollmsg_color_green", "100", _, "Green color amount", true, 0.0, true, 255.0), g_amx_scrollmsg_color_green);
|
|
|
|
bind_pcvar_num(create_cvar( "amx_scrollmsg_color_blue", "0", _, "Blue color amount", true, 0.0, true, 255.0), g_amx_scrollmsg_color_blue);
|
|
|
|
bind_pcvar_num(create_cvar( "amx_scrollmsg_only_dead", "0", _, "Display the message only to dead clients?", true, 0.0, true, 1.0), g_amx_scrollmsg_only_dead);
|
|
|
|
bind_pcvar_float(create_cvar( "amx_scrollmsg_speed", "0.3", _, "The rate at which the message will move", true, 0.0), g_amx_scrollmsg_speed);
|
|
|
|
bind_pcvar_float(create_cvar( "amx_scrollmsg_x_move_amount", "0.0063", _, "The amount of units to move on the X axis"), g_amx_scrollmsg_x_move_amount);
|
|
|
|
bind_pcvar_float(create_cvar( "amx_scrollmsg_x_start_pos", "0.35", _, "Starting position on the X axis", true, -1.0, true, 1.0), g_amx_scrollmsg_x_start_pos);
|
|
|
|
bind_pcvar_float(create_cvar( "amx_scrollmsg_x_end_pos", "0.65", _, "Ending position on the X axis", true, -1.0, true, 1.0), g_amx_scrollmsg_x_end_pos);
|
|
|
|
bind_pcvar_float(create_cvar( "amx_scrollmsg_y_pos", "0.9", _, "The Y position of the message", true, -1.0, true, 1.0), g_amx_scrollmsg_y_pos);
|
|
|
|
|
|
|
|
g_hud_object = CreateHudSyncObj();
|
|
|
|
AutoExecConfig();
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public showMsg()
|
|
|
|
{
|
2022-07-11 13:18:27 +00:00
|
|
|
new a = g_start_pos, i = 0;
|
2004-08-06 18:40:41 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
while (a < g_end_pos)
|
|
|
|
{
|
|
|
|
g_display_msg[i++] = g_scroll_msg[a++];
|
|
|
|
}
|
2004-08-06 18:40:41 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
g_display_msg[i] = 0;
|
2004-08-06 18:40:41 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
if (g_end_pos < g_length)
|
|
|
|
{
|
|
|
|
g_end_pos++;
|
|
|
|
}
|
2004-08-06 18:40:41 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
if (g_x_pos > g_amx_scrollmsg_x_start_pos)
|
|
|
|
{
|
|
|
|
g_x_pos -= g_amx_scrollmsg_x_move_amount;
|
|
|
|
}
|
2005-09-12 21:06:24 +00:00
|
|
|
else
|
|
|
|
{
|
2022-07-11 13:18:27 +00:00
|
|
|
g_start_pos++;
|
|
|
|
g_x_pos = g_amx_scrollmsg_x_start_pos;
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
2004-08-06 18:40:41 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
set_hudmessage(g_amx_scrollmsg_color_red, g_amx_scrollmsg_color_green, g_amx_scrollmsg_color_blue, g_x_pos, g_amx_scrollmsg_y_pos, 0, g_amx_scrollmsg_speed, g_amx_scrollmsg_speed, 0.05, 0.05, 2);
|
|
|
|
|
|
|
|
if (g_amx_scrollmsg_only_dead)
|
|
|
|
{
|
|
|
|
new players[MAX_PLAYERS], pnum;
|
|
|
|
get_players_ex(players, pnum, GetPlayers_ExcludeBots | GetPlayers_ExcludeHLTV | GetPlayers_ExcludeAlive);
|
|
|
|
|
|
|
|
for (new i; i < pnum; i++)
|
|
|
|
{
|
|
|
|
ShowSyncHudMsg(players[i], g_hud_object, g_display_msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowSyncHudMsg(0, g_hud_object, g_display_msg);
|
|
|
|
}
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public msgInit()
|
|
|
|
{
|
2022-07-11 13:18:27 +00:00
|
|
|
g_end_pos = 1;
|
|
|
|
g_start_pos = 0;
|
|
|
|
g_x_pos = g_amx_scrollmsg_x_end_pos;
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
replace_stringex(g_scroll_msg, charsmax(g_scroll_msg), "%hostname%", g_hostname);
|
2006-04-25 07:35:02 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
g_length = strlen(g_scroll_msg);
|
2006-04-25 07:35:02 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
set_task_ex(g_amx_scrollmsg_speed, "showMsg", SCROLLMSG_TASK, "", 0, SetTask_RepeatTimes, g_length + 48);
|
|
|
|
console_print(0, g_scroll_msg);
|
2004-01-31 20:56:22 +00:00
|
|
|
}
|
|
|
|
|
2005-09-12 21:06:24 +00:00
|
|
|
public setMessage()
|
|
|
|
{
|
2022-07-11 13:18:27 +00:00
|
|
|
remove_task(SCROLLMSG_TASK); /* remove current messaging */
|
|
|
|
read_argv(1, g_scroll_msg, charsmax(g_scroll_msg));
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
g_length = strlen(g_scroll_msg);
|
|
|
|
g_frequency = read_argv_int(2);
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
if (g_frequency > 0)
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
2022-07-11 13:18:27 +00:00
|
|
|
new minimal = floatround((g_length + 48) * (g_amx_scrollmsg_speed + 0.1));
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
if (g_frequency < minimal)
|
2005-09-12 21:06:24 +00:00
|
|
|
{
|
2022-07-11 13:18:27 +00:00
|
|
|
server_print("%L", LANG_SERVER, "MIN_FREQ", minimal);
|
|
|
|
g_frequency = minimal;
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
server_print("%L", LANG_SERVER, "MSG_FREQ", g_frequency / 60, g_frequency % 60);
|
|
|
|
set_task_ex(float(g_frequency), "msgInit", SCROLLMSG_TASK, "", 0, SetTask_Repeat);
|
2005-09-12 21:06:24 +00:00
|
|
|
}
|
|
|
|
else
|
2022-07-11 13:18:27 +00:00
|
|
|
{
|
|
|
|
server_print("%L", LANG_SERVER, "MSG_DISABLED");
|
|
|
|
}
|
2005-09-12 21:06:24 +00:00
|
|
|
|
2022-07-11 13:18:27 +00:00
|
|
|
return PLUGIN_HANDLED;
|
2004-08-22 04:25:55 +00:00
|
|
|
}
|