michaelrw

advert plugin

Jan 25th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.50 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #define DEBUG
  4.  
  5. #define PLUGIN_AUTHOR "codingcow"
  6. #define PLUGIN_VERSION "1.01"
  7.  
  8. #include <sourcemod>
  9. #include <sdktools>
  10.  
  11. public Plugin myinfo =
  12. {
  13.     name = "abstract-eventAdvert",
  14.     author = PLUGIN_AUTHOR,
  15.     description = "",
  16.     version = PLUGIN_VERSION,
  17.     url = ""
  18. }
  19. #pragma newdecls required
  20.  
  21. ConVar g_cbEnable = null;
  22. ConVar g_csMsg = null;
  23. ConVar g_cfTimerPeriod = null;
  24. ConVar g_cfXPos = null;
  25. ConVar g_cfYPos = null;
  26. ConVar g_cfMsgHoldTime = null;
  27. ConVar g_ciRed = null;
  28. ConVar g_ciGreen = null;
  29. ConVar g_ciBlue = null;
  30. ConVar g_ciAlpha = null;
  31.  
  32. public void OnPluginStart()
  33. {
  34. //  RegAdminCmd("sm_showmsg", Command_Showmsg, ADMFLAG_ROOT, "Message displayed");
  35.  
  36.     g_cbEnable = CreateConVar("advert_hudmsg_enable", "1", "Enable or disable the hud message from being displayed", 0, true, 0.0, true, 1.0);
  37.     g_csMsg = CreateConVar("advert_hudmsg", "Advert Hud Message Default", "This is the message you would like displayed", _);
  38.     g_cfTimerPeriod = CreateConVar("advert_hudmsg_period", "300", "How often to display the hud message", _, true, 1.0, true, 999.0);
  39.     g_cfXPos = CreateConVar("advert_hudmsg_x", "-1.0", "x-axis position", _, true, -1.0, true, 1.0);
  40.     g_cfYPos = CreateConVar("advert_hudmsg_y", "0.10", "y-axis position", _, true, -1.0, true, 1.0);
  41.     g_cfMsgHoldTime = CreateConVar("advert_hudmsg_time", "10", "how long to display the center hud message", _, true, 0.0);
  42.     g_ciRed = CreateConVar("advert_hudmsg_r", "0", "red color", _, true, 0.0, true, 255.0);
  43.     g_ciGreen = CreateConVar("advert_hudmsg_g", "190", "green color", _, true, 0.0, true, 255.0);
  44.     g_ciBlue = CreateConVar("advert_hudmsg_b", "255", "blue color", _, true, 0.0, true, 255.0);
  45.     g_ciAlpha = CreateConVar("advert_hudmsg_alpha", "225", "transparancy value", _, true, 0.0, true, 255.0);
  46.  
  47.     AutoExecConfig(true, "hud-adverts");
  48.  
  49.     CreateTimer(g_cfTimerPeriod.FloatValue, doPrint, _, TIMER_REPEAT);
  50. }
  51.  
  52. public Action doPrint(Handle timer)
  53. {
  54.     if(g_cbEnable.BoolValue)
  55.     {
  56.         char sMsg[256];
  57.         g_csMsg.GetString(sMsg, sizeof(sMsg));
  58.  
  59.         SetHudTextParams(g_cfXPos.FloatValue, g_cfYPos.FloatValue, g_cfMsgHoldTime.FloatValue, g_ciRed.IntValue, g_ciGreen.IntValue, g_ciBlue.IntValue, g_ciAlpha.IntValue);
  60.        
  61.  
  62.         for (int i = 1; i <= MaxClients; i++)
  63.         {
  64.             if (IsClientInGame(i) && !IsFakeClient(i))
  65.             {
  66.                 ShowHudText(i, 6, sMsg); //int ShowHudText(int client, int channel, const char[] message, any ...)
  67.             }
  68.         }
  69.     }
  70. }
  71. /*
  72. public Action:Command_Showmsg(client, args)
  73. {
  74.     doPrint();
  75.     return  Plugin_Handled;
  76. }
  77. */
Advertisement
Add Comment
Please, Sign In to add comment