new plugin: spam notifications
This commit is contained in:
parent
75fb3b22f5
commit
549f8b4032
101
SpamNotification/scripting/SpamNotification.sp
Normal file
101
SpamNotification/scripting/SpamNotification.sp
Normal file
@ -0,0 +1,101 @@
|
||||
#pragma semicolon 1
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
/*#include <zombiereloaded>
|
||||
#include <cstrike>
|
||||
#include <ccc>
|
||||
#include <multicolors>*/
|
||||
|
||||
ConVar g_cMessagePosition;
|
||||
ConVar g_cMessageColor;
|
||||
ConVar g_cMessageCooldown;
|
||||
ConVar g_cMessageText;
|
||||
|
||||
float MessagePos[2];
|
||||
int MessageColor[3];
|
||||
Handle MessageTimer;
|
||||
Handle MessageSync;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "SpamNotification",
|
||||
author = "Dogan",
|
||||
description = "Provide the server with important informations/advertisements",
|
||||
version = "1.0.0",
|
||||
url = ""
|
||||
}
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
g_cMessagePosition = CreateConVar("sm_message_position", "-1.0 0.8", "The x and y positions for the message");
|
||||
g_cMessageColor = CreateConVar("sm_message_color", "0 255 0", "RGB color value for the message");
|
||||
g_cMessageCooldown = CreateConVar("sm_message_cooldown", "120", "Cooldown of the message in seconds");
|
||||
g_cMessageText = CreateConVar("sm_message_text", "UNLOZE Christmas Sale: 25'%' on all VIP Offers. Check www.unloze.com for more info", "text thats shown at the message");
|
||||
|
||||
g_cMessagePosition.AddChangeHook(ConVarChange);
|
||||
g_cMessageColor.AddChangeHook(ConVarChange);
|
||||
g_cMessageCooldown.AddChangeHook(ConVarChange);
|
||||
|
||||
MessageSync = CreateHudSynchronizer();
|
||||
|
||||
AutoExecConfig(true, "plugin.SpamNotification");
|
||||
GetConVars();
|
||||
}
|
||||
|
||||
public void ColorStringToArray(const char[] sColorString, int aColor[3])
|
||||
{
|
||||
char asColors[4][4];
|
||||
ExplodeString(sColorString, " ", asColors, sizeof(asColors), sizeof(asColors[]));
|
||||
|
||||
aColor[0] = StringToInt(asColors[0]);
|
||||
aColor[1] = StringToInt(asColors[1]);
|
||||
aColor[2] = StringToInt(asColors[2]);
|
||||
}
|
||||
|
||||
public void GetConVars()
|
||||
{
|
||||
char StringPos[2][8];
|
||||
char PosValue[16];
|
||||
g_cMessagePosition.GetString(PosValue, sizeof(PosValue));
|
||||
ExplodeString(PosValue, " ", StringPos, sizeof(StringPos), sizeof(StringPos[]));
|
||||
|
||||
MessagePos[0] = StringToFloat(StringPos[0]);
|
||||
MessagePos[1] = StringToFloat(StringPos[1]);
|
||||
|
||||
char ColorValue[64];
|
||||
g_cMessageColor.GetString(ColorValue, sizeof(ColorValue));
|
||||
|
||||
ColorStringToArray(ColorValue, MessageColor);
|
||||
|
||||
char MessageValue[512];
|
||||
g_cMessageText.GetString(MessageValue, sizeof(MessageValue));
|
||||
|
||||
if (MessageTimer != INVALID_HANDLE && CloseHandle(MessageTimer))
|
||||
MessageTimer = INVALID_HANDLE;
|
||||
|
||||
MessageTimer = CreateTimer(g_cMessageCooldown.FloatValue, TimerCooldown, _, TIMER_REPEAT);
|
||||
}
|
||||
|
||||
public void ConVarChange(ConVar convar, char[] oldValue, char[] newValue)
|
||||
{
|
||||
GetConVars();
|
||||
}
|
||||
|
||||
public void SendMessage()
|
||||
{
|
||||
SetHudTextParams(MessagePos[0], MessagePos[1], 5.0, MessageColor[0], MessageColor[1], MessageColor[2], 255, 1, 3.0, 0.4, 0.4);
|
||||
|
||||
for (int client = 1; client <= MAXPLAYERS; client++)
|
||||
{
|
||||
if (IsClientConnected(client))
|
||||
{
|
||||
ShowSyncHudText(client, MessageSync, g_cMessageText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action TimerCooldown(Handle timer)
|
||||
{
|
||||
SendMessage();
|
||||
}
|
Loading…
Reference in New Issue
Block a user