Advertisement
Guest User

asdf

a guest
Jan 16th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <cstrike>
  4. #include <sdkhooks>
  5.  
  6. bool Whitelisted[MAXPLAYERS + 1];
  7. public Plugin myinfo =
  8. {
  9. name = "Whitelist",
  10. author = "cra88y",
  11. version = "6.9",
  12. };
  13.  
  14. public void OnPluginStart()
  15. {
  16. AddCommandListener(OnTeamJoin, "jointeam");
  17. RegConsoleCmd("sm_wclear", wClear, "Removes all added players.");
  18. RegConsoleCmd("sm_wadd", wAdd, "Adds a player to the whitelist.");
  19. RegConsoleCmd("sm_wremove", wRemove, "Removes player from the whitelist.");
  20. }
  21. public void OnClientPutInServer(int client)
  22. {
  23. Whitelisted[client] = false;
  24. }
  25. public Action OnTeamJoin(Client, const String:Command[], ArgumentsCount)
  26. {
  27. if (Client < 1 || Client > MaxClients || !IsClientInGame(Client) || ArgumentsCount < 1)
  28. {
  29. return Plugin_Handled;
  30. }
  31. char chTeam[5];
  32. GetCmdArgString(chTeam, sizeof(chTeam));
  33.  
  34. int iChTeam = StringToInt(chTeam);
  35.  
  36. if (iChTeam == CS_TEAM_SPECTATOR)
  37. {
  38. return Plugin_Continue;
  39. }
  40. if (Whitelisted[Client] == true)
  41. {
  42. CS_SwitchTeam(Client, iChTeam);
  43. PrintToConsole(Client, "%i was allowed to join team", Client);
  44. return Plugin_Stop;
  45.  
  46. }
  47. else
  48. {
  49. CS_SwitchTeam(Client, 1);
  50. PrintToChat(Client, "/x02You are not whitelisted!");
  51. return Plugin_Stop;
  52. }
  53. }
  54. public Action wAdd(int client, int args)
  55. {
  56. if (args < 1)
  57. {
  58. ReplyToCommand(client, "[Whitelist] Usage: sm_wadd <name>");
  59. return Plugin_Handled;
  60. }
  61. char arg[65];
  62. GetCmdArg(1, arg, sizeof(arg));
  63.  
  64. int target = FindTarget(client, arg);
  65.  
  66. if (target == -1)
  67. {
  68. return Plugin_Handled;
  69. }
  70.  
  71. Whitelisted[target] = false;
  72.  
  73. PrintToConsole(client, "Whitelisted %i", target);
  74. return Plugin_Handled;
  75. }
  76. public Action wRemove(int client, int args)
  77. {
  78. if (args < 1)
  79. {
  80. ReplyToCommand(client, "[Whitelist] Usage: sm_wremove <name>");
  81. return Plugin_Handled;
  82. }
  83. char arg[65];
  84. GetCmdArg(1, arg, sizeof(arg));
  85.  
  86. int target = FindTarget(client, arg);
  87.  
  88. if (target == -1)
  89. {
  90. return Plugin_Handled;
  91. }
  92.  
  93. Whitelisted[target] = false;
  94.  
  95. PrintToConsole(client, "%i removed from whitelist", target);
  96. return Plugin_Handled;
  97. }
  98.  
  99. public Action wClear(int client, int args)
  100. {
  101. for (new x = 1; x < MaxClients; x++)
  102. {
  103. if (IsClientInGame(x) && !IsFakeClient(x))
  104. {
  105. Whitelisted[x] = false;
  106. }
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement