Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool gB_Hide[MAXPLAYERS+1];
- // -- from include/shavit.inc --
- // stock bool IsValidClient(int client, bool bAlive = false)
- // {
- // return (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsClientSourceTV(client) && (!bAlive || IsPlayerAlive(client)));
- // }
- public void OnPluginStart()
- {
- // hide
- RegConsoleCmd("sm_hide", Command_Hide, "Toggle players' hiding.");
- RegConsoleCmd("sm_unhide", Command_Hide, "Toggle players' hiding.");
- gH_HideCookie = RegClientCookie("shavit_hide", "Hide settings", CookieAccess_Protected);
- }
- public Action Command_Hide(int client, int args)
- {
- if(!IsValidClient(client))
- {
- return Plugin_Handled;
- }
- gB_Hide[client] = !gB_Hide[client];
- UpdateFootsteps(client);
- char[] sCookie = new char[4]; // creating a 4 character string for the player's cookie
- IntToString(view_as<int>(gB_Hide[client]), sCookie, 4); //int IntToString(int num, char[] str, int maxlength)
- SetClientCookie(client, gH_HideCookie, sCookie); // clientprefs function to set gH_HideCookie (shavit_hide) in the database
- if(gB_Hide[client])
- {
- Shavit_PrintToChat(client, "%T", "HideEnabled", client, gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
- }
- else
- {
- Shavit_PrintToChat(client, "%T", "HideDisabled", client, gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText]);
- }
- return Plugin_Handled;
- }
- void UpdateFootsteps(int client)
- {
- if(sv_footsteps != null)
- {
- char[] sFootsteps = new char[4];
- IntToString((gB_Hide[client])? 0:sv_footsteps.IntValue, sFootsteps, 4);
- sv_footsteps.ReplicateToClient(client, sFootsteps);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment