Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

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

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

    2. Forum Support

    3. Site Suggestions

HazardX

[BETA] GTAIV .Net ScriptHook

Recommended Posts

fengyeblade

And the World.GetRandomPed() will make the game die......

 

Share this post


Link to post
Share on other sites
the hubster

 

Hi  Hazard

  I changed Niko's Skin and i save the game. This GameSave was invalidate.  If i restart game, it will crash when loading.....

 

  How can i change niko's skin ny safely. or return niko's skin?

 

thanks

The reason for your crash is that the game hasn't loaded the skin you chose into memory when the game loads. You might be able to fix this by calling the native REQUEST_MODEL(yourskin) when your script initializes.

Share this post


Link to post
Share on other sites
:DRX: ¡EyE!

The latest update works great for me, thanks! alien.gif

Share this post


Link to post
Share on other sites
boomer678

Hey hazard how do you play a sound? like i tried game.playaudioevent("SREETKIDS_LEFT") <- that is a song from radio. And it didnt play. Also is it possible to make it think your in a car but your not. So you can use radio on foot

Share this post


Link to post
Share on other sites
CoMPMStR

How would I use the method World.CheckForCollisions? It doesn't return a value so how do I determine if it found collisions in that position or not? I'm trying to spawn up to 3 vehicles on the street, but I don't want them to accidentally overlap on top of each other. Is there anyway to prevent this?

 

@boomer678: That method is used to play audio events, not radio songs. If you put in "WEAPON_PICKUP_CAR_BOMB" or "MOBILE_PHONE_SMS_RECIEVE" it will work. Those are the only two I found in the sco files.

Share this post


Link to post
Share on other sites
boomer678
How would I use the method World.CheckForCollisions? It doesn't return a value so how do I determine if it found collisions in that position or not? I'm trying to spawn up to 3 vehicles on the street, but I don't want them to accidentally overlap on top of each other. Is there anyway to prevent this?

 

@boomer678: That method is used to play audio events, not radio songs. If you put in "WEAPON_PICKUP_CAR_BOMB" or "MOBILE_PHONE_SMS_RECIEVE" it will work. Those are the only two I found in the sco files.

So anyway to play radio songs?

Share this post


Link to post
Share on other sites
CoMPMStR

 

How would I use the method World.CheckForCollisions? It doesn't return a value so how do I determine if it found collisions in that position or not? I'm trying to spawn up to 3 vehicles on the street, but I don't want them to accidentally overlap on top of each other. Is there anyway to prevent this?

 

@boomer678: That method is used to play audio events, not radio songs. If you put in "WEAPON_PICKUP_CAR_BOMB" or "MOBILE_PHONE_SMS_RECIEVE" it will work. Those are the only two I found in the sco files.

So anyway to play radio songs?

I don't know but I'm sure if somebody found out a way, there'd be a mod somewhere to do it. wink.gif I personally didn't looked into having the radio always playing.

 

 

I just found out that calling Model.Hash produces an error:

 

 

                      System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.                        at Scripting.?A0x8c39ee23.GetCharModel(Int32 , eModel* )                        at GTA.Ped.get_Model()

 

 

I tried using the model hash to compare peds, to determine which of my bodyguards was sitting in my passenger seat. At first, I tried comparing the ped objects but since it's two different references, they're never equal. I figured comparing the model hash would work better, since all my gurads have different models.

Share this post


Link to post
Share on other sites
boomer678

edit nvm got it

Edited by boomer678

Share this post


Link to post
Share on other sites
diryboy

hi, Hazard, is there any way to provide our own help info for our commands?

such as listing the available commands not only the built in commands and some additional help info.

 

it's nice that if we can register the additinal info too. maybe provide an overloaded version of BindConsoleCommand?

Edited by diryboy

Share this post


Link to post
Share on other sites
boomer678

hey CoMPMStR or hazard X. Is there a way to get the last key pressed. I made a custom teleport which loads from txt file like hazards. I made it so that if i press control and numpad 9 it will write the xyz to it so you can add custom teleports ingame without having to get out and add them. but i need the key to be in front of everthing except the vbCrLf( which is just making a new line before it writes the text. so its like this now

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)                   Game.DisplayText(Player.Character.Position.ToString + " written to txt flie")

 

 

but i want it to have the key that i pressed LAST first. so something like this it should look like( where key = last key pressed)

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & KEY & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)                   Game.DisplayText(Player.Character.Position.ToString + " written to txt flie")

 

Edited by boomer678

Share this post


Link to post
Share on other sites
CoMPMStR

 

hi, Hazard, is there any way to provide our own help info for our commands?

such as listing the available commands not only the built in commands and some additional help info.

 

it's nice that if we can register the additinal info too. maybe provide an overloaded version of BindConsoleCommand?

You can use Game.Console.Print to print strings to the console. This is what I use to provide info, just set up commands to print out the info, something like command_help.

 

 

@boomer678: The way I would do it is set up a variable to record the last key pressed, which would be used in the keydown event.

 

 

    Private lastKeyPressed As Keys = Keys.None   Protected Overrides Sub KeyDown(ByVal key As Keys)       If key > 0 Then lastKeyPressed = key   End Sub

 

 

Then you could save it to the file as an integer or string:

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & CInt(lastKeyPressed) & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & lastKeyPressed.ToString & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)

 

 

Is this what you were talking about?

Share this post


Link to post
Share on other sites
diryboy
hey CoMPMStR or hazard X. Is there a way to get the last key pressed. I made a custom teleport which loads from txt file like hazards. I made it so that if i press control and numpad 9 it will write the xyz to it so you can add custom teleports ingame without having to get out and add them. but i need the key to be in front of everthing except the vbCrLf( which is just making a new line before it writes the text. so its like this now

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)                   Game.DisplayText(Player.Character.Position.ToString + " written to txt flie")

 

 

but i want it to have the key that i pressed LAST first. so something like this it should look like( where key = last key pressed)

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & KEY & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)                   Game.DisplayText(Player.Character.Position.ToString + " written to txt flie")

 

i got an idea. you may hold a field to store it, and modify it in KeyDown method, and you may have to check the modifiers before modifying it

Share this post


Link to post
Share on other sites
diryboy
hi, Hazard, is there any way to provide our own help info for our commands?

such as listing the available commands not only the built in commands and some additional help info.

 

it's nice that if we can register the additinal info too. maybe provide an overloaded version of BindConsoleCommand?

You can use Game.Console.Print to print strings to the console. This is what I use to provide info, just set up commands to print out the info, something like command_help.

 

 

@boomer678: The way I would do it is set up a variable to record the last key pressed, which would be used in the keydown event.

 

 

    Private lastKeyPressed As Keys = Keys.None   Protected Overrides Sub KeyDown(ByVal key As Keys)       If key > 0 Then lastKeyPressed = key   End Sub

 

 

Then you could save it to the file as an integer or string:

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & CInt(lastKeyPressed) & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & lastKeyPressed.ToString & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)

 

 

Is this what you were talking about?

you are faster than me haha.

 

but this may cause a lot of custom ListInfoDiryboy or ListInfoComputerMaster so on..

Share this post


Link to post
Share on other sites
fengyeblade

In a loop. Call World.GetClosestPe(,) n times,the game must die.... n > 8

Share this post


Link to post
Share on other sites
HazardX
hi, Hazard, is there any way to provide our own help info for our commands?

such as listing the available commands not only the built in commands and some additional help info.

 

it's nice that if we can register the additinal info too. maybe provide an overloaded version of BindConsoleCommand?

I thought about it while adding the BindConsoleCommand. it would be no problem to include the commands with a custom helptext into the "help" listing. BUT this way the help list would be prettly large and confusing soon. But i'm considering to add a scroll option to the console, which would allow to have such a large list

Share this post


Link to post
Share on other sites
diryboy
hi, Hazard, is there any way to provide our own help info for our commands?

such as listing the available commands not only the built in commands and some additional help info.

 

it's nice that if we can register the additinal info too. maybe provide an overloaded version of BindConsoleCommand?

I thought about it while adding the BindConsoleCommand. it would be no problem to include the commands with a custom helptext into the "help" listing. BUT this way the help list would be prettly large and confusing soon. But i'm considering to add a scroll option to the console, which would allow to have such a large list

a scrollbar is cool! hope that we can mouse wheel to browse the console outputs, might need a ClearScreen command, haha~

i also have an idea, is it possible to make a help menu and categorize the custom commands hotkeys or some meta data, that will be cool.

Share this post


Link to post
Share on other sites
HazardX
In a loop. Call World.GetClosestPe(,) n times,the game must die....  n > 8

Indeed¡£the same to Call GetRandomPeds() cry.gifcry.gif

 

HazardX i need your help ! or my chaos mod wouldn't work !

 

http://www.gtaforums.com/index.php?showtopic=397744

Hmm, i was expecting problems like that after the threading fix. confused.gif Oh well... to get it to work, use the native call instead, until the next (fixed) version is out:

 

 

   Public Function GetRandomPed(ByVal Position As Vector3, ByVal Radius As Single) As Ped     Dim ped As New Native.Pointer(GetType(Ped))     Native.Function.Call("BEGIN_CHAR_SEARCH_CRITERIA")     Native.Function.Call("END_CHAR_SEARCH_CRITERIA")     Native.Function.Call("GET_RANDOM_CHAR_IN_AREA_OFFSET_NO_SAVE", Position.X - Radius, Position.Y - Radius, Position.Z - Radius, Radius * 2.0F, Radius * 2.0F, Radius * 2.0F, ped)     Return ped  End Function

 

 

Native.Function.Call does not suffer from the problems that some functions have with the new threading architecture.

Share this post


Link to post
Share on other sites
smokyrain
In a loop. Call World.GetClosestPe(,) n times,the game must die.... n > 8

Indeed¡£the same to Call GetRandomPeds() cry.gifcry.gif

 

HazardX i need your help ! or my chaos mod wouldn't work !

 

http://www.gtaforums.com/index.php?showtopic=397744

Hmm, i was expecting problems like that after the threading fix. confused.gif Oh well... to get it to work, use the native call instead, until the next (fixed) version is out:

 

 

   Public Function GetRandomPed(ByVal Position As Vector3, ByVal Radius As Single) As Ped     Dim ped As New Native.Pointer(GetType(Ped))     Native.Function.Call("BEGIN_CHAR_SEARCH_CRITERIA")     Native.Function.Call("END_CHAR_SEARCH_CRITERIA")     Native.Function.Call("GET_RANDOM_CHAR_IN_AREA_OFFSET_NO_SAVE", Position.X - Radius, Position.Y - Radius, Position.Z - Radius, Radius * 2.0F, Radius * 2.0F, Radius * 2.0F, ped)     Return ped  End Function

 

 

Native.Function.Call does not suffer from the problems that some functions have with the new threading architecture.

Thx£¬ it seems works happy.gif

 

but how to use native call to replace CetClosetVehical() function ?

Share this post


Link to post
Share on other sites
smokyrain

Unfortunate£¬ i found even the native call could not resolve crashing cry.gif , just relaying it.

 

So, Hazardx, i must wait for new version.

Share this post


Link to post
Share on other sites
Intosia
hi, Hazard, is there any way to provide our own help info for our commands?

such as listing the available commands not only the built in commands and some additional help info.

 

it's nice that if we can register the additinal info too. maybe provide an overloaded version of BindConsoleCommand?

I thought about it while adding the BindConsoleCommand. it would be no problem to include the commands with a custom helptext into the "help" listing. BUT this way the help list would be prettly large and confusing soon. But i'm considering to add a scroll option to the console, which would allow to have such a large list

Ok nice, i wanted to suggest for the console: When you press ~ you this the current console, and with shift+~ you get a fullscreen console (for when you have alot of debug messages). This is the way the console in COD4 works, always liked it. Ow and maybe a 'mini-console'. So when the console is hidden you see 1 row of text from the console without a background color. Hope you get what i meant tounge.gif

Share this post


Link to post
Share on other sites
HazardX

 

Unfortunate£¬ i found even the native call could not resolve crashing  cry.gif , just relaying it.

Are you sure that it is the native call that is crashing? Could you send me the ScriptHookDotNet.log right after a crash?

And the GetClosetVehicle also results in a crash sometimes?

 

@Intosia: Currently you can use the PageUp and PageDown keys to shrink/grow the console (small is 1/3 of the screen, large is 3/4). I might reuse the keys for scrolling in the next version, but keep the grow/shrink when you hold Shift maybe and change it to 1/4 steps up to complete fullscreen.

Edited by HazardX

Share this post


Link to post
Share on other sites
Intosia
Unfortunate£¬ i found even the native call could not resolve crashing  cry.gif , just relaying it.

Are you sure that it is the native call that is crashing? Could you send me the ScriptHookDotNet.log right after a crash?

And the GetClosetVehicle also results in a crash sometimes?

 

@Intosia: Currently you can use the PageUp and PageDown keys to shrink/grow the console (small is 1/3 of the screen, large is 3/4). I might reuse the keys for scrolling in the next version, but keep the grow/shrink when you hold Shift maybe and change it to 1/4 steps up to complete fullscreen.

Hmm ok, thanks for the tip. Maybe you have to block the Pageup and down keys when the console is open. I had something binded on it, and when the console was open the keys still functioned (and the console didnt resize i remember now). I thought it was wierd, since the console was open... But this explains.

Share this post


Link to post
Share on other sites
HazardX
Hmm ok, thanks for the tip. Maybe you have to block the Pageup and down keys when the console is open. I had something binded on it, and when the console was open the keys still functioned (and the console didnt resize i remember now). I thought it was wierd, since the console was open... But this explains.

The keys are blocked when the console is open, but i can only block the input of .Net scripts, not any other scripts/plugins. Or was it a .Net script?

Share this post


Link to post
Share on other sites
fengyeblade
In a loop. Call World.GetClosestPe(,) n times,the game must die....  n > 8

Indeed¡£the same to Call GetRandomPeds() cry.gifcry.gif

 

HazardX i need your help ! or my chaos mod wouldn't work !

 

http://www.gtaforums.com/index.php?showtopic=397744

Hmm, i was expecting problems like that after the threading fix. confused.gif Oh well... to get it to work, use the native call instead, until the next (fixed) version is out:

 

 

   Public Function GetRandomPed(ByVal Position As Vector3, ByVal Radius As Single) As Ped     Dim ped As New Native.Pointer(GetType(Ped))     Native.Function.Call("BEGIN_CHAR_SEARCH_CRITERIA")     Native.Function.Call("END_CHAR_SEARCH_CRITERIA")     Native.Function.Call("GET_RANDOM_CHAR_IN_AREA_OFFSET_NO_SAVE", Position.X - Radius, Position.Y - Radius, Position.Z - Radius, Radius * 2.0F, Radius * 2.0F, Radius * 2.0F, ped)     Return ped  End Function

 

 

Native.Function.Call does not suffer from the problems that some functions have with the new threading architecture.

Thank you very much....

\

 

 

I want you can give us some Docment(or source list) about the GTA.Euphoria. Thanks..

Share this post


Link to post
Share on other sites
smokyrain

 

Are you sure that it is the native call that is crashing? Could you send me the ScriptHookDotNet.log right after a crash?

And the GetClosetVehicle also results in a crash sometimes?

 

 

Humm, maybe something is REAL wrong.

 

i see only this in this log:

 

 

2009-02-14 19:29:05 - Initializing ScriptHookDotNet v0.84 BETA (GTA IV version 1.0.2.0)2009-02-14 19:30:49 - SEARCHING FOR SCRIPTS...2009-02-14 19:30:50 - Loading scripts in Assembly 'E:\games\Rockstar Games\Grand Theft Auto IV\scripts\WildCity.net.dll' ...2009-02-14 19:30:50 -  ...found script 'SmokyRain_WildCity'!2009-02-14 19:30:50 - DONE! 1 valid scripts found!2009-02-14 19:30:50 - STARTING SCRIPTS...2009-02-14 19:30:50 -  ...successfully started script 'SmokyRain_WildCity'!

 

 

over.

 

The code you show me is based on VB.net, but i wrote it using C#.so i rewrited it like this:

 

private Ped MyGetRandomPed(Vector3 Position, float Radius)   {       GTA.Native.Pointer myPed = new GTA.Native.Pointer(typeof(Ped));       GTA.Native.Function.Call("BEGIN_CHAR_SEARCH_CRITERIA");       GTA.Native.Function.Call("END_CHAR_SEARCH_CRITERIA");       GTA.Native.Function.Call("GET_RANDOM_CHAR_IN_AREA_OFFSET_NO_SAVE",                                   Position.X - Radius/2,                                    Position.Y - Radius/2,                                    Position.Z - Radius/2,                                    Radius,                                    Radius,                                   Radius,                                   myPed);       return ((Ped)myPed);   }

 

 

Anything wrong?

 

Share this post


Link to post
Share on other sites
diryboy

hi, Hazard, maybe is better to implement IEnumerable<T> interface for the types that has -Collection suffix. so that we can take advantage of the foreach loop. thank you!

Share this post


Link to post
Share on other sites
warclaw

were i get v 82 of it??? somemods dont work with the new one LINK?

Share this post


Link to post
Share on other sites
boomer678

 

 

@boomer678: The way I would do it is set up a variable to record the last key pressed, which would be used in the keydown event.

 

 

    Private lastKeyPressed As Keys = Keys.None   Protected Overrides Sub KeyDown(ByVal key As Keys)       If key > 0 Then lastKeyPressed = key   End Sub

 

 

Then you could save it to the file as an integer or string:

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & CInt(lastKeyPressed) & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)

 

 

My.Computer.FileSystem.WriteAllText(Game.InstallFolder & "\scripts\customteleport.txt", vbCrLf & lastKeyPressed.ToString & ", " & Player.Character.Position.X & ", " & Player.Character.Position.Y & ", " & Player.Character.Position.Z, True)

 

 

Is this what you were talking about?

Yea.... thats what i meant. Thanks biggrin.gif now i can set custom teleports ingame

Edited by boomer678

Share this post


Link to post
Share on other sites
diryboy

hi, is there a way to determine whether niko is swimming? i want to speed up while he's swimming, and only when he's swimming. thank you!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.