1. Hello,
    Is there any chance in the near future that an RoK section can be added to the guide under "Docs"? I'd like to try my hand at learning to create a plugin, and RoK is the only game I have a server for. Thanks!
     
  2. Last edited by a moderator: May 20, 2015
  3. Thanks so much! It's pretty daunting to look at the code for the first time.
     
  4. The link above is dead, anyone else have a tutorial from scratch? So far, Iv downloaded and ran every plugin available for ROK and ran it with no problems "I think"
     
  5. Well guys, I've started scripting about a week ago. I knew a really small knowledge regarding C#. But, it's not that hard to learn how to do it. It is, though, time-consuming.

    Download some plugins and start looking at their code - that is literally the best way.

    Also, you'll need at one point or another decompile the Assemply-CSharp.dll found at your server's directory (where you have installed oxide)/ROK_Data/Managed/Assembly-CSharp.dll. Just use dotPeek and extract the decompiled stuff to a folder in your desktop for example. Once you have, you can begin to explore the assembly. Most of the things you need will be in a folder called CodeHatch.

    You can always use the search option in windows explorer to search for specific stuff (e. "Server", "ThronesCommand", etc..). By the way, "Thrones" is the way reign of kings is refered as in the assembly, but most of the things you need won't necessarily be under the thrones folder (which, is in the CodeHatch folder. You will need to navigate into a lot of folders here...). Some stuff should be in CodeHatch/Engine/Core, just take your time and explore the assembly.

    Once you think you can start scripting, just make a simple command or a snippet for a callback(hook) and see how it goes. I advise you to keep your game running at all time because you'll need your server and test things quite frequently.
     
  6. Thank you for info, few more questions if you dont mind

    1. "Use dotPeek and extract the decompiled stuff to a folder in your desktop"

    I dragged the Assembly-CSharp.dll into Jetbrains, now looking at all this familiar code I see in the plugins, how do I extract to desktop ? I'm guessing export to Project or Phb
     
  7. should be export to project.
     
  8. So much information here...

    1. any other dlls needed to decompile under \ROK_Data\Managed or Managed\x64 ?

    Teaching myself as I go, I would like to translate the Rust Jail Mod to ROK

    2. So right now im going to just guess and say I need to find matching Plugin hooks"not sure if that's the right word" and replace them with what ROK uses right?


    From rust jail mod:----------
    Code:
    // Reference: Oxide.Ext.Rust
    using System.Collections.Generic;
    using System;
    using System.Reflection;
    using System.Data;
    using UnityEngine;
    using Oxide.Core;
    using Oxide.Core.Plugins;
    using Rust;
    namespace Oxide.Plugins
    To ROK Jail Mod--------
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using Oxide.Core;
    using CodeHatch.Engine.Networking;
    using CodeHatch.Inventory.Blueprints.Components;
    using CodeHatch.ItemContainer;
    using CodeHatch.Permissions;
    using UnityEngine;
    namespace Oxide.Plugins
    4. So many questions here like how do I choose the right "using System; "hook" to start my mod.
    [DOUBLEPOST=1432134000][/DOUBLEPOST]Crest Attacking Mod looks better to build on
    Code:
    using System;
    using System.Collections.Generic;using CodeHatch.Build;
    using CodeHatch.Engine.Networking;using CodeHatch.Engine.Core.Networking;
    using CodeHatch.Blocks;
    using CodeHatch.Blocks.Networking.Events;
    using CodeHatch.Networking.Events.Entities;
    using CodeHatch.Networking.Events.Entities.Players;
    using CodeHatch.Networking.Events.Players;
    using CodeHatch.Networking.Events.Social;namespace Oxide.Plugins
     
    Last edited by a moderator: May 20, 2015
  9. Wulf

    Wulf Community Admin

    PS. Your plugin is about to be taken over by Mughisi due to errors. ;)
     
  10. haha, I've been focused on a server system lately with admin script and everything. that 1.2k line script is taking its time when compiling :D.
    I'll work on the server logs soon.
    [DOUBLEPOST=1432149643][/DOUBLEPOST]well sword, as for what you've asked. I rarely played Rust and it was way before I discovered oxide. I haven't really gone through the plugins over there because it's all LUA and other things my mind translates to chinese.

    once you get your hand on C#, the only thing that can stop you is your imagination limit!!!!!

    (and bugs)
     
  11. Just started learning oxide and I can't stop searching through the code, its too much fun.

    I'm trying to track down the line of code responsible for showing the name and guild symbol above your head in Reign of Kings.

    In JetBrains I search for gesture and open all the .cs related lines, that uncovers more search terms like AnimationGestureBase.

    I'm looking for the timer that makes it disappear and would like to make it permanent.

    Am I go about this the right way? I'm thinking I need to decompile more than the Assembly-Csharp
     
  12. Most things normally reside in Assembly-CSharp.dll so in most cases you don't need to decompile more than that.
    And the limitations of the server :p
     
  13. Can you show me an example on what simple snippet or callback looks like in the most simple form with a working hook.

    My snippet called "Player and Enemy Health Change" has the following errors

    HealthTest plugin failed to compile!
    9:09 AM [Error] HealthTest.cs(43,13): error CS0103: The name `HookCalled' does not exist in the current context

    I started with the HooksTest.cs
    Code:
    using System.Collections.Generic;
    using System.Linq;using CodeHatch.Build;
    using CodeHatch.Engine.Core.Networking;
    using CodeHatch.Engine.Networking;
    using CodeHatch.Blocks.Networking.Events;
    using CodeHatch.Networking.Events.Entities;
    using CodeHatch.Networking.Events.Entities.Players;
    using CodeHatch.Networking.Events.Players;
    using CodeHatch.Networking.Events.Social;namespace Oxide.Plugins
    {
        [Info("Player and Enemy Health Change", "Swords", 0.1)]
        public class HealthTest : ReignOfKingsPlugin
        {
            private void OnPlayerConnected(Player player)
            {
                HookCalled("OnPlayerConnected");
                Puts(player.DisplayName + " has connected to the server.");
                PrintToChat(player.DisplayName + " has joined the server!");
                SendReply(player, "Welcome to the server {0}! We hope you enjoy your stay!", player.DisplayName);
            }
            private void OnPlayerChat(PlayerEvent e)
            {
                if (e is PlayerChatEvent)
                {
                    var chat = (PlayerChatEvent)e;
                    HookCalled("OnPlayerChat");
                    Puts(chat.PlayerName + " : " + chat.Message);
                }            if (e is GuildMessageEvent)
                {
                    var chat = (GuildMessageEvent)e;
                    HookCalled("OnPlayerChat");
                    Puts("[Guild: " + chat.GuildName + "] " + chat.PlayerName + " : " + chat.Message);
                }
            }
            private void OnEntityHealthChange(EntityDamageEvent e)
            {
                HookCalled("OnEntityHealthChange");
                if (e.Damage.Amount > 0)
                    Puts($"{e.Entity} took {e.Damage.Amount} {e.Damage?.DamageTypes} damage from {e.Damage?.DamageSource} ({e.Damage?.Damager?.name})");            if (e.Damage.Amount < 0)
                    Puts($"{e.Entity} gained {e.Damage.Amount} health.");
            }
        }
    }
     
    Last edited by a moderator: May 21, 2015
  14. Wulf

    Wulf Community Admin

    You copy/pasted too much. Just remove what is erroring, you don't need it. ;)
     
  15. No errors!...besides NullReferenceException: Object reference not set to an instance of an object

    Code:
    using System.Collections.Generic;
    using System.Linq;using CodeHatch.Build;
    using CodeHatch.Engine.Core.Networking;
    using CodeHatch.Engine.Networking;
    using CodeHatch.Blocks.Networking.Events;
    using CodeHatch.Networking.Events.Entities;
    using CodeHatch.Networking.Events.Entities.Players;
    using CodeHatch.Networking.Events.Players;
    using CodeHatch.Networking.Events.Social;namespace Oxide.Plugins
    {
        [Info("Player and Enemy Health Change", "Swords", 0.1)]
        public class HealthTest : ReignOfKingsPlugin
        {
            private void OnPlayerChat(PlayerEvent e)
            {
                if (e is PlayerChatEvent)
                {
                    var chat = (PlayerChatEvent)e;
                  
                    Puts(chat.PlayerName + " : " + chat.Message);
                }            if (e is GuildMessageEvent)
                {
                    var chat = (GuildMessageEvent)e;
                  
                    Puts("[Guild: " + chat.GuildName + "] " + chat.PlayerName + " : " + chat.Message);
                }
            }
            private void OnEntityHealthChange(EntityDamageEvent e)
            {
              
                if (e.Damage.Amount > 0)
                    Puts($"{e.Entity} took {e.Damage.Amount} {e.Damage?.DamageTypes} damage from {e.Damage?.DamageSource} ({e.Damage?.Damager?.name})");            if (e.Damage.Amount < 0)
                    Puts($"{e.Entity} gained {e.Damage.Amount} health.");
            }
        }
    }
    
     
  16. What are you intending to do in this script? My server logs plugins bring some stuff regarding logs you might want to check out and learn from :D
     
  17. e.Damage.Amount notification for player in chat/guild "not broadcast"

    Trying to understand the thought process of C#, correct me if im worng here

    1. Looking at Logs.cs, we must log every event before we can have it display?
     
    Last edited by a moderator: May 21, 2015
  18. Code:
    foreach(player i in Server.ClientPlayers)
        if(PlayerExtensions.GetGuild(i)) == PlayerExtensions.GetGuild(player))
            SendMessage(i, "Message");
     
    Last edited by a moderator: May 21, 2015
  19. Thanks, a couple more hours of googling and I'll more questions for you.
     
    Last edited by a moderator: May 21, 2015