OldSchoolHack

Registrieren / Anmelden Deutsch

[MW3] Server Addons [Update 08.02.2012]

icon Thema: [MW3] Server Addons [Update 08.02.2012]

Anmeldungsdatum: Mär 2010

Beiträge: 220

AdminPlugin
Idea:
Plugins using commands which depend on admin checks, currently don't have many options on working with admin functionality.
The Idea was to give Plugin developers more freedom on using admins by simplyfying that and extending the abilitys of the addon.dll.

General Features:
- Classes which derive from AdminPlugin get all features from the addon + the additional admin features
- seperated admin.cfg (autogenerated with admin-examples if the admin.cfg is missing)

Command Features:
- !admins (list the names of all admins)
- !addadmin <name> <xuid> (simply add a admin)
- !reloadadmins (if you edit the admin.cfg file while the server is still running, you can call this command to update the admin table)

Classes:
- ServerAdmin (Class which holds information of an admin, similar to ServerClient)
- Admin (Main Class holding the AdminPlugin Features)

ServerAdmin Functions:
- allowedToUse(command) Check if the admin is allowed to use the command
- isImmuneToCmd(command) Check if the admin is immun against the command

Admin Functions:
- LoadAdmins() loads the admin.cfg and initializes all admins
- GetAdmins() returns a list of ServerAdmins representing the admins defined in the admin.cfg
- GetAdminFromClient(ServerClient) returns the Admin-Information of the Client
- AddAdmin(name, xuid) add a new admin (which is also added in the admin.cfg)
- isAdmin(ServerClient) check if the client is a admin
- OnSayAfterAP(Message, ServerClient) this overrideable function is called after the AdminPlugin checked for admin related commands
- The OnSay Function is sealed inside the AdminPlugin to ensure that derived classes don't get the event before the AdminPlugin

Because i limit the usage of the AdminPlugin for derived classes only and sealing the OnSay Function, i ensure that AdminPlugin comes first regardless of the Plugin-Names.

Additional Information:
- the admin.cfg file is saved under admin\admin.cfg
- just make a derived project, start the server and run loadAdmins() to generate the default admin.cfg

Changelog:
- v0.1.1 Beta | initial release

Requirements:
- @Nukem's Server Addon v1.190+

Usage:
To Use the AdminPlugin, you have to set it as a reference in your Project.
This is a simple Example how to use my Plugin:

Spoiler
TEXT Code:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using AdminPlugin;
  5. using Addon;
  6.  
  7. namespace TestPlugin
  8. {
  9. //Since the AdminPlugin derives from CPlugin,
  10. //you only have to derive from AdminPlugin.Admin to call functions from both classes
  11. public class Test : Admin
  12. {
  13. public override void OnServerLoad()
  14. {
  15. //Load the admin.cfg and initialize all admins
  16. LoadAdmins();
  17. ServerPrint("TestPlugin loaded.");
  18. }
  19.  
  20. //This Function is called AFTER AdminPlugin checked the message for admin related commands
  21. public override ChatType OnSayAfterAP(string Message, ServerClient Client)
  22. {
  23. //Check if the Message starts with an command and check if the client is a admin
  24. if (Message.StartsWith("!") && isAdmin(Client))
  25. {
  26. //Get the ServerAdmin object representing the admin
  27. ServerAdmin admin = GetAdminFromClient(Client);
  28.  
  29. //Simply check if the admin is allowed to use the command
  30. if (admin.allowedToUse(Message.Split(' ')[0]))
  31. {
  32. TellClient(Client.ClientNum, "You are allowed to use this command.",true);
  33. }
  34. else
  35. {
  36. TellClient(Client.ClientNum, "You are not allowed to use this command.", true);
  37. }
  38. return ChatType.ChatNone;
  39. }
  40. else
  41. return ChatType.ChatContinue;
  42. }
  43. }
  44. }

This Version is Beta and yet not tested on Linux.
EDIT: I'm currently installing a Linux virtual machine and mw3-server to test the AdminPlugin on Linux.

I hope there are some developers willing to try my Plugin ^^

http://www.abload.de/img/download_buttoncouux.png

Um Links zu sehen, musst du dich registrieren



http://no-haking.square7.ch/images/wbb3-header-logo.png


__________________

http://no-haking.square7.ch/images/wbb3-header-logo.png