Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Forum Support

    3. Suggestions

[BETA] GTAIV .Net ScriptHook


HazardX
 Share

Recommended Posts

does anyone know how to allow peds in your group to use melee weapons

When ever i give the weapon to them they dont fight

Link to comment
Share on other sites

Maybe give them the weapon, then make them not able to change to another weapon, THEN start a task sequence?

Link to comment
Share on other sites

Maybe give them the weapon, then make them not able to change to another weapon, THEN start a task sequence?

I dont wont to start a task sequence because it will stop them from doing other things like entering vehicles and following me etc

ANd they dont change their weapon either, they just dont seem to attack with it

though they try to

Link to comment
Share on other sites

 

Maybe give them the weapon, then make them not able to change to another weapon, THEN start a task sequence?

I dont wont to start a task sequence because it will stop them from doing other things like entering vehicles and following me etc

ANd they dont change their weapon either, they just dont seem to attack with it

though they try to

I think that if you give any ped a melee weapon they need to be fighting another ped with a melee weapon and not a gun.

 

If you spawn a ped with a melee weapon and tell them to fight you, they will beat your ass unless you pull out a gun; at which time they will begin to flee. I think the same might happen with the bodyguards but since they have conflicting emotions (they want to flee since they have a melee weapon and the opponent has a gun yet they want to stay loyal and fight by your side) they end up doing nothing (or studdering).

Link to comment
Share on other sites

Maybe give them the weapon, then make them not able to change to another weapon, THEN start a task sequence?

I dont wont to start a task sequence because it will stop them from doing other things like entering vehicles and following me etc

ANd they dont change their weapon either, they just dont seem to attack with it

though they try to

I think that if you give any ped a melee weapon they need to be fighting another ped with a melee weapon and not a gun.

 

If you spawn a ped with a melee weapon and tell them to fight you, they will beat your ass unless you pull out a gun; at which time they will begin to flee. I think the same might happen with the bodyguards but since they have conflicting emotions (they want to flee since they have a melee weapon and the opponent has a gun yet they want to stay loyal and fight by your side) they end up doing nothing (or studdering).

My enemies dont have guns either, I just beat some guy and they defend me

Link to comment
Share on other sites

How do I make text that isn't affected by the resolution of the game?

I've tried all the different font modes

Pixel is the least affected but is still affected and it is the one supposed to be affected the most by resolution

 

this is what I mean

FontScaling.Pixel etc

Edited by lilmcnessy
Link to comment
Share on other sites

Fontscaling.Screen is what you should use. This scales from 1 to 0. x=0 being left, x = 1 being right.

y = 0 being top, y = 1 being bottom

 

Link to comment
Share on other sites

Fontscaling.Screen is what you should use. This scales from 1 to 0. x=0 being left, x = 1 being right.

y = 0 being top, y = 1 being bottom

It's not the placement that is the problem that is fine, I used the one in the example

It is the text size that is the problem

Link to comment
Share on other sites

Hello all !

I want to know how to make SAVE(S) (saving & loading) on a construct mod, someone can explain me the commands ?

Thanks

Link to comment
Share on other sites

@lilmcnessy

My guess would be that Fontscale.Screen wouldn't get affected by different resolutions. But since you tried everything... I don't know how I can help =/.

EDIT:

Something just popped into my head. Why don't you just use pixel scaling, set it right for *your* resolution, then make it detect the player's resolution and scale the size accordingly? Should work.

 

@Pepite

What exactly do you wish to save? Do you want to create a regular save (like a normal game save where you spawn in a safehouse)?

Or do you want to save the position of all made objects (since you're talking about a construct mod).

If the latter is the case, I would do it like this:

Add all objects to an array upon creation. Make a second array (with the same length) and in that array add the coordinates. Etc. (you could ofcourse make your own classes, which might be even easier).

 

Upon saving you write all objects to an ini, with their corrisponding attributes. And you're done smile.gif

 

EDIT:

Now I need some help myself =/.

(Using C#)

 

I'm working on a mod now, and I need to drawe a lot of text on screen. Because I need to draw different text on the screen all the time, I thought "Maybe a 'screen' class can come in handy. So I made the following class:

 

public class screens   {       public class text       {           public string textContent;           public Color textColour;           public float Xposition;           public float Yposition;       }       public class rectangle       {           public RectangleF rectangleInfo;           public Color rectangleColour;       }   }

 

pretty straight-forward, right?

Now I wanted to use this, ofcourse. So, in my mod, (in my Script class), I first put:

 

 

screens.rectangle[] hudScreenrectangleArray = new screens.rectangle[1];screens.text[] hudScreentextArray = new screens.text[1];

 

 

Okay, that's set up. Now let's add some stuff! In the main loop, I put:

 

// HUDSCREEN                      hudScreentextArray[0].textColour = healthColor; //Health           hudScreentextArray[0].textContent = (Player.Character.Health.ToString() + " HP");           hudScreentextArray[0].Xposition = 0.09f;           hudScreentextArray[0].Yposition = 0.96f;           hudScreentextArray[1].textColour = textColor; //Kills           hudScreentextArray[1].textContent = ("Kills: " + (getIntStat((int)gtaStats.STAT_PEOPLE_KILLED) - killedPeopleStart).ToString());           hudScreentextArray[1].Xposition = 0.72f;           hudScreentextArray[1].Yposition = 0.96f;

 

Now onto drawing this onto the screen. In the on-frame-drawing function:

 

for (int i = 0; i <= 2; i++)                       {                           e.Graphics.DrawText(hudScreentextArray[i].textContent, hudScreentextArray[i].Xposition, hudScreentextArray[i].Yposition, hudScreentextArray[i].textColour);                       }                       for (int i = 0; i <= 1; i++)                       {                           e.Graphics.DrawRectangle(hudScreenrectangleArray[i].rectangleInfo, hudScreenrectangleArray[i].rectangleColour);                       }

 

When I start this plugin in GTA, I get the following error:

"Null reference error: object reference not set to an instance"

 

what should I change? I'm sure it has something to do with my new class. But what have I done wrong? Thanks in advance.

Edited by thaCURSEDpie
Link to comment
Share on other sites

 

Add all objects to an array upon creation. Make a second array (with the same length) and in that array add the coordinates. Etc. (you could ofcourse make your own classes, which might be even easier).

Thx for your reply but how can i made it. Give me the essentials commands to do it, if you know. Thx

Link to comment
Share on other sites

 

@lilmcnessy

My guess would be that Fontscale.Screen wouldn't get affected by different resolutions. But since you tried everything... I don't know how I can help =/.

EDIT:

Something just popped into my head. Why don't you just use pixel scaling, set it right for *your* resolution, then make it detect the player's resolution and scale the size accordingly? Should work.

 

@Pepite

What exactly do you wish to save? Do you want to create a regular save (like a normal game save where you spawn in a safehouse)?

Or do you want to save the position of all made objects (since you're talking about a construct mod).

If the latter is the case, I would do it like this:

Add all objects to an array upon creation. Make a second array (with the same length) and in that array add the coordinates. Etc. (you could ofcourse make your own classes, which might be even easier).

 

Upon saving you write all objects to an ini, with their corrisponding attributes. And you're done smile.gif

 

EDIT:

Now I need some help myself =/.

(Using C#)

 

I'm working on a mod now, and I need to drawe a lot of  text on screen. Because I need to draw different text on the screen all the time, I thought "Maybe a 'screen' class can come in handy. So I made the following class:

 

public class screens   {       public class text       {           public string textContent;           public Color textColour;           public float Xposition;           public float Yposition;       }       public class rectangle       {           public RectangleF rectangleInfo;           public Color rectangleColour;       }   }

 

pretty straight-forward, right?

Now I wanted to use this, ofcourse. So, in my mod, (in my Script class), I first put:

 

 

screens.rectangle[] hudScreenrectangleArray = new screens.rectangle[1];screens.text[] hudScreentextArray = new screens.text[1];

 

 

Okay, that's set up. Now let's add some stuff! In the main loop, I put:

 

// HUDSCREEN                      hudScreentextArray[0].textColour = healthColor; //Health           hudScreentextArray[0].textContent = (Player.Character.Health.ToString() + " HP");           hudScreentextArray[0].Xposition = 0.09f;           hudScreentextArray[0].Yposition = 0.96f;           hudScreentextArray[1].textColour = textColor; //Kills           hudScreentextArray[1].textContent = ("Kills: " + (getIntStat((int)gtaStats.STAT_PEOPLE_KILLED) - killedPeopleStart).ToString());           hudScreentextArray[1].Xposition = 0.72f;           hudScreentextArray[1].Yposition = 0.96f;

 

Now onto drawing this onto the screen. In the on-frame-drawing function:

 

for (int i = 0; i <= 2; i++)                       {                           e.Graphics.DrawText(hudScreentextArray[i].textContent, hudScreentextArray[i].Xposition, hudScreentextArray[i].Yposition, hudScreentextArray[i].textColour);                       }                       for (int i = 0; i <= 1; i++)                       {                           e.Graphics.DrawRectangle(hudScreenrectangleArray[i].rectangleInfo, hudScreenrectangleArray[i].rectangleColour);                       }

 

When I start this plugin in GTA, I get the following error:

"Null reference error: object reference not set to an instance"

 

what should I change? I'm sure it has something to do with my new class. But what have I done wrong? Thanks in advance.

I think its the = sign in the i<=1 and i<=2. It loops one time to many. smile.gif

Link to comment
Share on other sites

 

Now I need some help myself =/.

(Using C#)

 

I'm working on a mod now, and I need to drawe a lot of  text on screen. Because I need to draw different text on the screen all the time, I thought "Maybe a 'screen' class can come in handy. So I made the following class:

 

public class screens   {       public class text       {           public string textContent;           public Color textColour;           public float Xposition;           public float Yposition;       }       public class rectangle       {           public RectangleF rectangleInfo;           public Color rectangleColour;       }   }

 

pretty straight-forward, right?

Now I wanted to use this, ofcourse. So, in my mod, (in my Script class), I first put:

 

 

screens.rectangle[] hudScreenrectangleArray = new screens.rectangle[1];screens.text[] hudScreentextArray = new screens.text[1];

 

 

Okay, that's set up. Now let's add some stuff! In the main loop, I put:

 

// HUDSCREEN                      hudScreentextArray[0].textColour = healthColor; //Health           hudScreentextArray[0].textContent = (Player.Character.Health.ToString() + " HP");           hudScreentextArray[0].Xposition = 0.09f;           hudScreentextArray[0].Yposition = 0.96f;           hudScreentextArray[1].textColour = textColor; //Kills           hudScreentextArray[1].textContent = ("Kills: " + (getIntStat((int)gtaStats.STAT_PEOPLE_KILLED) - killedPeopleStart).ToString());           hudScreentextArray[1].Xposition = 0.72f;           hudScreentextArray[1].Yposition = 0.96f;

 

Now onto drawing this onto the screen. In the on-frame-drawing function:

 

for (int i = 0; i <= 2; i++)                       {                           e.Graphics.DrawText(hudScreentextArray[i].textContent, hudScreentextArray[i].Xposition, hudScreentextArray[i].Yposition, hudScreentextArray[i].textColour);                       }                       for (int i = 0; i <= 1; i++)                       {                           e.Graphics.DrawRectangle(hudScreenrectangleArray[i].rectangleInfo, hudScreenrectangleArray[i].rectangleColour);                       }

 

When I start this plugin in GTA, I get the following error:

"Null reference error: object reference not set to an instance"

 

what should I change? I'm sure it has something to do with my new class. But what have I done wrong? Thanks in advance.

You are using a class here and classes need to instanciated before using.

 

 

           hudScreentextArray[0] = new text();          hudScreentextArray[0].textColour = healthColor; //Health          hudScreentextArray[0].textContent = (Player.Character.Health.ToString() + " HP");          hudScreentextArray[0].Xposition = 0.09f;          hudScreentextArray[0].Yposition = 0.96f;

 

 

That's because the array stores only references (pointers) to the classes contained in it. Since no instance of the class was created the pointer was 0 and thus you get a NullReferenceException upon accessing it. The "new" keyword allocates all memory required by the instance of the class and assignes the pointer to the array.

 

On the other hand you could use a struct instead of a class, which seems to be better in your case. Just replace the "class" keyword with "struct". This way you do not need the "new" keyword, because all memory required for the whole array will be allocated right away.

 

if you got large arrays where you just want to assign values to, structs are preferable. if you want to create an object that is often passed into other functions as a parameter then it is better to use a class.

 

[EDIT] Intosia is also correct. I'd suggest to change your for-loops in the following way:

 

for (int i = 0; i < hudScreentextArray.Length; i++)

 

 

 

@lilmcnessy: You need to set the Scaling of the Font to "ScreenUnits". Afterwards if you set the height of the font to 0.1 the text will always be 10% of the total screen height, no matter the resolution.

Edited by HazardX
Link to comment
Share on other sites

@lilmcnessy: You need to set the Scaling of the Font to "ScreenUnits". Afterwards if you set the height of the font to 0.1 the text will always be 10% of the total screen height, no matter the resolution.

It is still affected by resolution, or at least the width, anyways don't worry about it, I'm doing something else with it

 

How could I do some thing like this with a ped like a custom int for the ped

Ped.Rescued = 0;

 

In an alice script it looks like this

 

AllSurvivors[PedCount].rescued = 0

 

 

Sorry if this doesn't make much sense, I can't seem to find a way to put it into proper words

Link to comment
Share on other sites

Thanks HazardX and Intosia, I'll try your suggestions.

 

EDIT:

It's working now! Awesome biggrin.gif

Edited by thaCURSEDpie
Link to comment
Share on other sites

 

If I wanted to use the .Net ScriptHook to code in C++, how would I go about this?

Link to comment
Share on other sites

If I wanted to use the .Net ScriptHook to code in C++, how would I go about this?

You can't, use arus scripthook for C++

Link to comment
Share on other sites

I need help to add saves on a construct mod, someone can tell me the commands to save / load objects constructions??

Link to comment
Share on other sites

Does anyone know what the speed units are in the Vehicle.Speed property?

dontgetit.gif

 

[EDIT]Got it. It seems to be meters per second. m/s.

biggrin.gif

Edited by SRChiP
Link to comment
Share on other sites

Does anyone know what the speed units are in the Vehicle.Speed property?

dontgetit.gif

Look at the Speedometer example code, there should be a conversion formula smile.gif

Link to comment
Share on other sites

I have a wierd problem : when i install the .net ScriptHook, the game begins to lag/stutter as hell.

Even without any scripts installed, just the .dll and the .asi files.

 

I have some mods installed :

 

- modified popcycle (more traffic/peds)

- Simple Native Trainer v4.3

- Car Bomber Mod

- First Person Mod v1.1

- Ultimate Graphic Tweak

- Exaggerated blood v1.16

 

I'm under Vista 32bits.

 

Don't know what's happening. Without .Net ScriptHook it works well, with it it's unplayable.

Edited by Mysterius
Link to comment
Share on other sites

How can I make a subform in a form? Like when you open push a button on Form A, Form B opens but Form B still needs the fiels and methods from form A. Can I define a new Form B in the class from Form A without making a entirely new class for B? Or can I nest the class from Form B into the class from Form A? Or what should I do?

 

[EDIT] And how do I change the model of a ped? ped.skin.model is read only and ped.skin.template.model doesn't work...

Edited by Mania-92
Link to comment
Share on other sites

 

How can I make a subform in a form? Like when you open push a button on Form A, Form B opens but Form B still needs the fiels and methods from form A. Can I define a new Form B in the class from Form A without making a entirely new class for B? Or can I nest the class from Form B into the class from Form A? Or what should I do?

 

[EDIT] And how do I change the model of a ped? ped.skin.model is read only and ped.skin.template.model doesn't work...

You would probably do better just creating 2 different classes, one for each form. You can make certain fields and methods public to share them with each other and pass values back-and-forth. You can then add a call in FormA's Load, or VisibleChanged, event to Load FormB; thus resulting in both forms opening at the same time.

 

If you want both forms to be similar, you can try inheritance. Create a base form that has fields and methods used by both forms, then inherit the new forms from the base. All the public and protected base fields and methods will be passed to the class inherited by it. You will still need to load/show each form seperately.

 

You can change a ped's model by using the Ped.Model property (at least that's how I do it). This will however randomize the outfit that the ped is wearing, so if you want to be specific you need to use the Ped.Skin.Template property (not Ped.Skin.Template.Model). The TestScripts example (located in the scripthook rar file, TestScript.vb or TestScripts.cs) shows how to properly change the player model using a SkinTemplate. wink.gif

Link to comment
Share on other sites

what functions can i use to save object positions ?? pleasee

Get the object's coordinates, then write them to an INI.

Link to comment
Share on other sites

You can change a ped's model by using the Ped.Model property (at least that's how I do it). This will however randomize the outfit that the ped is wearing, so if you want to be specific you need to use the Ped.Skin.Template property (not Ped.Skin.Template.Model). The TestScripts example (located in the scripthook rar file, TestScript.vb or TestScripts.cs) shows how to properly change the player model using a SkinTemplate. wink.gif

 

                SkinTemplate newPed = ped.Skin.Template;               newPed.Model = "ig_Michelle";               ped.Skin.Template = newPed;

 

This is what I tried after looking at the example. But ingame I get a error, it says that the model of a ped can't be changed?

Link to comment
Share on other sites

Hi. How can i set game settings by coding?

 

for example, if player presses key U, draw distance will increase 10. if it is 50, it will be 60.

How can i do it?

My English is bad. Sorry.

Link to comment
Share on other sites

Hi. How can i set game settings by coding?

 

for example, if player presses key U, draw distance will increase 10. if it is 50, it will be 60.

How can i do it?

My English is bad. Sorry.

Please help me.

Link to comment
Share on other sites

Hi. How can i set game settings by coding?

 

for example, if player presses key U, draw distance will increase 10. if it is 50, it will be 60.

How can i do it?

My English is bad. Sorry.

Please help me.

I haven't been able to find a native function to do this.

Link to comment
Share on other sites

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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.