Flummi 2022-07-11 13:22:45 +00:00
parent 950e63d62f
commit 03cdb55266
4 changed files with 169 additions and 117 deletions

View File

@ -37,18 +37,38 @@ amx_show_activity 2
// Default value: "Welcome to %hostname% -- This server is using AMX Mod X" 600 // Default value: "Welcome to %hostname% -- This server is using AMX Mod X" 600
amx_scrollmsg "Welcome to %hostname% -- This server is using AMX Mod X" 600 amx_scrollmsg "Welcome to %hostname% -- This server is using AMX Mod X" 600
// Center typed colored messages (last parameter is a color in RRRGGGBBB format) // Center typed colored info messages (last parameter is a color in RRRGGGBBB format)
// //
// Default values: "Welcome to %hostname%" "000255100" // Default values: "Welcome to %hostname%" "000255100"
// "This server is using AMX ModX\nVisit http://www.amxmodx.org" "000100255" // "This server is using AMX ModX\nVisit http://www.amxmodx.org" "000100255"
amx_imessage "Welcome to %hostname%" "000255100" amx_imessage "Welcome to %hostname%" "000255100"
amx_imessage "This server is using AMX Mod X\nVisit http://www.amxmodx.org" "000100255" amx_imessage "This server is using AMX Mod X\nVisit http://www.amxmodx.org" "000100255"
// Frequency in seconds of colored messages // Frequency in seconds of info messages
// //
// Default value: 180 // Default value: 180
amx_freq_imessage 180 amx_freq_imessage 180
// X position on the screen for info messages
//
// Default value: -1.0
amx_imessage_x_pos -1.0
// Y position on the screen for info messages
//
// Default value: 0.2
amx_imessage_y_pos 0.2
// Hold time for info messages
//
// Default value: 12.0
amx_imessage_holdtime 12.0
// Set to 1 if you want to show info messages only to dead clients
//
// Default value: 0
amx_imessage_only_dead 0
// Ban times for the main ban menu (amx_banmenu) // Ban times for the main ban menu (amx_banmenu)
// Use 0 for permanent ban. // Use 0 for permanent ban.
// Default values: 0 5 10 15 30 45 60 // Default values: 0 5 10 15 30 45 60
@ -181,13 +201,3 @@ amx_debug 1
// //
// Default value: "" // Default value: ""
amx_mldebug "" amx_mldebug ""
// Performance monitor
//
// If function executed more than amx_perflog_ms milliseconds
// print plugin and function name to current amxmodx log file.
//
// Time in milliseconds
// Default value: 1.0
//
amx_perflog_ms 1.0

View File

@ -37,18 +37,38 @@ amx_show_activity 2
// Default value: "Welcome to %hostname% -- This server is using AMX Mod X" 600 // Default value: "Welcome to %hostname% -- This server is using AMX Mod X" 600
amx_scrollmsg "Welcome to %hostname% -- This server is using AMX Mod X" 600 amx_scrollmsg "Welcome to %hostname% -- This server is using AMX Mod X" 600
// Center typed colored messages (last parameter is a color in RRRGGGBBB format) // Center typed colored info messages (last parameter is a color in RRRGGGBBB format)
// //
// Default values: "Welcome to %hostname%" "000255100" // Default values: "Welcome to %hostname%" "000255100"
// "This server is using AMX ModX\nVisit http://www.amxmodx.org" "000100255" // "This server is using AMX ModX\nVisit http://www.amxmodx.org" "000100255"
amx_imessage "Welcome to %hostname%" "000255100" amx_imessage "Welcome to %hostname%" "000255100"
amx_imessage "This server is using AMX Mod X\nVisit http://www.amxmodx.org" "000100255" amx_imessage "This server is using AMX Mod X\nVisit http://www.amxmodx.org" "000100255"
// Frequency in seconds of colored messages // Frequency in seconds of info messages
// //
// Default value: 180 // Default value: 180
amx_freq_imessage 180 amx_freq_imessage 180
// X position on the screen for info messages
//
// Default value: -1.0
amx_imessage_x_pos -1.0
// Y position on the screen for info messages
//
// Default value: 0.2
amx_imessage_y_pos 0.2
// Hold time for info messages
//
// Default value: 12.0
amx_imessage_holdtime 12.0
// Set to 1 if you want to show info messages only to dead clients
//
// Default value: 0
amx_imessage_only_dead 0
// Ban times for the main ban menu (amx_banmenu) // Ban times for the main ban menu (amx_banmenu)
// Use 0 for permanent ban // Use 0 for permanent ban
// Default values: 0 5 10 15 30 45 60 // Default values: 0 5 10 15 30 45 60
@ -220,13 +240,3 @@ amx_statsx_freeze -2.0
// - // -
// Default value: 0 // Default value: 0
amx_restrmapsettings 0 amx_restrmapsettings 0
// Performance monitor
//
// If function executed more than amx_perflog_ms milliseconds
// print plugin and function name to current amxmodx log file.
//
// Time in milliseconds
// Default value: 1.0
//
amx_perflog_ms 1.0

View File

@ -37,18 +37,38 @@ amx_show_activity 2
// Default value: "Welcome to %hostname% -- This server is using AMX Mod X" 600 // Default value: "Welcome to %hostname% -- This server is using AMX Mod X" 600
amx_scrollmsg "Welcome to %hostname% -- This server is using AMX Mod X" 600 amx_scrollmsg "Welcome to %hostname% -- This server is using AMX Mod X" 600
// Center typed colored messages (last parameter is a color in RRRGGGBBB format) // Center typed colored info messages (last parameter is a color in RRRGGGBBB format)
// //
// Default values: "Welcome to %hostname%" "000255100" // Default values: "Welcome to %hostname%" "000255100"
// "This server is using AMX ModX\nVisit http://www.amxmodx.org" "000100255" // "This server is using AMX ModX\nVisit http://www.amxmodx.org" "000100255"
amx_imessage "Welcome to %hostname%" "000255100" amx_imessage "Welcome to %hostname%" "000255100"
amx_imessage "This server is using AMX Mod X\nVisit http://www.amxmodx.org" "000100255" amx_imessage "This server is using AMX Mod X\nVisit http://www.amxmodx.org" "000100255"
// Frequency in seconds of colored messages // Frequency in seconds of info messages
// //
// Default value: 180 // Default value: 180
amx_freq_imessage 180 amx_freq_imessage 180
// X position on the screen for info messages
//
// Default value: -1.0
amx_imessage_x_pos -1.0
// Y position on the screen for info messages
//
// Default value: 0.2
amx_imessage_y_pos 0.2
// Hold time for info messages
//
// Default value: 12.0
amx_imessage_holdtime 12.0
// Set to 1 if you want to show info messages only to dead clients
//
// Default value: 0
amx_imessage_only_dead 0
// Ban times for the main ban menu (amx_banmenu) // Ban times for the main ban menu (amx_banmenu)
// Use 0 for permanent ban. // Use 0 for permanent ban.
// Default values: 0 5 10 15 30 45 60 // Default values: 0 5 10 15 30 45 60
@ -218,14 +238,3 @@ amx_idle_ignore_immunity 1
// //
// Default value: 4 // Default value: 4
amx_unstuck_frequency 4 amx_unstuck_frequency 4
// Performance monitor
//
// If function executed more than amx_perflog_ms milliseconds
// print plugin and function name to current amxmodx log file.
//
// Time in milliseconds
// Default value: 1.0
//
amx_perflog_ms 1.0

View File

@ -14,110 +14,133 @@
#include <amxmodx> #include <amxmodx>
#include <amxmisc> #include <amxmisc>
#define X_POS -1.0 const MAX_MSG_LEN = 384;
#define Y_POS 0.20 const TASK_MSG = 12345;
#define HOLD_TIME 12.0
new Array:g_Values enum _:MessageInfo
new Array:g_Messages {
new g_MessagesNum Message[MAX_MSG_LEN],
new g_Current R,
G,
B
}
new amx_freq_imessage; new Array:g_messages;
new g_messagesNum;
new g_hudObject;
new g_current;
new g_hostname[64];
new Float:g_amx_freq_imessage;
new Float:g_amx_imessage_x_pos;
new Float:g_amx_imessage_y_pos;
new Float:g_amx_imessage_holdtime;
new g_amx_imessage_only_dead;
public plugin_init() public plugin_init()
{ {
g_Messages=ArrayCreate(384); register_plugin("Info. Messages", AMXX_VERSION_STR, "AMXX Dev Team");
g_Values=ArrayCreate(3); register_srvcmd("amx_imessage", "setMessage", _, "<message> <color in RRRGGGBBB format>");
register_plugin("Info. Messages", AMXX_VERSION_STR, "AMXX Dev Team")
register_dictionary("imessage.txt")
register_dictionary("common.txt")
register_srvcmd("amx_imessage", "setMessage")
amx_freq_imessage=register_cvar("amx_freq_imessage", "10")
new lastinfo[8] register_dictionary("imessage.txt");
get_localinfo("lastinfomsg", lastinfo, charsmax(lastinfo)) register_dictionary("common.txt");
g_Current = str_to_num(lastinfo)
set_localinfo("lastinfomsg", "") g_messages = ArrayCreate(MessageInfo);
g_hudObject = CreateHudSyncObj();
bind_pcvar_num(create_cvar("amx_imessage_only_dead", "0", _, "Set to 1 to show info messages only to dead clients", true, 0.0, true, 1.0), g_amx_imessage_only_dead);
bind_pcvar_float(create_cvar("amx_freq_imessage", "180", _, "Frequency in seconds of info messages", true, 0.0), g_amx_freq_imessage);
bind_pcvar_float(create_cvar("amx_imessage_x_pos", "-1.0", _, "X position for info messages", true, -1.0, true, 1.0), g_amx_imessage_x_pos);
bind_pcvar_float(create_cvar("amx_imessage_y_pos", "0.2", _, "Y position for info messages", true, -1.0, true, 1.0), g_amx_imessage_y_pos);
bind_pcvar_float(create_cvar("amx_imessage_holdtime", "12.0", _, "Hold time for info messages", true, 0.0), g_amx_imessage_holdtime);
bind_pcvar_string(get_cvar_pointer("hostname"), g_hostname, charsmax(g_hostname));
new lastinfo[8];
get_localinfo("lastinfomsg", lastinfo, charsmax(lastinfo));
g_current = str_to_num(lastinfo);
set_localinfo("lastinfomsg", "");
} }
public infoMessage() public infoMessage()
{ {
if (g_Current >= g_MessagesNum)
g_Current = 0
// No messages, just get out of here // No messages, just get out of here
if (g_MessagesNum==0) if (!g_messagesNum)
{ {
return; return;
} }
new values[3]; // If the last message is reached, go back to the first one
new Message[384]; if (g_current >= g_messagesNum)
{
g_current = 0;
}
ArrayGetString(g_Messages, g_Current, Message, charsmax(Message)); static message[MessageInfo];
ArrayGetArray(g_Values, g_Current, values); ArrayGetArray(g_messages, g_current, message);
replace_stringex(message[Message], charsmax(message[Message]), "%hostname%", g_hostname);
new hostname[64]; set_hudmessage(message[R], message[G], message[B], g_amx_imessage_x_pos, g_amx_imessage_y_pos, 0, 0.5, g_amx_imessage_holdtime, 2.0, 2.0, -1);
get_cvar_string("hostname", hostname, charsmax(hostname)); if (g_amx_imessage_only_dead)
replace(Message, charsmax(Message), "%hostname%", hostname); {
new players[MAX_PLAYERS], pnum;
get_players_ex(players, pnum, GetPlayers_ExcludeAlive);
set_hudmessage(values[0], values[1], values[2], X_POS, Y_POS, 0, 0.5, HOLD_TIME, 2.0, 2.0, -1); for (new player, i; i < pnum; i++)
{
player = players[i];
show_hudmessage(0, "%s", Message); ShowSyncHudMsg(player, g_hudObject, message[Message]);
console_print(player, message[Message]);
}
}
else
{
ShowSyncHudMsg(0, g_hudObject, message[Message]);
console_print(0, message[Message]);
}
client_print(0, print_console, "%s", Message); g_current++;
++g_Current;
new Float:freq_im = get_pcvar_float(amx_freq_imessage); if (g_amx_freq_imessage > 0.0)
{
if (freq_im > 0.0) set_task(g_amx_freq_imessage, "infoMessage", TASK_MSG);
set_task(freq_im, "infoMessage", 12345); }
} }
public setMessage() public setMessage()
{ {
remove_task(TASK_MSG);
new Message[384]; static message[MessageInfo];
read_argv(1, message[Message], charsmax(message[Message]));
replace_string(message[Message], charsmax(message[Message]), "\n", "^n");
remove_task(12345) new fullcolor[10];
read_argv(1, Message, charsmax(Message)) read_argv(2, fullcolor, charsmax(fullcolor));
while (replace(Message, charsmax(Message), "\n", "^n")) {} message[B] = str_to_num(fullcolor[6]);
fullcolor[6] = 0;
new mycol[12] message[G] = str_to_num(fullcolor[3]);
new vals[3]; fullcolor[3] = 0;
read_argv(2, mycol, charsmax(mycol)) // RRRGGGBBB message[R] = str_to_num(fullcolor[0]);
vals[2] = str_to_num(mycol[6]) fullcolor[0] = 0;
mycol[6] = 0 g_messagesNum++;
vals[1] = str_to_num(mycol[3]) ArrayPushArray(g_messages, message);
mycol[3] = 0 if (g_amx_freq_imessage > 0.0)
vals[0] = str_to_num(mycol[0]) {
set_task(g_amx_freq_imessage, "infoMessage", TASK_MSG);
}
g_MessagesNum++ return PLUGIN_HANDLED;
new Float:freq_im = get_pcvar_float(amx_freq_imessage)
ArrayPushString(g_Messages, Message);
ArrayPushArray(g_Values, vals);
if (freq_im > 0.0)
set_task(freq_im, "infoMessage", 12345)
return PLUGIN_HANDLED
} }
public plugin_end() public plugin_end()
{ {
new lastinfo[8] ArrayDestroy(g_messages);
set_localinfo("lastinfomsg", fmt("%i", g_current));
num_to_str(g_Current, lastinfo, charsmax(lastinfo))
set_localinfo("lastinfomsg", lastinfo)
ArrayDestroy(g_Messages)
ArrayDestroy(g_Values)
} }