michaelrw

shavit sm_hide mute players, for bTimes

Dec 16th, 2017
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.64 KB | None | 0 0
  1. bool gB_Hide[MAXPLAYERS+1];
  2.  
  3. // -- from include/shavit.inc --
  4.  
  5. //  stock bool IsValidClient(int client, bool bAlive = false)
  6. //  {
  7. //      return (client >= 1 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && !IsClientSourceTV(client) && (!bAlive || IsPlayerAlive(client)));
  8. //  }
  9.  
  10.  
  11. public void OnPluginStart()
  12. {
  13.     // hide
  14.     RegConsoleCmd("sm_hide", Command_Hide, "Toggle players' hiding.");
  15.     RegConsoleCmd("sm_unhide", Command_Hide, "Toggle players' hiding.");
  16.     gH_HideCookie = RegClientCookie("shavit_hide", "Hide settings", CookieAccess_Protected);
  17. }
  18.  
  19.  
  20. public Action Command_Hide(int client, int args)
  21. {
  22.     if(!IsValidClient(client))
  23.     {
  24.         return Plugin_Handled;
  25.     }
  26.  
  27.     gB_Hide[client] = !gB_Hide[client];
  28.     UpdateFootsteps(client);
  29.  
  30.     char[] sCookie = new char[4]; // creating a 4 character string for the player's cookie
  31.     IntToString(view_as<int>(gB_Hide[client]), sCookie, 4); //int IntToString(int num, char[] str, int maxlength)
  32.     SetClientCookie(client, gH_HideCookie, sCookie); // clientprefs function to set gH_HideCookie (shavit_hide) in the database
  33.  
  34.     if(gB_Hide[client])
  35.     {
  36.         Shavit_PrintToChat(client, "%T", "HideEnabled", client, gS_ChatStrings[sMessageVariable], gS_ChatStrings[sMessageText]);
  37.     }
  38.  
  39.     else
  40.     {
  41.         Shavit_PrintToChat(client, "%T", "HideDisabled", client, gS_ChatStrings[sMessageWarning], gS_ChatStrings[sMessageText]);
  42.     }
  43.  
  44.     return Plugin_Handled;
  45. }
  46.  
  47. void UpdateFootsteps(int client)
  48. {
  49.     if(sv_footsteps != null)
  50.     {
  51.         char[] sFootsteps = new char[4];
  52.         IntToString((gB_Hide[client])? 0:sv_footsteps.IntValue, sFootsteps, 4);
  53.         sv_footsteps.ReplicateToClient(client, sFootsteps);
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment