This commit is contained in:
parent
63c18bba6c
commit
0a0a8bc13d
|
@ -14,94 +14,136 @@
|
||||||
#include <amxmodx>
|
#include <amxmodx>
|
||||||
#include <amxmisc>
|
#include <amxmisc>
|
||||||
|
|
||||||
#define SPEED 0.3
|
const SCROLLMSG_SIZE = 512;
|
||||||
#define SCROLLMSG_SIZE 512
|
const SCROLLMSG_TASK = 123;
|
||||||
|
|
||||||
new g_startPos
|
new g_hostname[64];
|
||||||
new g_endPos
|
new g_amx_scrollmsg_color_red;
|
||||||
new g_scrollMsg[SCROLLMSG_SIZE]
|
new g_amx_scrollmsg_color_green;
|
||||||
new g_displayMsg[SCROLLMSG_SIZE]
|
new g_amx_scrollmsg_color_blue;
|
||||||
new Float:g_xPos
|
new g_amx_scrollmsg_only_dead;
|
||||||
new g_Length
|
new Float:g_amx_scrollmsg_speed;
|
||||||
new g_Frequency
|
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;
|
||||||
|
|
||||||
public plugin_init()
|
public plugin_init()
|
||||||
{
|
{
|
||||||
register_plugin("Scrolling Message", AMXX_VERSION_STR, "AMXX Dev Team")
|
register_plugin("Scrolling Message", AMXX_VERSION_STR, "AMXX Dev Team");
|
||||||
register_dictionary("scrollmsg.txt")
|
|
||||||
register_dictionary("common.txt")
|
register_dictionary("scrollmsg.txt");
|
||||||
register_srvcmd("amx_scrollmsg", "setMessage")
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
public showMsg()
|
public showMsg()
|
||||||
{
|
{
|
||||||
new a = g_startPos, i = 0
|
new a = g_start_pos, i = 0;
|
||||||
|
|
||||||
while (a < g_endPos)
|
while (a < g_end_pos)
|
||||||
g_displayMsg[i++] = g_scrollMsg[a++]
|
|
||||||
|
|
||||||
g_displayMsg[i] = 0
|
|
||||||
|
|
||||||
if (g_endPos < g_Length)
|
|
||||||
g_endPos++
|
|
||||||
|
|
||||||
if (g_xPos > 0.35)
|
|
||||||
g_xPos -= 0.0063
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
g_startPos++
|
g_display_msg[i++] = g_scroll_msg[a++];
|
||||||
g_xPos = 0.35
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2)
|
g_display_msg[i] = 0;
|
||||||
show_hudmessage(0, "%s", g_displayMsg)
|
|
||||||
|
if (g_end_pos < g_length)
|
||||||
|
{
|
||||||
|
g_end_pos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_x_pos > g_amx_scrollmsg_x_start_pos)
|
||||||
|
{
|
||||||
|
g_x_pos -= g_amx_scrollmsg_x_move_amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_start_pos++;
|
||||||
|
g_x_pos = g_amx_scrollmsg_x_start_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public msgInit()
|
public msgInit()
|
||||||
{
|
{
|
||||||
g_endPos = 1
|
g_end_pos = 1;
|
||||||
g_startPos = 0
|
g_start_pos = 0;
|
||||||
g_xPos = 0.65
|
g_x_pos = g_amx_scrollmsg_x_end_pos;
|
||||||
|
|
||||||
new hostname[64]
|
replace_stringex(g_scroll_msg, charsmax(g_scroll_msg), "%hostname%", g_hostname);
|
||||||
|
|
||||||
get_cvar_string("hostname", hostname, charsmax(hostname))
|
g_length = strlen(g_scroll_msg);
|
||||||
replace(g_scrollMsg, charsmax(g_scrollMsg), "%hostname%", hostname)
|
|
||||||
|
|
||||||
g_Length = strlen(g_scrollMsg)
|
set_task_ex(g_amx_scrollmsg_speed, "showMsg", SCROLLMSG_TASK, "", 0, SetTask_RepeatTimes, g_length + 48);
|
||||||
|
console_print(0, g_scroll_msg);
|
||||||
set_task(SPEED, "showMsg", 123, "", 0, "a", g_Length + 48)
|
|
||||||
client_print(0, print_console, "%s", g_scrollMsg)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public setMessage()
|
public setMessage()
|
||||||
{
|
{
|
||||||
remove_task(123) /* remove current messaging */
|
remove_task(SCROLLMSG_TASK); /* remove current messaging */
|
||||||
read_argv(1, g_scrollMsg, charsmax(g_scrollMsg))
|
read_argv(1, g_scroll_msg, charsmax(g_scroll_msg));
|
||||||
|
|
||||||
g_Length = strlen(g_scrollMsg)
|
g_length = strlen(g_scroll_msg);
|
||||||
|
g_frequency = read_argv_int(2);
|
||||||
|
|
||||||
new mytime[32]
|
if (g_frequency > 0)
|
||||||
|
|
||||||
read_argv(2, mytime, charsmax(mytime))
|
|
||||||
|
|
||||||
g_Frequency = str_to_num(mytime)
|
|
||||||
|
|
||||||
if (g_Frequency > 0)
|
|
||||||
{
|
{
|
||||||
new minimal = floatround((g_Length + 48) * (SPEED + 0.1))
|
new minimal = floatround((g_length + 48) * (g_amx_scrollmsg_speed + 0.1));
|
||||||
|
|
||||||
if (g_Frequency < minimal)
|
if (g_frequency < minimal)
|
||||||
{
|
{
|
||||||
server_print("%L", LANG_SERVER, "MIN_FREQ", minimal)
|
server_print("%L", LANG_SERVER, "MIN_FREQ", minimal);
|
||||||
g_Frequency = minimal
|
g_frequency = minimal;
|
||||||
}
|
}
|
||||||
|
|
||||||
server_print("%L", LANG_SERVER, "MSG_FREQ", g_Frequency / 60, g_Frequency % 60)
|
server_print("%L", LANG_SERVER, "MSG_FREQ", g_frequency / 60, g_frequency % 60);
|
||||||
set_task(float(g_Frequency), "msgInit", 123, "", 0, "b")
|
set_task_ex(float(g_frequency), "msgInit", SCROLLMSG_TASK, "", 0, SetTask_Repeat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
server_print("%L", LANG_SERVER, "MSG_DISABLED")
|
{
|
||||||
|
server_print("%L", LANG_SERVER, "MSG_DISABLED");
|
||||||
|
}
|
||||||
|
|
||||||
return PLUGIN_HANDLED
|
return PLUGIN_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user