Unturned

Unturned

29 ratings
[FLOW] Create your own Module Mod with C#
By flow____
I teach you how to create a Mod with this new Module stuff in Unturned

You need:

- C# Knowledge
- a compiler
- Say "I will do this"


You get:

- Free Source Codes --> MyModTutorial_(flow____)_Download[www.dropbox.com]
- Knowledge to create a Unturned Module Mod

   
Award
Favorite
Favorited
Unfavorite
About this Tutorial
Hello,
i want to show you a quick tutorial how to add "correctly" your code in the Module System of Unturned.

I going to show you how you Create a own Mod - with all what you need for the success!


About me, im working now with Unity a wile, can basics of some Programming language, im good at C# and worked one year on a own Videogame, used much scripts and wrote more then thousand of lines.

If you do not have experience with C# and Unity this can be to hard for you....

I will let you Download the Source files there -> MyModTutorial_(flow____)_Download[www.dropbox.com]
About this Mod we create
I want hold it so simple as possible, that means there is not more in the package - just what you need for your own.


This Mod does nothing at the moment, just a fancy GUI element dances on your screen.
What you need
First of all we need a program that can edit scripts and create a .DLL out of it.
I use Xamarin Studio for example, you can also use Virtual Studio like 90% of all people out there.
Link --> How to install Xamarin Studio in windows


Then we need the "Unturned Example Mod".
You can find it there --> YourStorage:\...\Steam\steamapps\common\Unturned\Bundles\Sources\Examples\UnturnedExampleMod

At last we need a Decompiler like dotPeek
--> dotPeek[www.jetbrains.com]


lOptional can you also install Unity (You will need much Unity stuff to lern - and use)
Unity 5[unity3d.com]
Unity Documentation[docs.unity3d.com]
Setup before you start to Scripting files
1. Open dotPeek

2. File -> Open -> then YourStorage:\....\Steam\steamapps\common\Unturned\Bundles\Sources\Examples\UnturnedExampleMod\UnturnedExampleModule.dll
.

.3. On dotPeek there is a "Assembly Exporer" window -> right click on UnturnedExampleModule.dll -> Export to Project -> check "Create *.sln" and check Create *.pdb file" -> Export.
.


4. Go to your folder where you save the Project, find the "UnturnedExampleModule.sln" file and open it with Xamarin Studio.
.


5. Then switch to your Windows Explorer and open the Folder YourStorage:\....\Steam\steamapps\common\Unturned\Bundles\Sources\Examples\UnturnedExampleMod
.

6. Copy the Folder "UnturnedExampleMod" with all Data in it to YourStorage:\....\Steam\steamapps\common\Unturned\Modules (Just copy and past - store the original files!!!!)



7. Rename the Folder to "MyModTutorial" (Use the name of your Mod).



8. Open the "English.dat" with Notepad and edit your Mod name and the Description.
In my case i change it to:
Name MyModTutorial Description Extra information. There you can put in your infos!!!
.


.9. Open the "Mod.module" with Notepad and edit your Mod name and your .DLL name.
In my case i change it to:
.
"IsEnabled": true, "Name": "MyModTutorial", "Version": "2.1.0.3", "Dependencies": [], "Assemblies": [ { "Path": "/MyModTutorial.dll", "Role": "Both_Optional" } ] }
.
Scripting
Ok, we are very basic now - what im going to do there is simple.

- Create a Object to store Scripts on it
- Create an new Script
- Connect both Scripts
- Create a small GUI to get visible in the Game for the proof

This is not a C# ore Unity Tutorial - i do not want to teach you Scripting!
View the Unity Scripting Dokumentation for more information.

Alright:



1. Go back to Xamarin Studio!



2. Right click on the "Reference" in the "Solution" explorer -> Edit Reference -> .Net Assembly -> Browse -> You need "Assembly-CSharp.dll" and "UnityEngine.dll" -> can found in YourStorage:\...\Steam\steamapps\common\Unturned\Unturned_Data\Managed

.Check this 2 .dll´s and press OK, you need this 2 for accessing your Library .
..





..

































.3. Click on "Main.cs" and replace all with this code:
using SDG.Framework.Modules; using UnityEngine; /* using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using UnityEditor; using System;*/ namespace LittleMod { public class Main : IModuleNexus { public GameObject obj; public Manager man; public void initialize() { obj = new GameObject("ManagerForThisModWithARandomName"); obj.AddComponent<Manager>(); //Debug.Log("On"); } public void shutdown() { obj = GameObject.Find("ManagerForThisModWithARandomName"); man = obj.GetComponent<Manager>(); man.Selfdestroy(); //Debug.Log((object)"Off"); } } }
So we have create on initialize()
- One GameObject obj.
- Added the Script (that we create now) "Manager.cs" on obj.



4. Create an new File, so go to:
File -> New File -> C# -> General -> Empty Class -> Name it Manager -> New
.


.5. Create an new File again and name it GUITest:
File -> New File -> C# -> General -> Empty Class -> Name it GUITest -> New



6. Create an new File and name it WorkScript:
File -> New File -> C# -> General -> Empty Class -> Name it WorkScript -> New



7. Copy this code in Manager.cs
/*using System; using SDG.Framework.Modules; using UnityEngine.UI;*/ using UnityEngine; namespace LittleMod { public class Manager : MonoBehaviour { public GameObject objectspawn1; public GameObject manger; void Start() { manger = GameObject.Find("ManagerForThisModWithARandomName"); DontDestroyOnLoad(this.manger); objectspawn1 = new GameObject("Testobject"); DontDestroyOnLoad(objectspawn1); objectspawn1.AddComponent<GUITest>(); objectspawn1.AddComponent<WorkScript>(); } public void Selfdestroy() { Destroy(objectspawn1); Destroy(manger); } } }
.What we done here?
- Find the GameObject that we created on "Main.cs"
- Create a new GameObject Testobject for the GUI element
- Dont destroy the Stuff when we enter in a new Level
- Added on Testobject "GUITest.cs" and "Workscript.cs"
- Create a "Selfdestroy" Function for the Mod "Shutdown()" in "Main.cs"



,8. Go to "GUITest.cs" and replace all.
using UnityEngine; //using System.Collections; namespace LittleMod { public class GUITest : MonoBehaviour { float t = 0f; public string testy = "This is a test run"; void Update() { if (t > 500f) t = 20f; Loadingbarlook(); } void Loadingbarlook() { t += Time.deltaTime * 100f; } public void OnGUI() { GUILayout.Box(testy, GUILayout.MaxWidth(t), GUILayout.Height(20)); } } }
.- Create a Simple GUI with the old GUI System



.9. This is your Script - there you can put all fancy Mods in it, go to "WorkScript.cs" and replace it with:
using UnityEngine; //using System.Collections; namespace LittleMod { public class WorkScript : MonoBehaviour { void Awake() { } void Start() { } void LateUpdate() { } void Update() { } void FixedUpdate() { } } }
..Alright this is your Script:
- I added all Update methods for you, enjoy your Code
Compiling and Installing
1. Once you create all files -> save all files!
.



























.2. Select Build -> Build All (I hope you got no Errors)
.



.3. Go to your Project Folder in Windows Explorer and find your .DLL -> modname\obj\Debug\YourDLL.dll
.


.4. Copy the DLL and past it in YourStorage:\...\Steam\steamapps\common\Unturned\Modules\MyAwesomeModFolder



5. Change the name of the .DLL to the name you write in the Mod.modules file
.


.6. Start Unturned and go to Workshop -> Modules -> and here you can Activate/Deactivate your Mods
.


.Good Luck!
Feedback
Play and enjoy your New Custom Mod!
Maybe you upload some Pictures ore a Video!

Well, i have need some time to figure this out - i hope i save you some hours of work!

I will post more content in the future - i have some great ideas about some fancy mods, at the moment i work on a Mobile Game so i do not know when the next post comes to you

Any ways ------> FLOW____ (With 4 underlines) add me on Steam
See you
Bye
12 Comments
KRYS May 20, 2020 @ 6:36pm 
Would this allow me to make a custom GUI that shows your money, food, water and health.
Virtual May 13, 2017 @ 9:20pm 
oh wait, got it working, just check your module file for json errors.
Virtual May 13, 2017 @ 9:16pm 
hey, I have tried to get my module to work, but I have tried everything, I have mod.xml, mod.dll, English.txt, Icon.png, and mod.module. I basically hit copy paste on the example from nelson, but it doesn't work for some reason. I have added references. All I hit is buld classlibrary1 and it bulds, but it doesn't work in the game. I have no idea what the problem is and I hope that you could help me. Thanks,
--Virtual
flow____  [author] Mar 23, 2017 @ 2:40am 
The GUI can be saved as AssetBundle and the dll load the asset and get it to work, i also made a GUI for Unturned in this way.

Programming is easy when you reach a point of practice.
Maze Mar 22, 2017 @ 3:14pm 
Thanks for this. Now only I wish I knew c#
Ceans Mar 22, 2017 @ 3:10pm 
Actually looking to do a in-game spy system window. Seem simple...... in my mind.
flow____  [author] Feb 8, 2017 @ 2:25am 
Its possible
Ol Feb 7, 2017 @ 5:17pm 
Is it possible to make an Prophunt with this?
flow____  [author] Jan 14, 2017 @ 3:43pm 
Im looking by myself for something like a API, you can decompile any dll for example and watch the code of the Development but i dont want support this hacker stuff

You do this by:
Find the GameObject you want to Teleport -> Find the Position Vector3 (Sometimes its Transform.Position = new Vector3(NewPos) but in complex games you have a "FixedPosition" so you need be a little tricky) -> set the new Position, add a GUI and done

I can help you a little and let you download a Mod that i created - with this Mod you can edit GameObjects and behavior, if you like that
Shadow™ Jan 13, 2017 @ 3:11pm 
Is there any Api ? I am not realy into programming C# but if I want to teleport a player for example, how do I do this ?