How to make a C# Script Mod for Grand Theft Auto V ?

0
60

How to make a C# Script Mod for Grand Theft Auto V ?

This tutorial is using Grand Theft Auto V – Mod Creator

Before starting, please install the tool and ensure you have all of the files.

The first step is to name your mod, this is going to be the name of your Class, and Namespace (for more information on classes & namespaces.

Replace the following with your mod name:

namespace ModName

Next, replace these:

        string ModName = "MOD NAME";
        string Developer = "YOUR NAME";
        string Version = "1.0";

In most cases, you will not need to change the Version, but feel free to do whatever you want.

We will be making a simple bodyguard script.

To start, lets insert a key press.
We will use the KeyDown tool.
Navigate to Insert –> KeyDown

Ensure that your cursor is inside of the “onKeyDown” method

Type your desired key and press “KeyDown”. This will insert a new if statement (For information on if statements, )

Now lets create your bodyguard inside of the GTA V game world.
To do this you will need to write some code yourself.
Before we continue, we need to have our player and playerPed variables. (For information on variables,)
To do this, you can use the Player tools.
Navigate to Insert –> Player –> player Variable
You also need the playerPed variable
Navigate to Insert –> Player –> playerPed Variable

 

Your code should now look something like this

 

Now, lets spawn the bodyguard.
You will be using the World.CreatePed() method. (For information on methods/functions, )
Insert the following code to your script:

Ped bodyguard = World.CreatePed(new Model(PedHash.Armoured02SMM), playerPed.Position);

We have now created the bodyguard at the players position and can mess with him using his variable bodyguard.
PedHash.Armoured02SMM is the bodyguard’s model hash, you can change this if you’d like.

Next step is to give him weapons, we will just give him a Pistol for now.
Insert the following code:

bodyguard.Weapons.Give(WeaponHash.Pistol, 9999, true, true);

This code gives the bodyguard a pistol with 9999 ammo. You can add more weapons if you would like, just copy and change the WeaponHash.

Now we need to give the bodyguard some armor.
You can use the Ped.Armor variable.

bodyguard.Armor = 100; // Armor ranges from 1-100

We’re almost done, we need to add the bodyguard to the players group so he protects the player.
We are using a native from the NativeDB here, using the GTA.Native.Function.Call() method

PedGroup playerGroup = playerPed.CurrentPedGroup; // gets the players current group
Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, bodyguard, playerGroup); // puts the bodyguard into the players group

You are gonna need to set the combat ability as well.

Function.Call(Hash.SET_PED_COMBAT_ABILITY, bodyguard, 100); // 100 = attack

The final step here is optional, but we are going to notify the player when a bodyguard is spawned.
We can use the tool Notify for this.
Navigate to Insert –> UI –> Notify

 

Feel free to change “Bodyguard spawned!” to whatever you like.

You’re done, to check, make sure your code looks similar to this:

 

ALL THAT IS LEFT NOW IS TO SAVE YOUR FILE AND RUN THE GAME!

Press File –> Save As… and navigate to your Grand Theft Auto V folder,
we need to put this file in the scripts folder, if you do not have this folder, create it.

LETS RUN THE GAME AND TEST THE SCRIPT.

Finally You Understand How to make a C# Script Mod for Grand Theft Auto V .

You May Also like

GTA V IRONMAN V2.0 MOD [ 8 MB ]

****

Loading...

LEAVE A REPLY

Please enter your comment!
Please enter your name here