Warp-Mod Development (Alpha-Release)


  • Hi Friends ^^.

    I'm back, looking sceptically at those closed-source mods.
    It's finally time to code that Warp-Mod I wanted to do a year ago.

    But I have to work into everything again and will have some hurdles on my way.
    You are invited to help me speed up the process.

    First step is to create a custom struct with a string and a Vector3.
    This should be used in a List which is saved and loaded on the server.
    Then we need to pass Info between Users and the Server and execute the teleport commands.

    I will refer to the Teleport and MOTD Mods I did before, where most neccesary code is already used.
    Gonna start now and keep you Up2Date.

    Update
    Scroll down a bit for first Alpha-Version.

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)


  • 13
    Posts
    2057
    Views
    Log in to reply


  • I'm nearly done with basic functionality.
    But I got my first problem now.

    I created a custom struct:

        public struct WLocation
        {
            public string LName;
            public Vector3 LPosition;
        }
    

    which is used inside a List:

        public static List<WLocation> WLocations = new List<WLocation> ();
    

    and a Save-Function:

        public static void SaveList()
        {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream file = File.Create(SaveLocation + "/Warps.r4");
            bf.Serialize(file, WLocations);
            file.Close();
        }
    

    The Problem I have is, that the struct is not serializable.
    Any Idea how to solve this?

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)



  • OK, i used a workaround...
    I just searialized a List<float> for Warp-Coordinates and created a single file for every warp.
    It's not most effective, but its working for now :)
    Couldn't even serialize Vector3.
    Look's like it's declared at Eco.Shared.Math and I don't know if it's even possible for modders to create custom structs which are serializable. Whatever.

    I got it working.

    But there is one major Problem:
    Every User can create warps.
    I wanted to restrict it on admins only, but I didn't find a way to check if a User is Admin or not with the newer Version of Eco. You can see how I tried at the script.

    ToDo:
    Warp creation for Admins only
    Delete Warps via Command
    Bug-Fixing

    Current Usage:
    /wadd WARPNAME (this will create a Warp at the current Player-Position)
    /w WARPNAME (this will teleport the Player to Warp WARPNAME)

    For every Warp a .r4 File will be created in the "Warps"-Directory.
    It can be just deleted by Server-Owners.

    Download:
    Warps.cs
    Place in Mods/Commands/ Folder

    USE AT YOUR OWN RISK!!!
    It is an early alpha Version
    ALL Players currently can create and overwrite Warps!!

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)



  • I SUCK at making commands, but I do know Admin commands uses this: "ChatAuthorizationLevel.Developer" while everyone else "ChatAuthorizationLevel.User" Hope this helps :D

    --MW--



  • I already tried :/
    Unfortunately it just didn't work as expected.
    Maybe I did something wrong.
    But thanks anyway.

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)



  • Sorry I couldn't help

    --MW--



  • No Problem.
    I'm glad atleast someone replied ^^

    That Auth-Level is also the only thing i found which may be indicating to admin rights.
    Gonna check it out again this evening.

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)



  • OMG... IT WORKS!!!!!!!!
    Problem was, I had the server runnning locally. Seems like you're always admin then.
    Here is newer Version working with Adminrights:
    Warps.cs

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)



  • For file serialization, I am now using JSON, eco offers a utility feature for this, it depends on what needs you have

    Also what is the general Idea here? to allow players to warp from 1 server to another?



  • With this mod admins can declare public places where all players can teleport to.

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)



  • What you mean is similar to the Multiverse-Mod on Minecraft.
    Something I thought about a lot recently.
    That will be a game changer.
    But to realize this, we need a way to exchange information between two or more servers.

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)



  • Ahh this is the same thing I had before with the /spawn /city etc



  • may be lacking some context here but just add the decoraction [Serializable] on the line above public.

    https://stackoverflow.com/questions/30400876/is-serialization-possible-for-a-struct


13
Posts
2057
Views
Log in to reply

Internal error.

Oops! Looks like something went wrong!