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.

    Scroll down a bit for first Alpha-Version.

  • 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);

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

  • 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.

    Warp creation for Admins only
    Delete Warps via Command

    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.

    Place in Mods/Commands/ Folder

    It is an early alpha Version
    ALL Players currently can create and overwrite Warps!!

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

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

  • Sorry I couldn't help

  • 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.

  • 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:

  • 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.

  • 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.

  • 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.


Log in to reply