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

Community Script Hook V .NET


crosire
 Share

Recommended Posts

Prof_Farnsworth

Hey all, any word on Vector3 import export from ini? Also, my script is not saving an integer. We just use "SetValue" no?

 

Thanks in advance.

Link to comment
Share on other sites

Hey all, any word on Vector3 import export from ini? Also, my script is not saving an integer. We just use "SetValue" no?

 

Thanks in advance.

You can convert Vector3 to a string and parse from a string to Vector3.

private static string ToStr( Vector3 vector ){	return vector.X + ";" + vector.Y + ";" + vector.Z;}private static Vector3 Parse( string str ){	float[] arr = Array.ConvertAll( str.Split( ';' ), float.Parse );	return new Vector3( arr[ 0 ], arr[ 1 ], arr[ 2 ] );}
Link to comment
Share on other sites

unknown modder

 

Hey all, any word on Vector3 import export from ini? Also, my script is not saving an integer. We just use "SetValue" no?

 

Thanks in advance.

You can convert Vector3 to a string and parse from a string to Vector3.
private static string ToStr( Vector3 vector ){	return vector.X + ";" + vector.Y + ";" + vector.Z;}private static Vector3 Parse( string str ){	float[] arr = Array.ConvertAll( str.Split( ';' ), float.Parse );	return new Vector3( arr[ 0 ], arr[ 1 ], arr[ 2 ] );}
surely you should try using the vector3 to string override instead of making your own
Link to comment
Share on other sites

surely you should try using the vector3 to string override instead of making your own

Then he should remove from string next substrings: "X: ", "Y: " and "Z: " when parsing Vector3 from string.

Edited by Inco
Link to comment
Share on other sites

Prof_Farnsworth

 

surely you should try using the vector3 to string override instead of making your own

Then he should remove from string next substrings: "X: ", "Y: " and "Z: " when parsing Vector3 from string.

 

Haha thanks guys. Overrides and parsing I haven't used much, but I'll see what I can come up with.

Link to comment
Share on other sites

unknown modder

 

 

surely you should try using the vector3 to string override instead of making your own

Then he should remove from string next substrings: "X: ", "Y: " and "Z: " when parsing Vector3 from string.

 

Haha thanks guys. Overrides and parsing I haven't used much, but I'll see what I can come up with.the override you don't need to worry about, just use vector3.tostring()
Link to comment
Share on other sites

I'm having serious problems with task sequences...

        class TaskTest : Script        {            bool doTasks = false;                        public TaskTest()            {                Tick += onTick;                KeyDown += onKeyDown;            }            private void onTick(object sender, EventArgs e)            {                                if(doTasks)                {                    Vehicle veh = Game.Player.Character.CurrentVehicle;                    TaskSequence toDo = new TaskSequence();                    toDo.AddTask.CruiseWithVehicle(veh, 20.0f);                    toDo.Close();                    Game.Player.Character.Task.PerformSequence(toDo);               }            }            private void onKeyDown(object sender, KeyEventArgs e)            {                if (e.KeyCode == Keys.F5 && e.Shift)                    doTasks = !doTasks;            }        }

The above code simply does not work. Either nothing happens, or my game crashes...

 

Any suggestions?
Yes... the player is in a vehicle when the task sequence is activated.

 

Matt

Link to comment
Share on other sites

unknown modder

I'm having serious problems with task sequences...

        class TaskTest : Script        {            bool doTasks = false;                        public TaskTest()            {                Tick += onTick;                KeyDown += onKeyDown;            }            private void onTick(object sender, EventArgs e)            {                                if(doTasks)                {                    Vehicle veh = Game.Player.Character.CurrentVehicle;                    TaskSequence toDo = new TaskSequence();                    toDo.AddTask.CruiseWithVehicle(veh, 20.0f);                    toDo.Close();                    Game.Player.Character.Task.PerformSequence(toDo);               }            }            private void onKeyDown(object sender, KeyEventArgs e)            {                if (e.KeyCode == Keys.F5 && e.Shift)                    doTasks = !doTasks;            }        }
The above code simply does not work. Either nothing happens, or my game crashes...

 

Any suggestions?

Yes... the player is in a vehicle when the task sequence is activated.

 

Matt

you don't need task sequences for one task. But the issue here is you keep creating the task sequence and playing it every tick. Once you play the sequence, set dotask to false
Link to comment
Share on other sites

you guys have plans to add support for the recently added directx hook in ScripthookV?

Link to comment
Share on other sites

you guys have plans to add support for the recently added directx hook in ScripthookV?

Yes, done.

Link to comment
Share on other sites

 

you guys have plans to add support for the recently added directx hook in ScripthookV?

Yes, done.

 

 

amazing :)

Link to comment
Share on other sites

I have a question.

 

Why you read a settings file manually instead of using WritePrivateProfileString / GetPrivateProfileString methods from Windows?

 

Regards,

Link to comment
Share on other sites

I have a question.

 

Why you read a settings file manually instead of using WritePrivateProfileString / GetPrivateProfileString methods from Windows?

 

Regards,

Because they do neither support trailing nor C++ syle comments. =)

Link to comment
Share on other sites

Prof_Farnsworth

Do we have an efficient method of dealing with blips? I am specifically having a hard time detecting if they exist since they are not an entity. Calling "blip.exists" crashes the script unless using a try catch, but if it's not there, the try will exit anyway. Best I can figure is to set a separate flag for each blip in order to only create one on the fly, as without the exists check it creates on every tick.

 

Any help is appreciated.

 

EDIT: The workaround is great, but if anyone knows anything else that works directly for the blips, feel free to help.

Edited by Prof_Farnsworth
Link to comment
Share on other sites

unknown modder

Do we have an efficient method of dealing with blips? I am specifically having a hard time detecting if they exist since they are not an entity. Calling "blip.exists" crashes the script unless using a try catch, but if it's not there, the try will exit anyway. Best I can figure is to set a separate flag for each blip in order to only create one on the fly, as without the exists check it creates on every tick.

 

Any help is appreciated.

 

EDIT: The workaround is great, but if anyone knows anything else that works directly for the blips, feel free to help.

are you making sure the blip is not null, that sounds like the issue
Link to comment
Share on other sites

Prof_Farnsworth

 

Do we have an efficient method of dealing with blips? I am specifically having a hard time detecting if they exist since they are not an entity. Calling "blip.exists" crashes the script unless using a try catch, but if it's not there, the try will exit anyway. Best I can figure is to set a separate flag for each blip in order to only create one on the fly, as without the exists check it creates on every tick.

 

Any help is appreciated.

 

EDIT: The workaround is great, but if anyone knows anything else that works directly for the blips, feel free to help.

are you making sure the blip is not null, that sounds like the issue

My concern was if something doesn't exist, does it automatically equal null? I'm not sure if there is another result that is possible.

Link to comment
Share on other sites

My concern was if something doesn't exist, does it automatically equal null? I'm not sure if there is another result that is possible.

 

You might want to mention which kind of exception it throws =).

Link to comment
Share on other sites

 

I have a question.

 

Why you read a settings file manually instead of using WritePrivateProfileString / GetPrivateProfileString methods from Windows?

 

Regards,

Because they do neither support trailing nor C++ syle comments. =)

 

 

That is true, I forgot completely about the commenting into INI files. I've sent you a PM.

 

Regards,

Link to comment
Share on other sites

I would guess there is no easy way to change INSERT reset key to something else out of the way, whole right side set of keys i'm using for game since those are nicely isolated. REaly the best would be combination of two keys, because many people have everything assign twice with scripts in game and stuff. Just asking for consideration.

Link to comment
Share on other sites

bigtiny779

hey guys i really need some help. i can play the game normaly with my controller, but as soon as i touch any key on my keyboard the game crashes... it only does this when i have scripthookv .net active. any body got any ideas?

Edited by bigtiny779
Link to comment
Share on other sites

unknown modder

 

 

Do we have an efficient method of dealing with blips? I am specifically having a hard time detecting if they exist since they are not an entity. Calling "blip.exists" crashes the script unless using a try catch, but if it's not there, the try will exit anyway. Best I can figure is to set a separate flag for each blip in order to only create one on the fly, as without the exists check it creates on every tick.

 

Any help is appreciated.

 

EDIT: The workaround is great, but if anyone knows anything else that works directly for the blips, feel free to help.

are you making sure the blip is not null, that sounds like the issue
My concern was if something doesn't exist, does it automatically equal null? I'm not sure if there is another result that is possible.If the error you are getting is a null argument error, it usually means you are trying to use a variable that hasn't been set to anything. Checking if it's null could be your solution
Link to comment
Share on other sites

Released v1.1, adds support for drawing custom textures and some new features due to native memory access (like World.GetNearbyPeds/Vehicles overloads which take a position and World.GetAllPeds/Vehicles),

Link to comment
Share on other sites

identitymatrix

Crosire, how do you go about native functions that require a hash

 

say...

 

Dim fPos As Vector3 = Fjet.PositionDim pPos As Vector3 = player.PositionNative.Function.Call(Native.Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, fPos.X, fPos.Y, fPos.Z, pPos.X, pPos.Y, pPos.Z, 15, True, HASH_HERE, player, True, True, -1)

There is no data type for hash in vb.net, well i can't pass a raw hash as a param or I will get error, e.g 0x398hf093 or something

 

 Private Function getHash(ByVal weapon As String) As Int32        Dim hashkey As Int32 = Native.Function.Call(Of Int32)(Native.Hash.GET_HASH_KEY, weapon)        Return hashkey    End Function
Link to comment
Share on other sites

identitymatrix

 

Crosire, how do you go about native functions that require a hash

 

say...

 

Dim fPos As Vector3 = Fjet.PositionDim pPos As Vector3 = player.PositionNative.Function.Call(Native.Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, fPos.X, fPos.Y, fPos.Z, pPos.X, pPos.Y, pPos.Z, 15, True, HASH_HERE, player, True, True, -1)

There is no data type for hash in vb.net, well i can't pass a raw hash as a param or I will get error, e.g 0x398hf093 or something

 

 Private Function getHash(ByVal weapon As String) As Int32        Dim hashkey As Int32 = Native.Function.Call(Of Int32)(Native.Hash.GET_HASH_KEY, weapon)        Return hashkey    End Function

 

 

ah, it is native.hash, always gets me.

Link to comment
Share on other sites

identitymatrix

 

 

Crosire, how do you go about native functions that require a hash

 

say...

 

Dim fPos As Vector3 = Fjet.PositionDim pPos As Vector3 = player.PositionNative.Function.Call(Native.Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, fPos.X, fPos.Y, fPos.Z, pPos.X, pPos.Y, pPos.Z, 15, True, HASH_HERE, player, True, True, -1)

There is no data type for hash in vb.net, well i can't pass a raw hash as a param or I will get error, e.g 0x398hf093 or something

 

 Private Function getHash(ByVal weapon As String) As Int32        Dim hashkey As Int32 = Native.Function.Call(Of Int32)(Native.Hash.GET_HASH_KEY, weapon)        Return hashkey    End Function

 

 

ah, it is native.hash, always gets me.

 

 

Well, it still don't work, I guess I doing something wrong:

 Dim fPos As Vector3 = Fjet.Position Dim pPos As Vector3 = player.Position               Dim weapon_hash As New Native.WeaponHash                weapon_hash = Native.WeaponHash.HeavyShotgun Native.Function.Call(Native.Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, fPos.X, fPos.Y, fPos.Z, pPos.X, pPos.Y, pPos.Z, 15, True, weapon_hash, player, True, True, -1)
Edited by TheVideoVolcano
Link to comment
Share on other sites

unknown modder

 

Crosire, how do you go about native functions that require a hash

 

say...

 

 

Dim fPos As Vector3 = Fjet.PositionDim pPos As Vector3 = player.PositionNative.Function.Call(Native.Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, fPos.X, fPos.Y, fPos.Z, pPos.X, pPos.Y, pPos.Z, 15, True, HASH_HERE, player, True, True, -1)
There is no data type for hash in vb.net, well i can't pass a raw hash as a param or I will get error, e.g 0x398hf093 or something

 

 

 Private Function getHash(ByVal weapon As String) As Int32        Dim hashkey As Int32 = Native.Function.Call(Of Int32)(Native.Hash.GET_HASH_KEY, weapon)        Return hashkey    End Function
for what you are doing the, why not just use the model struct, something like dim weaponModel as new Model("weapon name goes here").

 

I don't know vb but i think it would be something like that

Link to comment
Share on other sites

unknown modder

Does it work in latest patch?

test it yourself, i see no reason why it shouldn't given script hook v has been updated
Link to comment
Share on other sites

Does it work in latest patch?

Works fine for me, at least that I can tell.

Link to comment
Share on other sites

Prof_Farnsworth

For some reason the BlipSprite "Crosshair2" no longer works for me, it just doesn't show up. Anyone know a reason why. Other Sprite types do show up, such as the default blip, and "Crosshair".

 

Thanks in advance!

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

  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

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