Thursday, 18 April 2013

[TUT] Settings file - Saving and loading .INI config info

Today i wanna show how you can load and save configuration in .INI files, this is very useful to set customizable things in your script like Hotkeys, timeouts, offsets, etc..

Download the sample project here, let's use this project as the base for this tutorial.


  • Reading data

Let's start with the basic, the basic is the ScriptHook native Settings object. to read data from the script default INI file we can use the following methods:


       Settings.GetValueBool
        Settings.GetValueFloat
        Settings.GetValueInteger
        Settings.GetValueKey
        Settings.GetValueModel 
        Settings.GetValueNames
        Settings.GetValueString
        Settings.GetValueVector3

As you can see we have different types of return, i generally use GetValueString because its easier to handle.
Those methods require some parameters:










OptionName: Set the name of the option in the INI file
Category: Set the category where the option will be
DefaultValue: Set the default value that will be returned when the option don't exists in the INI file

You can skip the Category parameter, but its not good idea.

Remember that the structure of an INI file is something like:


[CATEGORY]
OPTION1=VALUE1
OPTION2=VALUE2


[CATEGORY2]
OPTION12=VALUE12
OPTION22=VALUE22

So, to read an string from the INI file we can use:






The same idea with Integers, floats, etc..


  • Writing data
We have only one method to write data in the INI file:

        Settings.SetValue

We can use any of the Reading types in this method, the method will detect and write the correct info. The params needed are:






OptionName, Category and the Value that can be one of the types  listed in "Reading data" section of this tutorial.

After writing into the INI file we must use the method Save to save the info in the INI file, if the file don't exists it will be automatically created:

        Settings.Save

The name of the file will be the name of the script file less .net.dll/.vb/.cs part.


In my scripts i always try to maintain all settings available in .INI file without the need of release the mod with the INI file, to do this i always check if the option exists in the INI file, if don't exists i set my default value. to do this i use an method:







This method will try to read an String from the INI, if nothing is found it will set in the INI the default value, then read it again and return the result as String. 

To use i call it like this:




We can use this method to read double and integer values too, we just need to convert the result to the desired type:




To read Key value i use another method that will always return an Key:






using it:


The variable must be an Keys type:




  • Another way to read and write
When i need to read and write INI file with custom names like i do in Air Combat IV where i need to read ini files that are inside folder Jets and the names are custom (armor_jet_name.ini) i use the following methods:

















As you can see we need to import the System.Text to use the StringBuilder object :)
We are using windows API's to read and write data from the INI file.

This method requires that the ini file already exists, so i use this method to confirm the INI file existence before use it:









Also i use an Global string variable (iniFile) to be the INI file name that im using, you can modify the methods to add this as parameter but i prefer to use this way. You must use the entire path to determine the INI file, it can be relative: 

iniFile = ".\Scripts\MyCustomINI.ini"

or absolute:

iniFile = "C:\Program Files\Rockstar Games\Grand Theft Auto IV\Scripts\MyCustomINI.ini"

both works fine :)

Example of use:








Download the script of this tutorial here


Tuesday, 16 April 2013

Iron Man IV script mod - Possible problems and possible solutions :)

In this post i wanna show some possible problems that you can have with Iron Man IV script and some possible solutions.

First of all, if the script don't work, you did something wrong or have wrong or incompatible software (Crack, patch version, ASI loader, scripthook version, etc.), the script works fine if everything is ok, and it's not hard to make it happen, basically a fresh install of the game "patched" to 1.0.4.0 in a computer with .Net framework 4.0 and running the game as administrator will be enough.

Download last version (v1.1) here

If version 1.0 results in "Error in script 'Iron Man IV'", try the prerelease of version 1.1 here.

Also you can download this Test Version of the script to see if it will work fine, in this version i did some extra checks and removed XNA XBox 360 control support that can be making game crash for some people.


Make sure that you have the following packages installed:

http://www.microsoft.com/pt-br/download/details.aspx?id=17851
http://www.microsoft.com/en-us/download/details.aspx?id=5555
and maybe:
http://www.microsoft.com/en-us/download/details.aspx?id=20914

Make sure that you can load .Net Scripthook scripts or you will not be able to run this mod :(


Possible problems


  • Game crash at loading screen.
This can happen if you:

Is using wrong ScriptHook.dll version, the default DLL that goes with script its to be used with GTA with patch 1.0.6.0 or later, or with EFLC, if you wanna run the script in the GTA with patch 1.0.4.0 or lower you  need to copy the DLL from folder "DLL for 1.0.4.0" and overwrite the default one in the GTAIV.exe folder.

Didn't copied file Microsoft.Xna.Framework.dll, this file is loaded by script with xbox 360 control support, so if its missing game will crash at loading screen when script is loaded.


  • Error in script 'Iron Man IV':
Try the command reloadscripts, press " to see the scripthook console window.

This error can happen if you don't copy all files from Scripts folder:


to Scritps folder in GTAIV.exe folder.


This error can happen too if another script mod is deleting one of the Iron Man IV objects, in this case i recommend to remove all other scripts and test only with Iron Man IV to make sure that this is the reason or not.


Sometimes this error can happen randomly at game startup, in this case try using the scripthook console command reloadscripts, press " to see the console window then type the command.


  • Game crash at first screen (black screen):

Some users had this issue and was related to incompatible ScriptHookDotNet.asi file, so they tryed other sources and worked.



Another thing that you can try is use CCleaner to clean windows registry issues, this helped one of the users, game was crashing at loading screen and all was properly installed, so he did this registry clean and the problem was fixed :)



I hope that this info can help you solve your Iron Man IV problems :)


Check the new armors post :)

Saturday, 13 April 2013

[Script] Chainsaw for GTA iV

Chainsaw gun in GTA Vice City was a bad ass gun, why don't have something similar in GTA IV?

Download: Main link (mirror1)

You will be able to equip an chainsaw and have some GTA Vice City killing style.




Sunday, 7 April 2013

[TUT] Cool "3D" target HUD

Today i wanna show how you can use some game features to create an cool "3D" target HUD to use in your scripts, this is an preview of what I'm talking about:



Download the sample script here.

The idea consists in draw checkpoints/coronas around the target, we will use the native function DRAW_CHECKPOINT to draw the checkpoints.

Download the sample project here, let's use this project as the base for this tutorial.

We will need the following objects to make this code work:


here we will store the possible targets

this will be the interval of the targets search

this object will give offset positions around the target

this is just an variable to help us create an rotation effect for the target HUD, we will increase it and apply to the Y value of the targetAux object rotation

this will set the actual target so we can kid with it :)


When the script loads we should create the object, choose an model with small volume to avoid collisions with other things, we also set this object to be invisible, without collisions and with freezeposition set to true, the wait(500) it's an single delay to avoid script crash at first start, because when game finishes loading the object creation can fail:


Ok, first let's search for the possible targets, in the tick let's check if the timer variable (timeWaitSearchTargets) it's less than zero, then we will reset it to 300 and search for the targets, so each 300 ms we will update the targets list:


Now we will reset the actual target to nothing and run the targets list to see what vehicle is close enough to the aim, we will do it only if user is pressing Aim key and if the targets list exists:


I'm using this method to find the targets.

Now that we have our target we can draw the checkpoint around it:


How it works:

First we set the targetAux object position to player position, you can use current camera position, but the result its almost the same
Then we set the rotation of this object to be the same of the camera
Now we just need to use the method GetOffsetPosition to detect the position around it and based on this we can define the Offset position around the target:

To get the position above the target:


Bellow target:


on the Left:


on the right Right:



This is an simple idea that works very fine, isn't the best option but works fine :)

You can use lights and coronas too, the result will look better.

[Script] Iron Man IV - Release post and installation guide :)

This mod allows you to have some Iron Man features like repulsor beam, cannon and flight :)


Features

Different armors with armor selection menu


Super strength melee attacks (Q and R keys)



Minigun/cannon

Darts for silent kill


Mini rockets with multi target lock (up to 10)


Hand repulsor beam


Chest repulsor beam


Flight ability



Also you can have one Ally to help you and flying enemies




Controls

Options Menu:

Number 0 (not numpad0) - Show Options Menu
Left/Right - Switch menu item
Enter - Choose/Toggle menu item

Hold Spacebar (Jump) briefly to toggle Flight Mode ON/OFF
Hold Right Mouse Button (Aim) to aim/Set Targets (Must hold Aim to fire)
Left Mouse Click (Fire) - Fire Weapon
1, 2, 3, 4, 5 - Switch Weapons
Hold Middle Mouse Button to see Weapon Selection menu, move the mouse to select and release Middle Mouse Button to accept (Crysis Style)
E - Switch to next Weapon

In Flight Mode:

W - Go Forward
S - Go Backward
A/D - Strafe Left/Right
Shift - Go Up
Control - Go Down
B - Hold to be able to rotate camera around player without changing player's rotation

Ground Combat Only:

Q - Powered Kick
R - Powered Uppercut


Xbox 360 Controller

Options Menu:

Hold Left Bumper and Right Bumper together - Show Options Menu
Left/Right on Dpad - Switch menu item
A Button - Choose/Toggle menu item

Hold X Button (Jump) briefly to toggle Flight Mode ON/OFF
Hold Left Trigger (Aim) to aim/Set Targets (Must hold Aim to fire)
Right Trigger - Fire Weapon (Tap for most Weapons, Must hold to fire Minigun)
Dpad Left/Right - Switch Weapons

In Flight Mode:

Left Stick Up - Go Forward
Left Stick Down - Go Backward
Left Stick Left/Right - Strafe Left/Right
Click Left Stick - Go Up
Click Right Stick - Go Down

Ground Combat Only:

Left Bumper - Powered Kick
Right Bumper - Powered Uppercut



Observation for ENB/iCeNhancer users

The repulsor beam effect uses corona to simulate the beam, so the intensity of corona effect must be greater or equal to 2:

[LIGHTSPRITE]
Intensity=2.0

file that has this config: enbseries.ini or iceconfig.ini

Saturday, 6 April 2013

GTA3 Rage Classic - Junkyard car smasher

Today i was kidding with GTA III Rage Classic and decided to create an junkyard car smash feature:

Download:
GTA 4 Mods (mirror1mirror2)




Controls:

Numpad 4, 6 - rotate crane
Numpad 8, 5 - change crane pitch
Numpad 0 - toggle magnet on/off
Numpad subtract, add - change magnet height above ground


You can leave an vehicle in an place to trigger the automatic mode:


or go to the control place and control the crane and magnet:


you can pick more than one vehicle:



Actually should work only in the GTA 3 Rage Classic mod, I'm planning to extend this to GTA IV/EFLC, but i need to find some models first.

Wednesday, 3 April 2013

[Update] AC-130 v1.1


This is the new version of my AC-130 script, not big changes, i don't know what more i can do for this script

What i did:

Performance improvement using new methods to find targets and create the night vision effect
Added XBox 360 controller
Added thermal camera effect
Added more effect for .40 and .105 projectiles
Added option to skip resolution auto detect for users that run at 3860x2160 (downsampling method)
Added new target HUD for Air support mode
Fixed EFLC texture issues
Fixed texture stretch issue
Fixed some bugs

Download: GTA 4 Mods (GTA Garage, Mod DB)

Script will go with two versions:

Default (AC130.net.dll): Requires dll Microsoft.Xna.Framework.dll in GTAIV.exe folder (included)
Non XNA (AC130Files\No XNA\AC130.vb): Without XBox 360 controller support.

Why we have two versions? Because in my tests with San Andreas IV the XNA version don't work :(


Controls: Keyboard + mouse:


F7 - Activate AC130 in remote control mode
in this mode, hotkeys are:

Hold middle mouse button and move mouse Up/Down to zoom in/out (change FOV)
1 - Switch to 105mm
2 - Switch to 40mm
3 - Switch to 20mm
Right click - toggle gun
W - Speed up plane
S - Slow down plane
A - turn left
D - turn right
Left click - Shoot with actual gun
C - Change camera when in 105mm gun mode
N - Switch nightvision mode On/OFf (EFLC will have one extra: thermal vision mode, ON/Thermal/Off)

F8 - Activate AC130 in "Air support" mode

In this mode you stay on the ground, aim at the vehicle, ped or ground to set the target,
then press 1 to fire 105mm, 2 to fire 40mm and 3 to fire 20mm gun (burst fire mode)

Controls: XBox 360 controller:

Hold right Trigger and press left Thumb Stick to activate AC130
Hold right Trigger and press right Thumb Stick to activate Air support mode

A - Shoot actual gun
B - Switch gun
X - Switch Nightvision mode
Y - Switch camera for 105 shoots
Left Thumb Stick - Aim
Left Trigger - Turn left
Right Trigger - Turn right
Left Shoulder - Zoom out
Right Shoulder - Zoom in

In Air support mode: Left Thumb Stick: Walk, Right Thumb Stick: Aim

To deactivate the AC130/Air support press left or right Thumb Stick