Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1

    Post Getting started with this bare bones BF3 plugin template

    For an FAQ about basic plugin API design and architecture, see this thread:
    https://forum.myrcon.com/showthread....y-first-plugin

    I've started writing a new plugin and since I can never remember what's needed for a basic plugin, I started with a bare bones plugin template copy & pasted from a handful of popular plugins. It covers most of the basics, including:

    * Required using and namespaces statements
    * Plugin registration methods with template description HTML
    * Get, GetDisplay and Set settings variables (bare bones)
    * Plugin enable and disable functions
    * On<event> overrides for most of the interesting events, mostly just empty functions
    * Basic console and debug logging functions

    On every OnServerInfo event, it prints the value of the single settings variable (debug level) to the console window. If you change the value, the change eventually shows up in the log. This shows that variable display and get/set is working, as well as On<event> hookup. Enabling/Disabling the plugin also prints a message.

    What's not covered: in-game command registration, HTTP Web requests.

    To use the template to create your own plugin, just get a copy and:

    * Rename the file to whatever you want .cs
    * Change BasicPlugin class name to whatever you want
    * Change the constructor to the same name
    * Edit the GetPluginName, GetPluginVersion, GetPluginAuthor and GetPluginWebsite functions
    * Fill in the GetPluginDescription function with your HTML description

    The best way to get a copy is to fork my public GitHub repo. Or, use the v0.0.0.1 tag, which is also a page where you can download a ZIP of the basic files.

    Or just use ZIP attached to this post and copy the BasicPlugin.cs file out of it.

    Keywords: plugin, basic, beginner, getting started, template, how to.

    EDIT: See post #2 for a ZIP of the code.
    Last edited by PapaCharlie9; 19-01-2014 at 16:18. Reason: Removed and added FAQ link
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  2. #2

    0.0.0.2: utf8 and CRLF line endings

    Okay, so I learned that GitHub doesn't like Unicode LE + BOM (thinks its a binary file) and the tag-based download has LF line endings.

    Here's a clean UTF-8 version with CRLF line endings. It's v0.0.0.2. Still bare bones, no actual zombie code yet.

    EDIT: this zip names the plugin BF3Zombie instead of BasicPlugin, but its the same code. And ignore the BF3, it works for BF4 and probably MOHW as well. Just remember to rename the file name AND the class name, they need to match.
    Attached Files Attached Files
    Last edited by PapaCharlie9; 19-01-2014 at 16:18.
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  3. #3
    no fair, that's what i'm working on ;(

  4. #4
    Quote Originally Posted by m4xx View Post
    no fair, that's what i'm working on ;(
    Hey, save me the work! I'll just use yours. Let me know how I can help.
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  5. #5
    Renamed the repo to remove all reference to zombies. Updated all docs and names. Now this is just a clean skeletal plugin that you can use as the starting point for a new BF3 plugin.
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  6. #6
    It doesn't show up in the plugin list for me, how can I fix that?

  7. #7
    Quote Originally Posted by errieman View Post
    It doesn't show up in the plugin list for me, how can I fix that?
    Did you use the version in post #2? That's the one to use.

    What were the compilation errors in plugin.log?
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  8. #8
    Quote Originally Posted by PapaCharlie9 View Post
    Did you use the version in post #2? That's the one to use.

    What were the compilation errors in plugin.log?
    No, I did not, I will try.
    and it didn't show up in the log.

    I probably forgot some stupid little thing, but it's just that there is almost no documentation on plugins.

    edit: it did show up, I was looking at the wrong log it says:

    [15:32:17] Compiling KaasPlugin.cs... Done
    [15:32:18] Could not load type 'PRoConEvents.KaasPlugin' from assembly 'KaasPlugin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
    Last edited by errieman; 26-01-2013 at 19:24.

  9. #9
    Quote Originally Posted by errieman View Post
    No, I did not, I will try.
    and it didn't show up in the log.

    I probably forgot some stupid little thing, but it's just that there is almost no documentation on plugins.

    edit: it did show up, I was looking at the wrong log it says:

    [15:32:17] Compiling KaasPlugin.cs... Done
    [15:32:18] Could not load type 'PRoConEvents.KaasPlugin' from assembly 'KaasPlugin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
    Er, did you rename the BF3Zombies.cs file to KaasPlugin.cs? Don't do that yet. Just try copying the BF3Zombie.cs, unchanged, into your procon/Plugins/BF3 folder and see if that compiles. If it does, THEN rename everything, inside the code and out. The error is saying that you didn't change all of the names inside the code as required. Probably left class BF3Zombies unchanged, would be my guess.
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  10. #10
    Quote Originally Posted by PapaCharlie9 View Post
    Er, did you rename the BF3Zombies.cs file to KaasPlugin.cs? Don't do that yet. Just try copying the BF3Zombie.cs, unchanged, into your procon/Plugins/BF3 folder and see if that compiles. If it does, THEN rename everything, inside the code and out. The error is saying that you didn't change all of the names inside the code as required. Probably left class BF3Zombies unchanged, would be my guess.
    Thank you, that worked for a while but now I have the same problem but it doesn't even show up in the logs.
    The source file is just sitting there, Procon won't even try to compile it.

    edit: it is on another server
    Last edited by errieman; 29-01-2013 at 14:12.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •