Quantcast

Jump to content

» «
Photo

Release: Open Source C# Mods

9 replies to this topic
DaBOSS54320
  • DaBOSS54320

    Square Civilian

  • Members
  • Joined: 19 Jan 2014
  • United-States

#1

Posted 23 August 2014 - 07:20 AM Edited by DaBOSS54320, 23 August 2014 - 07:21 AM.

These are some of the C# mods I've made while modding GTA IV. I made these before joining the forum here and decided it'd be cool to share them. I realize there is a chance of people stealing them by releasing them open source but they are pretty simple anyway. Also I had fun making them so whatever. 2 reasons for releasing open source, 1 is so you can modify them to fit your liking, and 2 is because I don't know how to compile to a dll xD. Probably could figure it out if I looked into it but I don't mind these being open-source.

 

Also please mind these are just small simple mods I made. I don't think they are anything big, but that doesn't mean they can't be fun. I plan to make some bigger mods soon.

 

 

Slow Motion: Slow down time to focus

//Original script mod by DaBOSS54320
//Please do not remove/modify this credit if redistributed

using GTA;
using System;
using System.Drawing;

public class SlowMotion : Script{
	GameKey gKey = GameKey.RadarZoom;
	bool isPressed = false;
	bool isTapped = false;
	bool canBeTapped = false;
	
	bool toggle = false;
	
	const int minTime = 15;
	const int maxTime = 451;
	int time = 451;
	
	int timeSinceDeactivate = 0;
	const int timeRequired = 150;
	
	const float slowSpeed = 0.24F;
	
	public SlowMotion(){
		Interval = 50;
		Tick += new EventHandler(tick);
		PerFrameDrawing += new GraphicsEventHandler(gTick);
	}
	
	private void tick(object sender,System.EventArgs args){
		isPressed = Game.isGameKeyPressed(gKey);
		if(!isPressed) canBeTapped = true;
		if(isPressed && canBeTapped){isTapped = true;canBeTapped = false;}
		
		
		if(!toggle && isTapped && time >= minTime) toggle = true;
		else if(toggle && isTapped){toggle = false;timeSinceDeactivate = 0;}
		
		if(time < 0){toggle = false;time = 0;timeSinceDeactivate = 0;}
		
		if(timeSinceDeactivate < timeRequired) timeSinceDeactivate++;
		if(timeSinceDeactivate >= timeRequired && !toggle && time < maxTime) time++;
		
		if(!Player.Character.isDead) Game.TimeScale = toggle ? slowSpeed : 1.0F;
		if(toggle) time-= 3;
		
		Player.Character.Invincible = toggle;
		
		
		isTapped = false;
	}
	
	private void gTick(object sender,GraphicsEventArgs args){
		float h = (float) Game.Resolution.Height;
		float w = (float) Game.Resolution.Width;
		
		float dis = 15.0F; //Distance from corner of screen
		float l = 200.0F;
		float x1 = w-dis-l;
		float y1 = h-dis;
		float t = (float) time;
		float maxT = (float) maxTime;
		float x2 = w-dis-l*(1.0F - (t/maxT));
		float y2 = h-dis;
		float w1 = 8.0F;
		Color c = Color.Blue;
		
		args.Graphics.DrawLine(x1,y1,x2,y2,w1,c);
	}
}

Invisable Mod: This one is pretty fun for f*cking with people. You can toggle your visibility and any time and can only be seen by peds/police when you have a gun out or are in a car (Because they can see the floating gun or the car)

using GTA;

public class Invisable : Script{
	bool toggle = false;
	
	bool isPressed = false;
	
	public Invisable(){
		Interval = 50;
		Tick += new System.EventHandler(tick);
	}
	
	private void tick(object sender,System.EventArgs args){
		if(!isPressed && Game.isGameKeyPressed(GameKey.RadarZoom)){toggle = !toggle;isPressed = true;}
		else if(!Game.isGameKeyPressed(GameKey.RadarZoom)) isPressed = false;
		Player.SetComponentVisibility(PedComponent.Bags,!toggle);
		Player.SetComponentVisibility(PedComponent.Face,!toggle);
		Player.SetComponentVisibility(PedComponent.Feet,!toggle);
		Player.SetComponentVisibility(PedComponent.Hair,!toggle);
		Player.SetComponentVisibility(PedComponent.Hand,!toggle);
		Player.SetComponentVisibility(PedComponent.Head,!toggle);
		Player.SetComponentVisibility(PedComponent.Jacket,!toggle);
		Player.SetComponentVisibility(PedComponent.LowerBody,!toggle);
		Player.SetComponentVisibility(PedComponent.Teeth,!toggle);
		Player.SetComponentVisibility(PedComponent.Unknown_SUS2,!toggle);
		Player.SetComponentVisibility(PedComponent.UpperBody,!toggle);
		Player.IgnoredByEveryone = (toggle && !Player.Character.isInVehicle() && Player.Character.Weapons.Current.Type == Weapon.Unarmed);
	}
}

Health Regen: Real simple one here, health will regenerate over time.

//Original script mod by DaBOSS54320
//Please do not remove/modify this credit if redistributed

using GTA;
using System;

public class HealthRegen : Script{
	int time = 0;
	int lastKnownHP;
	const int rate = 1;
	const int maxHealth = 65;
	const int timeRequired = 15;
	
	public HealthRegen(){
		Interval = 100;
		Tick += new EventHandler(tick);
		lastKnownHP = Player.Character.Health;
	}
	
	private void tick(object sender,System.EventArgs args){
		if(time >= timeRequired && Player.Character.Health < maxHealth && !Player.Character.isDead){
			Player.Character.Health += rate;lastKnownHP = Player.Character.Health;}
		if(time < timeRequired && !Player.Character.isDead) time++;
		if(lastKnownHP > Player.Character.Health && !Player.Character.isDead){time = 0;lastKnownHP = Player.Character.Health;}
		
		Wait(2000);
	}
}

I thought I had some more but I guess I lost them. I used to have a awesome mod but I won't say what it was because I will likely release a better version of it some day. Reason I deleted it was because I thought I was gonna make a better version of it quicker but I guess I didn't.

Anyways hope you enjoy the mods.

The controls are GameKey because I play with a gamepad. Feel free to change them to keyboard keys if you want.


LetsPlayOrDy
  • LetsPlayOrDy

    Lets mod or die!

  • Members
  • Joined: 24 Aug 2013
  • United-States

#2

Posted 23 August 2014 - 01:09 PM

To compile them, create a class library (I think it's called that) in Visual Studio, copy your code to the file it created, then press Build -> Build Solution. This will compile the code and make a dll file for you (which you will have to rename to *name*.net.dll).

leftas
  • leftas

    :)

  • Members
  • Joined: 13 Jun 2013
  • Lithuania

#3

Posted 23 August 2014 - 01:23 PM

Nice... It's good when people gives their source codes. Awesome work!

Good luck with your other mods! :)

 

Best regards,

Paul.


Wiebrendh
  • Wiebrendh

    C# Programmer

  • Members
  • Joined: 22 Mar 2014
  • Netherlands

#4

Posted 23 August 2014 - 01:49 PM Edited by Wiebrendh, 23 August 2014 - 05:57 PM.

To compile them, create a class library (I think it's called that) in Visual Studio, copy your code to the file it created, then press Build -> Build Solution. This will compile the code and make a dll file for you (which you will have to rename to *name*.net.dll).

 

Yeah, but (if i am not mistaken) you can just put that code in .cs file, and it will work?


LetsPlayOrDy
  • LetsPlayOrDy

    Lets mod or die!

  • Members
  • Joined: 24 Aug 2013
  • United-States

#5

Posted 23 August 2014 - 01:50 PM

You can, but he said he didn't know how to compile so... I told him.

Wiebrendh
  • Wiebrendh

    C# Programmer

  • Members
  • Joined: 22 Mar 2014
  • Netherlands

#6

Posted 23 August 2014 - 05:57 PM

You can, but he said he didn't know how to compile so... I told him.

 

I said it as a question, but i did not put a question mark at the end..


LetsPlayOrDy
  • LetsPlayOrDy

    Lets mod or die!

  • Members
  • Joined: 24 Aug 2013
  • United-States

#7

Posted 23 August 2014 - 06:03 PM

Well then yes you can just do that
  • Wiebrendh likes this

Wiebrendh
  • Wiebrendh

    C# Programmer

  • Members
  • Joined: 22 Mar 2014
  • Netherlands

#8

Posted 23 August 2014 - 06:46 PM

Well then yes you can just do that

 

Nice, easy :)


DaBOSS54320
  • DaBOSS54320

    Square Civilian

  • Members
  • Joined: 19 Jan 2014
  • United-States

#9

Posted 25 August 2014 - 03:37 AM

Thanks for teaching me how to compile. I prefer notepad++ to visual studio though. More room and I don't really need all the fancy stuff an IDE offers. I made a batch file to compile it for me and it works pretty well. Making my police mod currently, hopefully it'll turn out good and that can be my first big mod release.

  • Wiebrendh likes this

Wiebrendh
  • Wiebrendh

    C# Programmer

  • Members
  • Joined: 22 Mar 2014
  • Netherlands

#10

Posted 25 August 2014 - 07:11 AM

Awesome, good luck man!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users