Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #pragma newdecls required
- #pragma semicolon 1
- #define PREFIX " \x0Cā¤ā¤ā¤\x0B"
- public Plugin myinfo =
- {
- name = "Rules plugin",
- author = "proobs",
- description = "simple plugin that reads motd.txt in the root csgo directory and prints it to chat every so often, with a command admins can use",
- version = "1.0",
- url = "https://github.com/proobs"
- };
- ConVar g_cvEnable = null;
- ConVar g_cvTime = null;
- Handle g_hTime;
- char g_cWebBuffer[256];
- public void OnPluginStart() {
- g_cvEnable = CreateConVar("sm_rules_enable", "1", "enable or disable rule chat thing");
- g_cvTime = CreateConVar("sm_rules_interval", "240.0", "float value in which we send the rules to everyone in chat every now and then");
- OpenMOTD();
- RegAdminCmd("sm_printrules", CMD_PrintRules, ADMFLAG_SLAY, "Prints rules link to client");
- }
- void OpenMOTD() {
- File yes = OpenFile("motd.txt", "r");
- yes.ReadString(g_cWebBuffer, sizeof(g_cWebBuffer), -1);
- yes.Close();
- }
- public void OnMapStart() {
- if(g_cvEnable.BoolValue) {
- g_hTime = CreateTimer(g_cvTime.FloatValue, timer_rulepost, _, TIMER_REPEAT);
- }
- }
- public void OnMapEnd() {
- KillTimer(g_hTime);
- }
- public Action timer_rulepost(Handle timer) {
- PrintToChatAll("%s Having trouble on the server? Read the rules at %s or press TAB and go to our servers web-page to view them!", PREFIX, g_cWebBuffer);
- }
- public Action CMD_PrintRules(int client, int args) {
- char arg1[32];
- GetCmdArg(1, arg1, sizeof(arg1));
- if(args < 1) {
- ReplyToCommand(client, "%s usage: sm_printrules <player>", PREFIX);
- return Plugin_Handled;
- }
- int target = FindTarget(client, arg1);
- if(target == -1) {
- return Plugin_Handled;
- }
- PrintToChat(target, "%s Hey %N, an admin has requested that you read the rules at: %s", PREFIX, target, g_cWebBuffer);
- return Plugin_Handled;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement