Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <cstrike>
- #include <sdkhooks>
- bool Whitelisted[MAXPLAYERS + 1];
- public Plugin myinfo =
- {
- name = "Whitelist",
- author = "cra88y",
- version = "6.9",
- };
- public void OnPluginStart()
- {
- AddCommandListener(OnTeamJoin, "jointeam");
- RegConsoleCmd("sm_wclear", wClear, "Removes all added players.");
- RegConsoleCmd("sm_wadd", wAdd, "Adds a player to the whitelist.");
- RegConsoleCmd("sm_wremove", wRemove, "Removes player from the whitelist.");
- }
- public void OnClientPutInServer(int client)
- {
- Whitelisted[client] = false;
- }
- public Action OnTeamJoin(Client, const String:Command[], ArgumentsCount)
- {
- if (Client < 1 || Client > MaxClients || !IsClientInGame(Client) || ArgumentsCount < 1)
- {
- return Plugin_Handled;
- }
- char chTeam[5];
- GetCmdArgString(chTeam, sizeof(chTeam));
- int iChTeam = StringToInt(chTeam);
- if (iChTeam == CS_TEAM_SPECTATOR)
- {
- return Plugin_Continue;
- }
- if (Whitelisted[Client] == true)
- {
- CS_SwitchTeam(Client, iChTeam);
- PrintToConsole(Client, "%i was allowed to join team", Client);
- return Plugin_Stop;
- }
- else
- {
- CS_SwitchTeam(Client, 1);
- PrintToChat(Client, "/x02You are not whitelisted!");
- return Plugin_Stop;
- }
- }
- public Action wAdd(int client, int args)
- {
- if (args < 1)
- {
- ReplyToCommand(client, "[Whitelist] Usage: sm_wadd <name>");
- return Plugin_Handled;
- }
- char arg[65];
- GetCmdArg(1, arg, sizeof(arg));
- int target = FindTarget(client, arg);
- if (target == -1)
- {
- return Plugin_Handled;
- }
- Whitelisted[target] = false;
- PrintToConsole(client, "Whitelisted %i", target);
- return Plugin_Handled;
- }
- public Action wRemove(int client, int args)
- {
- if (args < 1)
- {
- ReplyToCommand(client, "[Whitelist] Usage: sm_wremove <name>");
- return Plugin_Handled;
- }
- char arg[65];
- GetCmdArg(1, arg, sizeof(arg));
- int target = FindTarget(client, arg);
- if (target == -1)
- {
- return Plugin_Handled;
- }
- Whitelisted[target] = false;
- PrintToConsole(client, "%i removed from whitelist", target);
- return Plugin_Handled;
- }
- public Action wClear(int client, int args)
- {
- for (new x = 1; x < MaxClients; x++)
- {
- if (IsClientInGame(x) && !IsFakeClient(x))
- {
- Whitelisted[x] = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement