Add cvars

This commit is contained in:
OciXCrom 2018-09-13 15:13:19 +02:00
parent f6fc2336b4
commit 199daad295

View File

@ -14,8 +14,16 @@
#include <amxmodx> #include <amxmodx>
#include <amxmisc> #include <amxmisc>
#define SPEED 0.3 #define SCROLLMSG_SIZE 512
#define SCROLLMSG_SIZE 512
new g_amx_scrollmsg_color_red;
new g_amx_scrollmsg_color_green;
new g_amx_scrollmsg_color_blue;
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_startPos; new g_startPos;
new g_endPos; new g_endPos;
@ -28,9 +36,19 @@ new g_Frequency;
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("scrollmsg.txt");
register_dictionary("common.txt"); register_dictionary("common.txt");
register_srvcmd("amx_scrollmsg", "setMessage"); register_srvcmd("amx_scrollmsg", "setMessage");
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_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);
} }
public showMsg() public showMsg()
@ -49,17 +67,17 @@ public showMsg()
g_endPos++; g_endPos++;
} }
if (g_xPos > 0.35) if (g_xPos > g_amx_scrollmsg_x_start_pos)
{ {
g_xPos -= 0.0063; g_xPos -= g_amx_scrollmsg_x_move_amount;
} }
else else
{ {
g_startPos++; g_startPos++;
g_xPos = 0.35; g_xPos = g_amx_scrollmsg_x_start_pos;
} }
set_hudmessage(200, 100, 0, g_xPos, 0.90, 0, SPEED, SPEED, 0.05, 0.05, 2); set_hudmessage(g_amx_scrollmsg_color_red, g_amx_scrollmsg_color_green, g_amx_scrollmsg_color_blue, g_xPos, g_amx_scrollmsg_y_pos, 0, g_amx_scrollmsg_speed, g_amx_scrollmsg_speed, 0.05, 0.05, 2);
show_hudmessage(0, "%s", g_displayMsg); show_hudmessage(0, "%s", g_displayMsg);
} }
@ -67,7 +85,7 @@ public msgInit()
{ {
g_endPos = 1; g_endPos = 1;
g_startPos = 0; g_startPos = 0;
g_xPos = 0.65; g_xPos = g_amx_scrollmsg_x_end_pos;
new hostname[64]; new hostname[64];
@ -76,7 +94,7 @@ public msgInit()
g_Length = strlen(g_scrollMsg); g_Length = strlen(g_scrollMsg);
set_task(SPEED, "showMsg", 123, "", 0, "a", g_Length + 48); set_task(g_amx_scrollmsg_speed, "showMsg", 123, "", 0, "a", g_Length + 48);
client_print(0, print_console, "%s", g_scrollMsg); client_print(0, print_console, "%s", g_scrollMsg);
} }
@ -95,7 +113,7 @@ public setMessage()
if (g_Frequency > 0) 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)
{ {