01-06-2012, 19:20
Features:
This plugin allows server admins to have control over who can use which commands. For example, you can only allow admins to play with 90 fov*, or let moderators only see their ping**.
Why?:
It's annoying for server admins to have to set up xuids in every plugin. And this allows moderators, helpers and even donators to get some more features then a normal player. (It works the same way in Minecraft with Bukkit)
Requirements:
@Nukem's dedicated server addon 1.190+
Changelog:
v1.0 BETA: initial release
v1.1 BETA: Updated to .NET 3.0 (Linux support). Now requires addon 1.190+
Usage (for players):
Usage (For server admins):
Put aaaPermissionPlugin.dll in your servers /plugin/ folder (NOTE: DO NOT RENAME THE PLUGIN!).
Now go to your sv_config.ini and paste the following code, now change everything to your liking. You can add custom groups by adding them after User in the "Usergroups=" line, then add a "<NewGroupName>_xuids=" line and put xuids after it, when you've done that you must add "<NewGroupName>_commands=" and put commands after it.
Now start your server.
Usage (For plugin developers):
Nothing. Just don't add any 'IsPlayerAdmin' checks yourself. Basically, if this plugin isn't installed, everyone can use the commands.
Credits:
@Pozzuh - Made the plugin
Source:
*Note: 90 fov not included in this plugin, use @zxz0O0's plugin.
**Note: Ping viewer not included in this plugin, use my other plugin.
Please report bugs!
This plugin allows server admins to have control over who can use which commands. For example, you can only allow admins to play with 90 fov*, or let moderators only see their ping**.
Why?:
It's annoying for server admins to have to set up xuids in every plugin. And this allows moderators, helpers and even donators to get some more features then a normal player. (It works the same way in Minecraft with Bukkit)
Requirements:
@Nukem's dedicated server addon 1.190+
Changelog:
v1.0 BETA: initial release
v1.1 BETA: Updated to .NET 3.0 (Linux support). Now requires addon 1.190+
Usage (for players):
Code:
!help // Shows the commands you can use.
!gettype // See what user type you are (for example admin, moderator or user).
!getxuid // See your xuid, useful for admins to setup their server.
Usage (For server admins):
Put aaaPermissionPlugin.dll in your servers /plugin/ folder (NOTE: DO NOT RENAME THE PLUGIN!).
Now go to your sv_config.ini and paste the following code, now change everything to your liking. You can add custom groups by adding them after User in the "Usergroups=" line, then add a "<NewGroupName>_xuids=" line and put xuids after it, when you've done that you must add "<NewGroupName>_commands=" and put commands after it.
Code:
//Don't add spaces after commas!
//CASE SENSITIVE!
//Don't remove the User & Admin groups!
[Permission]
//You can add more user groups here
Usergroups=Admin,Moderator,User
//Add admin xuids here (Go ingame and use !getxuid)
Admin_xuids=xuid1,xuid2,xuid3
//Admins can use all commands (Do not change!).
Admin_commands=*ALL*
//Add moderator xuids here
Moderator_xuids=xuid1,xuid2,xuid3
//Add commands moderators can use here
Moderator_commands=!help,!getxuid,!gettype
//Add commands everyone can use
User_commands=!help,!getxuid,!gettype
//Everyone who isn't in any other group is a user (Do not change!).
User_xuids=*EVERYONE*
Usage (For plugin developers):
Nothing. Just don't add any 'IsPlayerAdmin' checks yourself. Basically, if this plugin isn't installed, everyone can use the commands.
Credits:
@Pozzuh - Made the plugin
Source:
Spoiler (Click to View)
CSHARP Code
- using System;
- using System.Collections.Generic;
- using Addon;
- //Pozzuh xuid = 0110000102fd9a03
- namespace _PermissionPlugin
- {
- public class _PermissionPlugin : CPlugin
- {
- public List<string> Admins;
- public List<string> UserGroups;
-
- public override void OnServerLoad()
- {
- ServerPrint("Permission plugin loaded. Author: Pozzuh. Version 1.0 Beta");
-
- initUserGroups();
- firstStart();
- }
-
- void firstStart()
- {
- if(GetServerCFG("Permission", "Usergroups", "x") == "x")
- SetServerCFG("Permission", "Usergroups", "Admin,Moderator,User");
-
- if(GetServerCFG("Permission","Admin_xuids", "x") == "x")
- SetServerCFG("Permission","Admin_xuids", "xuid1,xuid2,xuid3");
-
- if(GetServerCFG("Permission","Admin_commands", "x") == "x")
- SetServerCFG("Permission","Admin_commands", "*ALL*");
-
- if (GetServerCFG("Permission", "Moderator_xuids", "x") == "x")
- SetServerCFG("Permission", "Moderator_xuids", "xuid1,xuid2,xuid3");
-
- if (GetServerCFG("Permission", "Moderator_commands", "x") == "x")
- SetServerCFG("Permission", "Moderator_commands", "!help,!getxuid,!gettype");
-
- if (GetServerCFG("Permission", "User_commands", "x") == "x")
- SetServerCFG("Permission", "User_commands", "!help,!getxuid,!gettype");
-
- if (GetServerCFG("Permission", "User_xuids", "x") == "x")
- SetServerCFG("Permission", "User_xuids", "*EVERYONE*");
- }
-
- void initUserGroups()
- {
-
- string UserGroups_string = GetServerCFG("Permission", "Usergroups", "Admin,Moderator,User");
-
- foreach (string Group in UserGroups_string.Split(','))
- UserGroups.Add(Group);
- }
-
- List<string> getUsersInGroup(string groupname)
- {
-
- string group_string = GetServerCFG("Permission", groupname + "_xuids", " ");
-
- if (group_string != " ")
- foreach (string xuid in group_string.Split(','))
- group.Add(xuid);
- else
- if(groupname != "User")
- ServerPrint("No users set for group: " + groupname);
-
- return group;
- }
-
- List<string> getCommandsAllowedInGroup(string groupname)
- {
-
- string group_string = GetServerCFG("Permission", groupname + "_commands", " ");
-
- if (group_string != " ")
- foreach (string cmd in group_string.Split(','))
- group.Add(cmd);
- else
- ServerPrint("No commands set for group: " + groupname);
-
- return group;
- }
-
- string getUserGroup(string xuid)
- {
- foreach (string group in UserGroups)
- {
- usersInGroup = getUsersInGroup(group);
-
- if (usersInGroup.Contains(xuid))
- return group;
- }
-
- return "User";
- }
-
- public override ChatType OnSay(string Message, ServerClient Client)
- {
- string userIsInGroup = getUserGroup(Client.XUID);
- string lowMsg = Message.ToLower();
-
- if (lowMsg.StartsWith("!getxuid")) //Can't be used in the permission plugin OH THE IRONY
- {
- TellClient(Client.ClientNum, "Your xuid is: \'" + Client.XUID + "\'.", true);
- return ChatType.ChatNone;
- }
-
- if (lowMsg.StartsWith("!gettype")) //Can't be used in the permission plugin OH THE IRONY
- {
- TellClient(Client.ClientNum, "Your user type is: \'" + userIsInGroup + "\'.", true);
- return ChatType.ChatNone;
- }
-
- if (lowMsg.StartsWith("!help") || lowMsg.StartsWith("!cmdlist"))
- {
- List<string> allowed_commands = getCommandsAllowedInGroup(userIsInGroup);
- string msg = "You can use the following commands^1:^7 ";
-
- for (int i = 0; i < allowed_commands.Count; i++)
- {
- if(i == (allowed_commands.Count - 2))
- msg += allowed_commands[i] + "^1 and^7 ";
- else if (i == (allowed_commands.Count-1))
- msg += allowed_commands[i] + "^1.";
- else
- msg += allowed_commands[i] + "^1,^7 ";
- }
-
- TellClient(Client.ClientNum, msg,true);
- return ChatType.ChatNone;
- }
-
- if (userIsInGroup != "Admin")
- {
- if (!lowMsg.StartsWith("!"))
- return ChatType.ChatAll;
-
- List<string> allowed_commands = getCommandsAllowedInGroup(userIsInGroup);
-
- if (allowed_commands.Contains(lowMsg.Split(' ')[0]))
- return ChatType.ChatContinue;
- else
- {
- TellClient(Client.ClientNum, "^1You aren't allowed to use that command!", true);
- return ChatType.ChatNone;
- }
- }
-
- return ChatType.ChatContinue;
- }
- }
- }
*Note: 90 fov not included in this plugin, use @zxz0O0's plugin.
**Note: Ping viewer not included in this plugin, use my other plugin.
Please report bugs!