SHARE
TWEET

Untitled

a guest Aug 17th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <cstrike>
  5. #include <sdktools>
  6. #include <clientprefs>
  7. #include <store>
  8.  
  9. public Plugin myinfo =
  10. {
  11.     name = "HUDv2",
  12.     author = "xSLOW",
  13.     description = "Server Hud",
  14.     version = "1.4"
  15. };
  16.  
  17. enum {
  18.     RED = 0,
  19.     GREEN,
  20.     BLUE
  21. }
  22.  
  23. ConVar g_cvarMessage1;
  24. ConVar g_cvarMessage2;
  25. ConVar g_cvarMessage3;
  26. ConVar g_cvarSlots;
  27. ConVar g_cvarHUDColors;
  28.  
  29. Handle g_hHUDv2Cookie;
  30. bool g_bIsHudEnabled[MAXPLAYERS + 1];
  31. int g_iHUDColors[3];
  32.  
  33.  
  34. public void OnPluginStart()
  35. {
  36.     g_hHUDv2Cookie = RegClientCookie("HudCookie_V2", "HudCookie_V2", CookieAccess_Protected);
  37.  
  38.     g_cvarMessage1 = CreateConVar("sm_hud_message1", "Forum: OneFrag.pl", "Top-Left first message", FCVAR_NOTIFY);
  39.     g_cvarMessage2 = CreateConVar("sm_hud_message2", "TS3: OneFrag.pl", "Top-Left second message", FCVAR_NOTIFY);
  40.     g_cvarMessage3 = CreateConVar("sm_hud_message3", "Wpisz /sklepsms aby kupic Vipa", "Top-Mid third message", FCVAR_NOTIFY);
  41.     g_cvarSlots = CreateConVar("sm_hud_slots", "13", "Number of server's slots", FCVAR_NOTIFY);
  42.     g_cvarHUDColors = CreateConVar("sm_hud_rgb", "230,57,0", "RGB of the text. You can get more colors from https://www.hexcolortool.com/", FCVAR_NOTIFY);
  43.  
  44.     AutoExecConfig(true, "HUDv2");
  45.     CreateTimer(1.0, CreditsTimer, GetClientUserId(client), TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  46.     UpdateHUDColor();
  47.     g_cvarHUDColors.AddChangeHook(cvarChanged_HUDColor);
  48.     RegConsoleCmd("hud", Command_hud);
  49. }
  50.  
  51. public void OnClientPutInServer(int client)
  52. {
  53.     g_bIsHudEnabled[client] = true;
  54.     char buffer[64];
  55.     GetClientCookie(client, g_hHUDv2Cookie, buffer, sizeof(buffer));
  56.     if(StrEqual(buffer,"0"))
  57.         g_bIsHudEnabled[client] = false;
  58. }
  59.  
  60. public void cvarChanged_HUDColor(ConVar convar, const char[] oldValue, const char[] newValue) {
  61.     UpdateHUDColor();
  62. }
  63.  
  64. public Action Command_hud(int client, int args)
  65. {
  66.     if(g_bIsHudEnabled[client])
  67.     {
  68.         PrintToChat(client, " ★ \x02HUD pomyslnie wylaczony");
  69.         g_bIsHudEnabled[client] = false;
  70.         SetClientCookie(client, g_hHUDv2Cookie, "0");
  71.     }
  72.     else
  73.     {
  74.         PrintToChat(client, " ★ \x04HUD pomyslnie wlaczony");
  75.         g_bIsHudEnabled[client] = true;
  76.         SetClientCookie(client, g_hHUDv2Cookie, "1");
  77.     }
  78. }
  79.  
  80. public Action CreditsTimer(Handle timer, any userid)
  81. {
  82.     int client = GetClientOfUserId(userid);
  83.     int clientCount = 0, iTimeleft;
  84.     char sTime[64], szTime[30], iMessage1[32], iMessage2[32], iMessage3[32], MapTimeLeft[128];
  85.  
  86.     for (int i = 1; i <= MaxClients; i++)
  87.     {
  88.         if (IsClientInGame(i) && !IsFakeClient(i))
  89.             ++clientCount;
  90.     }
  91.  
  92.     g_cvarMessage1.GetString(iMessage1, sizeof(iMessage1));
  93.     g_cvarMessage2.GetString(iMessage2, sizeof(iMessage2));
  94.     g_cvarMessage3.GetString(iMessage3, sizeof(iMessage3));
  95.  
  96.     GetMapTimeLeft(iTimeleft);
  97.     FormatTime(szTime, sizeof(szTime), "%H:%M:%S", GetTime());
  98.     FormatTime(sTime, sizeof(sTime), "%M:%S", iTimeleft);
  99.  
  100.     for(int i = 1; i <= MaxClients; i++)
  101.     {
  102.         if(g_bIsHudEnabled[i] && IsValidClient(i))
  103.         {
  104.             char iBuffer[1024];
  105.             if(!(iTimeleft > 0))
  106.                 Format(MapTimeLeft,sizeof(MapTimeLeft), "Last Round");
  107.             else
  108.                 Format(MapTimeLeft,sizeof(MapTimeLeft), "%s", sTime);
  109.  
  110.             Format(iBuffer, sizeof(iBuffer),"%s\n%s\nGraczy: %d/%d\nPozostalo: %s\nGodzina: %s\nKredyty: %i\nPrędkość:%.2f",iMessage1, iMessage2, clientCount, g_cvarSlots.IntValue, MapTimeLeft, szTime, Store_GetClientCredits(client), GetPlayerSpeed(client));
  111.             SetHudTextParams(0.0, 0.0, 0.9, g_iHUDColors[RED], g_iHUDColors[GREEN], g_iHUDColors[BLUE], 255, 0, 0.0, 0.0, 0.0);  
  112.             ShowHudText(i, -1, iBuffer);  
  113.  
  114.             SetHudTextParams(-1.0, 0.075, 0.9, g_iHUDColors[RED], g_iHUDColors[GREEN], g_iHUDColors[BLUE], 255, 0, 0.0, 0.0, 0.0);  
  115.             ShowHudText(i, -1, iMessage3);  
  116.         }
  117.     }
  118. }
  119.  
  120. float GetPlayerSpeed(int client)
  121. {
  122.     float faVelocity[3];
  123.     GetEntPropVector(client, Prop_Data, "m_vecVelocity", faVelocity);
  124.    
  125.     float fSpeed;
  126.     fSpeed = SquareRoot(faVelocity[0] * faVelocity[0] + faVelocity[1] * faVelocity[1]);
  127.     fSpeed *= GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue");
  128.    
  129.     return fSpeed;
  130. }
  131.  
  132.  
  133. stock bool IsValidClient(client, bool nobots = true)
  134. {
  135.     if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
  136.     {
  137.         return false;
  138.     }
  139.     return IsClientInGame(client);
  140. }
  141.  
  142. void UpdateHUDColor() {
  143.     char buffer[16];
  144.     g_cvarHUDColors.GetString(buffer, sizeof(buffer));
  145.  
  146.     char buffer2[3][4];
  147.     ExplodeString(buffer, ",", buffer2, sizeof(buffer2), sizeof(buffer2[]));
  148.    
  149.     for (int i = 0; i < 3; i++) {
  150.         g_iHUDColors[i] = StringToInt(buffer2[i]);
  151.     }
  152. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top