2014-08-04 16:12:15 +04: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 23:56:22 +03:00
|
|
|
|
2004-03-05 22:35:38 +03:00
|
|
|
#include <amxmodx>
|
2004-03-07 17:30:53 +03:00
|
|
|
#include <amxmisc>
|
2004-01-31 23:56:22 +03:00
|
|
|
|
|
|
|
#define SPEED 0.3
|
2006-04-11 10:30:59 +04:00
|
|
|
#define SCROLLMSG_SIZE 512
|
2004-01-31 23:56:22 +03:00
|
|
|
|
|
|
|
new g_startPos
|
|
|
|
new g_endPos
|
2006-04-11 10:30:59 +04:00
|
|
|
new g_scrollMsg[SCROLLMSG_SIZE]
|
|
|
|
new g_displayMsg[SCROLLMSG_SIZE]
|
2004-01-31 23:56:22 +03:00
|
|
|
new Float:g_xPos
|
|
|
|
new g_Length
|
|
|
|
new g_Frequency
|
|
|
|
|
2005-09-13 01:06:24 +04:00
|
|
|
public plugin_init()
|
|
|
|
{
|
|
|
|
register_plugin("Scrolling Message", AMXX_VERSION_STR, "AMXX Dev Team")
|
|
|
|
register_dictionary("scrollmsg.txt")
|
|
|
|
register_dictionary("common.txt")
|
|
|
|
register_srvcmd("amx_scrollmsg", "setMessage")
|
2004-01-31 23:56:22 +03:00
|
|
|
}
|
|
|
|
|
2005-09-13 01:06:24 +04:00
|
|
|
public showMsg()
|
|
|
|
{
|
|
|
|
new a = g_startPos, i = 0
|
2004-08-06 22:40:41 +04:00
|
|
|
|
2005-09-13 01:06:24 +04:00
|
|
|
while (a < g_endPos)
|
|
|
|
g_displayMsg[i++] = g_scrollMsg[a++]
|
2004-08-06 22:40:41 +04:00
|
|
|
|
2005-09-13 01:06:24 +04:00
|
|
|
g_displayMsg[i] = 0
|
2004-08-06 22:40:41 +04:00
|
|
|
|
2005-09-13 01:06:24 +04:00
|
|
|
if (g_endPos < g_Length)
|
|
|
|
g_endPos++
|
2004-08-06 22:40:41 +04:00
|
|
|
|
2005-09-13 01:06:24 +04:00
|
|
|
if (g_xPos > 0.35)
|
|
|
|
g_xPos -= 0.0063
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_startPos++
|
|
|
|
g_xPos = 0.35
|
|
|
|
}
|
2004-08-06 22:40:41 +04:00
|
|
|
|
2006-03-13 17:37:23 +03:00
|
|
|
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2)
|
2005-11-21 23:31:18 +03:00
|
|
|
show_hudmessage(0, "%s", g_displayMsg)
|
2004-01-31 23:56:22 +03:00
|
|
|
}
|
|
|
|
|
2005-09-13 01:06:24 +04:00
|
|
|
public msgInit()
|
|
|
|
{
|
|
|
|
g_endPos = 1
|
|
|
|
g_startPos = 0
|
|
|
|
g_xPos = 0.65
|
|
|
|
|
2006-04-25 11:35:02 +04:00
|
|
|
new hostname[64]
|
|
|
|
|
2014-07-29 18:32:32 +04:00
|
|
|
get_cvar_string("hostname", hostname, charsmax(hostname))
|
|
|
|
replace(g_scrollMsg, charsmax(g_scrollMsg), "%hostname%", hostname)
|
2006-04-25 11:35:02 +04:00
|
|
|
|
|
|
|
g_Length = strlen(g_scrollMsg)
|
|
|
|
|
2005-09-13 01:06:24 +04:00
|
|
|
set_task(SPEED, "showMsg", 123, "", 0, "a", g_Length + 48)
|
2005-11-21 23:31:18 +03:00
|
|
|
client_print(0, print_console, "%s", g_scrollMsg)
|
2004-01-31 23:56:22 +03:00
|
|
|
}
|
|
|
|
|
2005-09-13 01:06:24 +04:00
|
|
|
public setMessage()
|
|
|
|
{
|
|
|
|
remove_task(123) /* remove current messaging */
|
2014-07-29 18:32:32 +04:00
|
|
|
read_argv(1, g_scrollMsg, charsmax(g_scrollMsg))
|
2005-09-13 01:06:24 +04:00
|
|
|
|
|
|
|
g_Length = strlen(g_scrollMsg)
|
|
|
|
|
|
|
|
new mytime[32]
|
|
|
|
|
2014-07-29 18:32:32 +04:00
|
|
|
read_argv(2, mytime, charsmax(mytime))
|
2005-09-13 01:06:24 +04:00
|
|
|
|
|
|
|
g_Frequency = str_to_num(mytime)
|
|
|
|
|
|
|
|
if (g_Frequency > 0)
|
|
|
|
{
|
|
|
|
new minimal = floatround((g_Length + 48) * (SPEED + 0.1))
|
|
|
|
|
|
|
|
if (g_Frequency < minimal)
|
|
|
|
{
|
|
|
|
server_print("%L", LANG_SERVER, "MIN_FREQ", minimal)
|
|
|
|
g_Frequency = minimal
|
|
|
|
}
|
|
|
|
|
|
|
|
server_print("%L", LANG_SERVER, "MSG_FREQ", g_Frequency / 60, g_Frequency % 60)
|
|
|
|
set_task(float(g_Frequency), "msgInit", 123, "", 0, "b")
|
|
|
|
}
|
|
|
|
else
|
|
|
|
server_print("%L", LANG_SERVER, "MSG_DISABLED")
|
|
|
|
|
|
|
|
return PLUGIN_HANDLED
|
2004-08-22 08:25:55 +04:00
|
|
|
}
|