Advertisement
proobs

Untitled

Jul 23rd, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. #include <sourcemod>
  2.  
  3. #pragma newdecls required
  4. #pragma semicolon 1
  5.  
  6. #define PREFIX " \x0Cāž¤āž¤āž¤\x0B"
  7.  
  8. public Plugin myinfo =
  9. {
  10.     name = "Rules plugin",
  11.     author = "proobs",
  12.     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",
  13.     version = "1.0",
  14.     url = "https://github.com/proobs"
  15. };
  16.  
  17. ConVar g_cvEnable = null;
  18. ConVar g_cvTime = null;
  19.  
  20. Handle g_hTime;
  21.  
  22. char g_cWebBuffer[256];
  23.  
  24. public void OnPluginStart() {
  25.     g_cvEnable = CreateConVar("sm_rules_enable", "1", "enable or disable rule chat thing");
  26.     g_cvTime = CreateConVar("sm_rules_interval", "240.0", "float value in which we send the rules to everyone in chat every now and then");
  27.    
  28.     OpenMOTD();
  29.    
  30.     RegAdminCmd("sm_printrules", CMD_PrintRules, ADMFLAG_SLAY, "Prints rules link to client");
  31. }
  32.  
  33. void OpenMOTD() {
  34.     File yes = OpenFile("motd.txt", "r");
  35.     yes.ReadString(g_cWebBuffer, sizeof(g_cWebBuffer), -1);
  36.     yes.Close();
  37. }
  38.  
  39. public void OnMapStart() {
  40.     if(g_cvEnable.BoolValue) {
  41.         g_hTime = CreateTimer(g_cvTime.FloatValue, timer_rulepost, _, TIMER_REPEAT);
  42.     }
  43. }
  44. public void OnMapEnd() {
  45.     KillTimer(g_hTime);
  46. }
  47.  
  48. public Action timer_rulepost(Handle timer) {
  49.     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);
  50. }
  51.  
  52. public Action CMD_PrintRules(int client, int args) {
  53.     char arg1[32];
  54.     GetCmdArg(1, arg1, sizeof(arg1));
  55.     if(args < 1) {
  56.         ReplyToCommand(client, "%s usage: sm_printrules <player>", PREFIX);
  57.         return Plugin_Handled;
  58.     }
  59.    
  60.     int target = FindTarget(client, arg1);
  61.     if(target == -1) {
  62.         return Plugin_Handled;
  63.     }
  64.    
  65.     PrintToChat(target, "%s Hey %N, an admin has requested that you read the rules at: %s", PREFIX, target, g_cWebBuffer);
  66.     return Plugin_Handled;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement