Jump to content

GTA IV C# Modding


AbelSoftware

Important Resources:

Scripthookdotnet

Visual Studio 13 or up

.Net Framework 4.5.2

Tutorial Start:

1) We will begin with this base script:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GTA;
using GTA.Native;

namespace Mod
{
    public class Mod : Script
    {

        public Mod()
        {
            //set interval
            Interval = Settings.GetValueInteger("INTERVAL", "SETTINGS", 10000);

            //bind tick event
            this.Tick += new EventHandler(ModTick);

            //bind keydown event.
            this.KeyDown += new GTA.KeyEventHandler(ModKeyDown);


        }

        //tick method, ran every 20 secs
        public void ModTick(object sender, EventArgs e)
        {
            if (Player.Character.isInjured)
            {
                Player.Character.Health = 1000;
            }
        }

        //key down handler
        //A lot of your script will go here
        public void ModKeyDown(object sender, GTA.KeyEventArgs e)
        {

            if (Keys.F6 == e.Key)
            {
                //Add some kind of code to happen on key press
            }
        }
    }
}

Be sure you go to references, and import all listed at the top.

2) I will now provide some code sources below:

Car Spawning

Vector3 vehPos = World.GetNextPositionOnStreet(Player.Character.Position.Around(10.0f));
World.CreateVehicle(new Model("POLICE"), vehPos);

Vehicle Repair

Player.Character.CurrentVehicle.Repair();

Wash Vehicle

Player.Character.CurrentVehicle.Wash();

Max Player Health

Player.Character.Health = 1000;

Max Player Armour

Player.Character.Armor = 1000;

Change Player Model

Player.Model = ("M_Y_SWAT");

Player models can be found here

Change Player Voice

Player.Character.Voice = ("VOICE NAME HERE");

Example of player voice

Player.Character.Voice = ("M_Y_COP_WHITE");

3) Before exporting your script, go to properties and make sure you are using Framework 4.5.2 or above. On your build and assembly name, add ".net" to the end of it!

Now build the file, and add it to your scripts file!

Video Tutorial Here

 

 



User Feedback

Recommended Comments

There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×