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. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    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

CoMPMStR

 

Why is 'Model.name' property not working? It says in not in the final build? Or something? Tobad, would be usefull.

Model.Name does indeed work, I use it in my super spawner script after you spawn something, when it displays the message. I use it for ped, vehicle, and object models which works for them all. confused.gif

 

 

Thanks to donny and hazard for the helpful tips, I finally got my menus working. biggrin.gif This time I'd like to share with the rest, what I threw together. I made a sample script that shows how to display a menu ingame, and shows how to scroll and select the items. It doesn't have many comments, but it might be useful to some of you who are looking to use it in your scripts. I hope it's enough for you to understand.

 

 

' Menu Sample Script   By: CoMPuTer MAsSteR [.:AKA:.] CoMPMStR'' This script shows how to draw a simple menu with a title and menu items.' It also shows how to navigate those items and make a selection.

 

http://www.mediafire.com/download.php?ejzdml1rnot

 

 

@algrn912005: I don't think it's possible. I use 2 displaytext calls to display 2 lines, something like this:

 

 

Game.DisplayText("First Line", 2000)Wait(2000)Game.DisplayText("Second Line", 2000)

 

 

If you have more than that, you can always try using the PerFrameDrawing event. It allows you to draw text anywhere on the screen.

Share this post


Link to post
Share on other sites
boomer678

 

Why is 'Model.name' property not working? It says in not in the final build? Or something? Tobad, would be usefull.

Model.Name does indeed work, I use it in my super spawner script after you spawn something, when it displays the message. I use it for ped, vehicle, and object models which works for them all. confused.gif

 

 

Thanks to donny and hazard for the helpful tips, I finally got my menus working. biggrin.gif This time I'd like to share with the rest, what I threw together. I made a sample script that shows how to display a menu ingame, and shows how to scroll and select the items. It doesn't have many comments, but it might be useful to some of you who are looking to use it in your scripts. I hope it's enough for you to understand.

 

 

' Menu Sample Script   By: CoMPuTer MAsSteR [.:AKA:.] CoMPMStR'' This script shows how to draw a simple menu with a title and menu items.' It also shows how to navigate those items and make a selection.

 

http://www.mediafire.com/download.php?ejzdml1rnot

 

 

@algrn912005: I don't think it's possible. I use 2 displaytext calls to display 2 lines, something like this:

 

 

Game.DisplayText("First Line", 2000)Wait(2000)Game.DisplayText("Second Line", 2000)

 

 

If you have more than that, you can always try using the PerFrameDrawing event. It allows you to draw text anywhere on the screen.

Sweet thanks i think im gonna make a trainer/object spawner, but i gotta question. how would u change the posistion from the center to the top left corner of the screen.. i tried something but it didnt seem to work

 

*

edit i got it

Edited by boomer678

Share this post


Link to post
Share on other sites
loki114

How would you go about giving a car god mode or fixing a car

Share this post


Link to post
Share on other sites
HazardX
How would you go about giving a car god mode or fixing a car

You can do this by using the MakeProofTo and Repair functions of the Vehicle class.

Share this post


Link to post
Share on other sites
greasypirate

I'm getting an error on startup with this.

 

it says:

 

Runtime Error!

 

Program: C:...

 

R6030

- CRT not initialized

 

After deleting the scripthook files GTA IV started up fine.

Share this post


Link to post
Share on other sites
HazardX

 

Runtime Error!

...

 

R6030

- CRT not initialized

You are most likely using an old AsiLoader. Download a new one and it should work.

Share this post


Link to post
Share on other sites
greasypirate

Runtime Error!

...

 

R6030

- CRT not initialized

You are most likely using an old AsiLoader. Download a new one and it should work.

Nope, that's not it, I modded GTA IV after I installed 1.0.2 or whatever the newest patch is.

 

The YAASIL loader just gives me another error and still doesn't let me start up my GTA

Share this post


Link to post
Share on other sites
Krailer

I'm trying to edit the bodyguard script to prevent dead guards from laying around, but the bodies never fade, not even when I use 'NoLongerNeeded'.

 

I'm most likely doing something wrong as this is pretty much my first experience with VB.NET, but anyway, these are the changes I made to the last sub of the script:

 

Private Sub AddToGroup(ByVal p As Ped)     If Not Exists(p) Then Return     If p.isDead() Then        p.NoLongerNeeded()     ElseIf Group.isMember(p) Then Return        p.CurrentRoom = Player.Character.CurrentRoom        p.WillDoDrivebys = True        p.PriorityTargetForEnemies = True        p.DuckWhenAimedAtByGroupMember = False        p.SetPathfinding(True, True, True)        p.AlwaysDiesOnLowHealth = True        p.Accuracy = 100     End If         Dim weap As Weapon = Player.Character.Weapons.Current       p.Weapons(weap).Ammo = 30000       p.Weapons.DesertEagle.Ammo = 30000       p.Weapons.Select(weap)       p.RelationshipGroup = RelationshipGroup.Player       p.ChangeRelationship(RelationshipGroup.Player, Relationship.Companion)       p.CantBeDamagedByRelationshipGroup(RelationshipGroup.Player, True)       Group.AddMember(p, True)       Game.DisplayText(Group.MemberCount & " hoes in gang")   End Sub

 

Any advice? Thanks.

 

Share this post


Link to post
Share on other sites
CoMPMStR

 

I'm trying to edit the bodyguard script to prevent dead guards from laying around, but the bodies never fade, not even when I use 'NoLongerNeeded'.

 

I'm most likely doing something wrong as this is pretty much my first experience with VB.NET, but anyway, these are the changes I made to the last sub of the script:

 

 code snipped ... 

 

Any advice? Thanks.

When I copied this snippet into VB it showed some errors with the code, maybe that's the problem. Another could be that you're calling NoLongerNeeded in the AddToGroup method which shouldn't be done IMO. Here's what I changed it to:

 

 

    Private bgPeds As New List(Of Ped)   Private Sub AddToGroup(ByVal p As Ped)       If Exists(p) Then           p.CurrentRoom = Player.Character.CurrentRoom           p.WillDoDrivebys = True           p.PriorityTargetForEnemies = True           p.DuckWhenAimedAtByGroupMember = False           p.SetPathfinding(True, True, True)           p.AlwaysDiesOnLowHealth = True           p.Accuracy = 100           Dim weap As Weapon = Player.Character.Weapons.Current           p.Weapons(Weapon.SMG_MP5).Ammo = 30000           p.Weapons(weap).Ammo = 30000           p.Weapons.Select(weap)           p.RelationshipGroup = RelationshipGroup.Player           p.ChangeRelationship(RelationshipGroup.Player, Relationship.Companion)           p.CantBeDamagedByRelationshipGroup(RelationshipGroup.Player, True)           bgPeds.Add(p)           Player.Group.AddMember(p, True)           Game.DisplayText(Player.Group.MemberCount & " hoes in gang")       End If   End Sub   Private Sub RemoveFromGroup(ByRef bgList As List(Of Ped), ByVal index As Integer)       bgList(index).Delete()       bgList(index).NoLongerNeeded()       bgList(index).CantBeDamagedByRelationshipGroup(RelationshipGroup.Player, False)       If Player.Group.isMember(bgList(index)) = True Then Player.Group.RemoveMember(bgList(index))       bgList.RemoveAt(index)   End Sub   Protected Overrides Sub Tick()       If bgPeds.Count > 0 Then           For r As Integer = bgPeds.Count - 1 To 0 Step -1               If bgPeds®.Health <= 0 Then RemoveFromGroup(bgPeds, r)               Threading.Thread.Sleep(0)           Next       End If   End Sub   Protected Overrides Sub Startup()       Interval = 1   End Sub

 

 

I changed the AddToGroup method so it should be used only when adding a spawned ped. I added a new variable to keep track of all the spawned bodyguards, and also a new method to remove a bodyguard from the group by index. The Tick() event is used to keep watch over the bodyguards' health and remove them if they're dead. I hope this helps, it should work just fine.

 

If you're using raw scripts to test instead of compiling you may need an import:

 

 

Imports System.Collections.Generic

 

Share this post


Link to post
Share on other sites
Intosia

If i do the following i get the error message "the process cant access the file...blabla". The file it self is created in my GTA folder, but nothing gets written.

 

Any ideas on how to write a txt file?

 

 

TextWriter tw = new StreamWriter("xxx.txt");               int tmpI = 0;               foreach  (GTA.Object model in Models)               {                  tw.Write(tmpI);                  tw.Write(",");                  tw.WriteLine(model.Position.X);

 

Share this post


Link to post
Share on other sites
boomer678
If i do the following i get the error message "the process cant access the file...blabla". The file it self is created in my GTA folder, but nothing gets written.

 

Any ideas on how to write a txt file?

 

 

TextWriter tw = new StreamWriter("xxx.txt");               int tmpI = 0;               foreach  (GTA.Object model in Models)               {                  tw.Write(tmpI);                  tw.Write(",");                  tw.WriteLine(model.Position.X);

 

Its easy

 

 

  My.Computer.FileSystem.WriteAllText("C:\test.txt", "testing123", True) 

 

 

Just fill in the paths and text you want to right also i think you have to create the file before but im not sure it might auto create it.

Share this post


Link to post
Share on other sites
the hubster

Great work HazardX, Its good fun to play around with this.

 

Could you give an Example of how to use Console Commands with multiple arguments?

Edited by the hubster

Share this post


Link to post
Share on other sites
boomer678

Hey hazard. this may sound weird but how do i warp into a vehicle? like i wanna warp into a nrg900 i just spawned... but only when im holding control key. and press button on ingame menu . if im not pressing button it will just spawn and wont warp me into.

 

 

                    Case 1 : If key = Keys.ControlKey Then                           World.CreateVehicle("NRG900", Player.Character.Position.Around(3.0F))                           Game.DisplayText("NRG900 SPAWNED + WAPRED INTO")                           Player.Character.WarpIntoVehicle("NRG900", VehicleSeat.Driver)                       Else                           World.CreateVehicle("NRG900", Player.Character.Position.Around(3.0F))                           Game.DisplayText("NRG900 SPAWNED")                       End If

 

 

It says the "NRG900" can not be converted into gta.vehicle. how would it work?

Share this post


Link to post
Share on other sites
CoMPMStR

 

Hey hazard. this may sound weird but how do i warp into a vehicle? like i wanna warp into a nrg900 i just spawned... but only when im holding control key. and press button on ingame menu . if im not pressing button it will just spawn and wont warp me into.

 

 

                    Case 1 : If key = Keys.ControlKey Then                           World.CreateVehicle("NRG900", Player.Character.Position.Around(3.0F))                           Game.DisplayText("NRG900 SPAWNED + WAPRED INTO")                           Player.Character.WarpIntoVehicle("NRG900", VehicleSeat.Driver)                       Else                           World.CreateVehicle("NRG900", Player.Character.Position.Around(3.0F))                           Game.DisplayText("NRG900 SPAWNED")                       End If

 

 

It says the "NRG900" can not be converted into gta.vehicle. how would it work?

A string can't be converted into a vehicle class, this is how you should do it:

 

 

Dim v As Vehicle = World.CreateVehicle("NRG900", World.GetGroundPosition(Player.Character.Position.Around(3)))Player.Character.WarpIntoVehicle(v, VehicleSeat.Driver)

 

 

Just remember to call nolongerneeded afterward to free up any used memory.

 

 

@the hubster: Maybe you can try using a case switch for the parameter length, here's an small example in VB:

 

 

    Protected Overrides Sub ConsoleCommand(ByVal Command As String, ByVal Parameter() As String)       Select Case LCase(Command)           Case "command1"               Select Case Parameter.Length                   Case 0 'no parameters                   Case 1 '1 parameter                   Case 4 '4 parameters               End Select           Case "command2"       End Select   End Sub

 

Share this post


Link to post
Share on other sites
boomer678

 

Hey hazard. this may sound weird but how do i warp into a vehicle? like i wanna warp into a nrg900 i just spawned... but only when im holding control key. and press button on ingame menu . if im not pressing button it will just spawn and wont warp me into.

 

 

                    Case 1 : If key = Keys.ControlKey Then                           World.CreateVehicle("NRG900", Player.Character.Position.Around(3.0F))                           Game.DisplayText("NRG900 SPAWNED + WAPRED INTO")                           Player.Character.WarpIntoVehicle("NRG900", VehicleSeat.Driver)                       Else                           World.CreateVehicle("NRG900", Player.Character.Position.Around(3.0F))                           Game.DisplayText("NRG900 SPAWNED")                       End If

 

 

It says the "NRG900" can not be converted into gta.vehicle. how would it work?

A string can't be converted into a vehicle class, this is how you should do it:

 

 

Dim v As Vehicle = World.CreateVehicle("NRG900", World.GetGroundPosition(Player.Character.Position.Around(3)))Player.Character.WarpIntoVehicle(v, VehicleSeat.Driver)

 

 

Just remember to call nolongerneeded afterward to free up any used memory.

 

 

@the hubster: Maybe you can try using a case switch for the parameter length, here's an small example in VB:

 

 

    Protected Overrides Sub ConsoleCommand(ByVal Command As String, ByVal Parameter() As String)       Select Case LCase(Command)           Case "command1"               Select Case Parameter.Length                   Case 0 'no parameters                   Case 1 '1 parameter                   Case 4 '4 parameters               End Select           Case "command2"       End Select   End Sub

 

Thanks but i tried that already.. oh woops i typed it wrong thats why it wastnt working

Share this post


Link to post
Share on other sites
CleanShot

Hi Hazzard,

 

i experienced some problems when calling native functions via GTA.Native.Function.Call method (e.g. GET_ROOT_CAM).

I switched from Aru's C++ Script Hook to .NetScriptHook and I am very happy with coding my mods in C#.

Anyway, not all native functions in Aru's Script Hook are defined yet (some are left in ScriptingDirty.h) and have to be defined by the developers themselfes.

I did so and added a few native function definitions.

My question: Could it be that functions not being defined in Aru's C++ Script hook (Scripting.h) can't be used in .NetScriptHook? Don't you use Aru's Script Hook as unmanaged basis for wrapping it to .Net?

 

If so, here are some added native functions I added recently to my C++-based mods:

 

static void PreviewRingtone(u32 sound) { NativeInvoke::Invoke<scriptVoid>("PREVIEW_RINGTONE", sound); }

static void StopPreviewRingtone() { NativeInvoke::Invoke<scriptVoid>("STOP_PREVIEW_RINGTONE"); }

static void SetPlayerNeverGetsTired(Player playerIndex, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_PLAYER_NEVER_GETS_TIRED", playerIndex, value); }

static void SetPlayerFastReload(Player playerIndex, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_PLAYER_FAST_RELOAD", playerIndex, value); }

static void GiveWeaponToChar(Ped ped, eWeapon weapon, u32 ammo, b8 unknown) { NativeInvoke::Invoke<scriptVoid>("GIVE_WEAPON_TO_CHAR", ped, weapon, ammo, unknown); }

static void SetCharAmmo(Ped ped, eWeapon weapon, u32 ammo) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_AMMO", ped, weapon, ammo); }

static void SetCharVisible(Ped ped, u8 value) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_VISIBLE", ped, value); }

static void SetTimeScale(f32 scale) { NativeInvoke::Invoke<scriptVoid>("SET_TIME_SCALE", scale); }

static void SetInSpectatorMode(b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_IN_SPECTATOR_MODE", value); }

static void SetObjectCollision(Object object, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_OBJECT_COLLISION", object, value); }

//static void SetObjectCollision(Object object, eModel value) { NativeInvoke::Invoke<scriptVoid>("SET_OBJECT_COLLISION", object, value); }

static void SetObjectDynamic(Object object, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_OBJECT_DYNAMIC", object, value); }

static void SetLoadCollisionForObjectFlag(Object object, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_LOAD_COLLISION_FOR_OBJECT_FLAG", object, value); }

static void RequestCollisionForModel(eModel model) { NativeInvoke::Invoke<scriptVoid>("REQUEST_COLLISION_FOR_MODEL", model); }

static b8 HasCollisionForModelLoaded(eModel model) { return NativeInvoke::Invoke<scriptVoid>("HAS_COLLISION_FOR_MODEL_LOADED", model); }

static void SetObjectRotation(Object object, f32 x, f32 y, f32 z) { NativeInvoke::Invoke<scriptVoid>("SET_OBJECT_ROTATION", object, x, y, z); }

static void SetCharCoordinates(Ped ped, f32 x, f32 y, f32 z) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_COORDINATES", ped, x, y, z); }

static void GetCamPos(Cam cam, f32 *x, f32*y, f32 *z) { NativeInvoke::Invoke<scriptVoid>("GET_CAM_POS", cam, x, y, z); }

static void GetCamRot(Cam cam, f32 *x, f32*y, f32 *z) { NativeInvoke::Invoke<scriptVoid>("GET_CAM_ROT", cam, x, y, z); }

static void GetGameCam(Cam *cam) { NativeInvoke::Invoke<scriptVoid>("GET_GAME_CAM", cam); }

static void GetFreeCam(Cam *cam) { NativeInvoke::Invoke<scriptVoid>("GET_FREE_CAM", cam); }

static void GetRootCam(Cam *cam) { NativeInvoke::Invoke<scriptVoid>("GET_ROOT_CAM", cam); }

static void ApplyForceToCar(Vehicle car, u32 uk1, f32 x, f32 y, f32 z, f32 uk2, f32 uk3, f32 uk4, u32 uk5, u32 uk6, u32 uk7, u32 uk8) { NativeInvoke::Invoke<scriptVoid>("APPLY_FORCE_TO_CAR", car, uk1, x, y, z, uk2, uk3, uk4, uk5, uk6, uk7, uk8); }

static void ApplyForceToPed(Ped ped, u32 uk1, f32 x, f32 y, f32 z, f32 uk2, f32 uk3, f32 uk4, u32 uk5, u32 uk6, u32 uk7, u32 uk8) { NativeInvoke::Invoke<scriptVoid>("APPLY_FORCE_TO_PED", ped, uk1, x, y, z, uk2, uk3, uk4, uk5, uk6, uk7, uk8); }

static void ForcePedToLoadCover(Ped ped, b8 value) { NativeInvoke::Invoke<scriptVoid>("FORCE_PED_TO_LOAD_COVER", ped, value); }

static void SetObjectVisible(Object object, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_OBJECT_VISIBLE", object, value); }

static void ForceNetPlayerInvisible(Ped ped, b8 value) { NativeInvoke::Invoke<scriptVoid>("FORCE_NET_PLAYER_INVISIBLE", ped, value); }

static void NetworkGetPlayerIDOfNextTextChat(u32 *playerID) { NativeInvoke::Invoke<scriptVoid>("NETWORK_GET_PLAYER_ID_OF_NEXT_TEXT_CHAT", playerID); }

static void GetNetworkIDFromPed(Ped ped, u32 *networkID) { NativeInvoke::Invoke<scriptVoid>("GET_NETWORK_ID_FROM_PED", ped, networkID); }

static void DisplayPlayerNames(b8 value) { NativeInvoke::Invoke<scriptVoid>("DISPLAY_PLAYER_NAMES", value); }

static void NetworkKickPlayer(u32 networkID) { NativeInvoke::Invoke<scriptVoid>("NETWORK_KICK_PLAYER", networkID); }

static void SetPlayerInvisibleToAI(b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_PLAYER_INVISIBLE_TO_AI", value); }

static void AllowScenarioPedsToBeReturnedByNextCommand(b8 value) { NativeInvoke::Invoke<scriptVoid>("ALLOW_SCENARIO_PEDS_TO_BE_RETURNED_BY_NEXT_COMMAND", value); }

static void SetCharNeverLeavesGroup(Ped c, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_NEVER_LEAVES_GROUP", c, value); }

static void SetGroupLeader(Group group, Ped leader) { NativeInvoke::Invoke<scriptVoid>("SET_GROUP_LEADER", group, leader); }

static void SetGroupMember(Group group, Ped member) { NativeInvoke::Invoke<scriptVoid>("SET_GROUP_MEMBER", group, member); }

static void SetGroupFollowStatus(Group group, u32 status) { NativeInvoke::Invoke<scriptVoid>("SET_GROUP_FOLLOW_STATUS", group, status); }

static void SetGroupFormation(Group group, u32 formation) { NativeInvoke::Invoke<scriptVoid>("SET_GROUP_FORMATION", group, formation); }

static void SetGroupFormationSpacing(Group group, f32 space) { NativeInvoke::Invoke<scriptVoid>("SET_GROUP_FORMATION_SPACING", group, space); }

static void SetGroupSeparationRange(Group group, f32 seperation) { NativeInvoke::Invoke<scriptVoid>("SET_GROUP_SEPARATION_RANGE", group, seperation); }

static void SetCharInvincible(Ped c, b8 enable) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_INVINCIBLE", c, enable); }

static void SetCurrentCharWeapon(Ped c, eWeapon w, b8 unknownTrue) { NativeInvoke::Invoke<scriptVoid>("SET_CURRENT_CHAR_WEAPON", c, w, unknownTrue); }

static void TaskEnterCarAsDriver(Ped ped, Vehicle vehicle, u32 duration) { NativeInvoke::Invoke<scriptVoid>("TASK_ENTER_CAR_AS_DRIVER", ped, vehicle, duration); }

static void TaskWarpCharIntoCarAsDriver(Ped c, Vehicle v) { NativeInvoke::Invoke<scriptVoid>("TASK_WARP_CHAR_INTO_CAR_AS_DRIVER", c, v); }

static void TaskCarMission(Ped ped, Vehicle vehicle, u32 target, u32 missiontype, f32 speed, u32 drivingstyle, u32 unknown6_10, u32 unknown7_5) { NativeInvoke::Invoke<scriptVoid>("TASK_CAR_MISSION", ped, vehicle, target, missiontype, speed, drivingstyle, unknown6_10, unknown7_5); } // target is whatever missiontype requires (ie. vehicle or just 0). missiontypes: 5=wait(), 21=drivetoplayer()

static void TaskCarMissionPedTarget(Ped ped, Vehicle vehicle, Ped target, u32 unknown0_4, f32 speed, u32 unknown2_1, u32 unknown3_5, u32 unknown4_10) { NativeInvoke::Invoke<scriptVoid>("TASK_CAR_MISSION_PED_TARGET", ped, vehicle, target, unknown0_4, speed, unknown2_1, unknown3_5, unknown4_10); }

static void SetCharKeepTask(Ped c, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_KEEP_TASK", c, value); }

static void TaskLeaveAnyCar(Ped c) { NativeInvoke::Invoke<scriptVoid>("TASK_LEAVE_ANY_CAR", c); }

static void ApplyForceToObject(Object o, u32 uk0_3, f32 pX, f32 pY, f32 pZ, f32 spinX, f32 spinY, f32 spinZ, u32 uk4_0, u32 uk5_1, u32 uk6_1, u32 uk7_1) { NativeInvoke::Invoke<scriptVoid>("APPLY_FORCE_TO_OBJECT", o, uk0_3, pX, pY, pZ, spinX, spinY, spinZ, uk4_0, uk5_1, uk6_1, uk7_1); }

static void SetCarCanBeDamaged(Vehicle vehicle, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_CAR_CAN_BE_DAMAGED", vehicle, value); }

static void SetCarCoordinates(Vehicle vehicle, f32 pX, f32 pY, f32 pZ) { NativeInvoke::Invoke<scriptVoid>("SET_CAR_COORDINATES", vehicle, pX, pY, pZ); }

static void SetCarHeading(Vehicle vehicle, f32 dir) { NativeInvoke::Invoke<scriptVoid>("SET_CAR_HEADING", vehicle, dir); }

static void SetCarVisible(Vehicle vehicle, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_CAR_VISIBLE", vehicle, value); }

static void SetCarCanBeVisiblyDamaged(Vehicle vehicle, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_CAR_CAN_BE_VISIBLY_DAMAGED", vehicle, value); }

static void SetCarProofs(Vehicle vehicle, b8 bulletproof, b8 fireproof, b8 explosionproof, b8 collisionproof, b8 meleeproof) { NativeInvoke::Invoke<scriptVoid>("SET_CAR_PROOFS", vehicle, bulletproof, fireproof, explosionproof, collisionproof, meleeproof); }

static u32 StartScriptFire(f32 pX, f32 pY, f32 pZ, u32 unknown0_3, u32 unknown1_2) { return NativeInvoke::Invoke<u32>("START_SCRIPT_FIRE", pX, pY, pZ, unknown0_3, unknown1_2); }

static void SetEveryoneIgnorePlayer(u32 playerIndex, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_EVERYONE_IGNORE_PLAYER", playerIndex, value); }

//static Vehicle GetClosestCar(f32 x, f32 y, f32 z, f32 radius, u32 unknown0_0, u32 cartype) { return NativeInvoke::Invoke<Vehicle>("GET_CLOSEST_CAR", x, y, z, radius, unknown0_0, cartype); }

static void LockCarDoors(Vehicle vehicle, u32 level) { NativeInvoke::Invoke<scriptVoid>("LOCK_CAR_DOORS", vehicle, level); }

static ScriptAny StartObjectFire(Object o) { return NativeInvoke::Invoke<scriptAny>("START_OBJECT_FIRE", o); }

static void SetCamTargetPed(u32 camera, Ped ped) { NativeInvoke::Invoke<scriptVoid>("SET_CAM_TARGET_PED", camera, ped); }

static void CreateCam(u32 camtype_usually14, u32* camera) { NativeInvoke::Invoke<scriptVoid>("CREATE_CAM", camtype_usually14, camera); }

static void DestroyCam(u32 camera) { NativeInvoke::Invoke<scriptVoid>("DESTROY_CAM", camera); }

static void SetCamActive(u32 camera, bool value) { NativeInvoke::Invoke<scriptVoid>("SET_CAM_ACTIVE", camera, value); }

static void SetCameraControlsDisabledWithPlayerControls(bool value) { NativeInvoke::Invoke<scriptVoid>("SET_CAMERA_CONTROLS_DISABLED_WITH_PLAYER_CONTROLS", value); }

static void SetPedIsDrunk(Ped c, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_PED_IS_DRUNK", c, value); }

static void SetPedIsBlindRaging(Ped c, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_PED_IS_BLIND_RAGING", c, value); }

static void SetCamPropagate(u32 camera, bool value) { NativeInvoke::Invoke<scriptVoid>("SET_CAM_PROPAGATE", camera, value); }

static void SetCharCollision(Ped ped, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_COLLISION", ped, value); }

static void SetCharGravity(Ped c, f32 value) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_GRAVITY", c, value); }

static void SetCharHeading(Ped c, f32 dir) { NativeInvoke::Invoke<scriptVoid>("SET_CHAR_HEADING", c, dir); }

static void SetCarCollision(Vehicle vehicle, b8 value) { NativeInvoke::Invoke<scriptVoid>("SET_CAR_COLLISION", vehicle, value); }

static ScriptAny StartCharFire(Ped c) { return NativeInvoke::Invoke<scriptAny>("START_CHAR_FIRE", c); }

static void GetNetworkIdFromPed(Ped ped, u32 *id) { NativeInvoke::Invoke<scriptVoid>("GET_NETWORK_ID_FROM_PED", ped, id); }

 

I don't know if they all are absolutely correct, but most work very well.

Thanks for the great work.

 

 

Greetings to Hazzard County.

Share this post


Link to post
Share on other sites
loki114

Is there a forum some where or wiki that has the gta classes or anything

Share this post


Link to post
Share on other sites
HazardX
If i do the following i get the error message "the process cant access the file...blabla". The file it self is created in my GTA folder, but nothing gets written.

...

 

TextWriter tw = new StreamWriter("xxx.txt");...tw.WriteLine(model.Position.X);

 

You need a tw.Close(); to release the file handle and write the data to disk. I guess thats the problem here.

 

@the hubster: You can use a length of the parameter array to determine if there are enough parameters for you function. afterwards you have to convert the string parameters into the desired datatypes. in the next version the list of parameters will be a "ParameterCollection", which provides easy functions to convert parameters into common datatypes.

 

@CleanShot: What kind of problems do you have with Native.Function.Call? It should be possible to call all native methods with it. It is definately not limited to those implemented already. Yes, aru's C++ scripthook is the base for the .Net scripthook. Thanks for the function declarations, most of them are included already, but some are not yet.

 

@loki114: I don't think that a wiki is required, because Visual Studio tells you which functions and classes are available or which classes are taken/returned by a function. I'm also adding some infos to classes adn class members now, which are then shown in Visual Studio.

 

@CoMPMStR: Thanks ALOT for your excellent help to the people in this thread! I wouldn't be able to help everyone at the current speed the thread is moving with.

Share this post


Link to post
Share on other sites
loki114

.....had a stupid moment ingore this

Edited by loki114

Share this post


Link to post
Share on other sites
Mictian

Hello hazard ! Im trying to make Niko less accurate at shooting. But Player.Character.Accuracy acting weird. At values 50...0 the aiming circle getting bigger but not enough, inly 10-20%. I tried to set values like -5, -50, -999 then even 200, 999 but only thing i got is GREAT increase of accuracy! Aiming circle getting really small.

 

I have an idea that it because of accuracy values in WeaponInfo.xml, which is very small numbers. And Player.Character.Accuracy is based on these numbers. So when i change value to 50, it changes accuracy of pistol(for example) from 0.5 to 1(thats weird, but to make accuracy lower you have to rise those accuracy values up). But to make accuracy really low you need to make it about 90 or so.

 

Anyway, is it any way:) to to make Niko shoot less precisely by a script command?

 

PS I apologize for my English.

Share this post


Link to post
Share on other sites
CleanShot

Hello HazardX,

 

here is an example of a problem with native function call:

 

I try to get an instance (Camera) of the Root Camera with the help of GET_ROOT_CAM.

GET_ROOT_CAM takes a pointer to the camera to be returned. Using an object of the Native.Pointer class, which I pass to the native function call, it seems I never get a non-null result (pointer.Value is always null after calling native method).

In my C++-Skript, I get the Root Camera though.

Sometimes (not always), the error log says something about AccessViolation while calling GET_ROOT_CAM.

 

The Game.MainCamera returns only a valid camera if Niko is NOT aiming at something. When aiming (right mouse button), MainCamera is always null. I need to have information about camera rotation while Niko is aiming.

 

Anyway, native function APPLY_FORCE_TO_PED didn't work for me, too.

 

I'm not at home currently so I cannot post the exact code. If you want to have a look at it, tell me.

 

Despite these problems, coding mods with .Net is very comfortable and a great fun. Thank you.

 

BTW: Could you imagine to share the sources of your .Net script hook with us? I know this can be going to be a mess without a proper versioning system. Maybe we could start a project on sourceforge.net?

Share this post


Link to post
Share on other sites
Krailer

 

I'm trying to edit the bodyguard script to prevent dead guards from laying around, but the bodies never fade, not even when I use 'NoLongerNeeded'.

 

I'm most likely doing something wrong as this is pretty much my first experience with VB.NET, but anyway, these are the changes I made to the last sub of the script:

 

 code snipped ... 

 

Any advice? Thanks.

When I copied this snippet into VB it showed some errors with the code, maybe that's the problem. Another could be that you're calling NoLongerNeeded in the AddToGroup method which shouldn't be done IMO. Here's what I changed it to:

 

 

<snip>

 

 

I changed the AddToGroup method so it should be used only when adding a spawned ped. I added a new variable to keep track of all the spawned bodyguards, and also a new method to remove a bodyguard from the group by index. The Tick() event is used to keep watch over the bodyguards' health and remove them if they're dead. I hope this helps, it should work just fine.

You're right, the snippet I posted had a mistake that was preventing the script from working at all; I managed to get it running by removing the Group.isMember check, but still without the intended results.

 

Seems like you've implemented some advanced features in the BG script, I'd never guess there was so much room for improving the original script. I'll give it a try when I get home.

 

Thanks for all the help! icon14.gif

Share this post


Link to post
Share on other sites
Intosia

How come when i try to spawn something with a hash code it doesnt spawn? Are there limitations?

 

entry.mModel = World.CreateObject(0x4F6F0EC6, World.GetGroundPosition(Player.Character.Position.Around(2.0f)));

 

 

Share this post


Link to post
Share on other sites
CoMPMStR

 

How come when i try to spawn something with a hash code it doesnt spawn? Are there limitations?

 

entry.mModel = World.CreateObject(0x4F6F0EC6, World.GetGroundPosition(Player.Character.Position.Around(2.0f)));

I haven't noticed any limitations, maybe you're assigning the object to the wrong class type. I did this and it worked:

 

 

GTA.Object obj = World.CreateObject(0x4F6F0EC6, World.GetGroundPosition(Player.Character.Position.Around(2)));obj.Collision = true;

 

 

 

@Krailer: You can always improve the original scripts, they're just there for learning purposes. It's just a matter of if you know how to improve them. biggrin.gif

 

@HazardX: I'm glad to provide help, it helps you focus on the stuff that only you can fix. If I know a solution, or at least a work-around, I'm going to do my best to help out. It's the least I can do for you releasing such a great modding tool. wink.gif

 

EDIT: Are there any classes to use as variables for scripted fires? {StartScriptFire(f32 x, f32 y, f32 z, b8 unknown_0, b8 unknown_0)} I wanted to create a nice effect, like in this thread, but I didn't know what to use to delete them when needed (other than the native RemoveScriptFire, but what to pass as the parameter?).

Edited by CoMPMStR

Share this post


Link to post
Share on other sites
boomer678

Hey CoMPMStR or Hazard X...

 

How would you give a car a speed boost. Is it something to do with player.character.velocity? i tried playing around with that but couldnt get it to work.

Share this post


Link to post
Share on other sites
HazardX
How would you give a car a speed boost. Is it something to do with player.character.velocity? i tried playing around with that but couldnt get it to work.

No, player.character.velocity is the current movement of the character. You could try to do this every tick:

 

Player.Character.CurrentVehicle.Speed += 5.0F

 

 

I'm not sure about the value. It might be too much.

Share this post


Link to post
Share on other sites
CoMPMStR
Hey CoMPMStR or Hazard X...

 

How would you give a car a speed boost. Is it something to do with player.character.velocity? i tried playing around with that but couldnt get it to work.

Close..

 

 

Player.Character.CurrentVehicle.Speed

 

Share this post


Link to post
Share on other sites
boomer678
Hey CoMPMStR or Hazard X...

 

How would you give a car a speed boost. Is it something to do with player.character.velocity? i tried playing around with that but couldnt get it to work.

Close..

 

 

Player.Character.CurrentVehicle.Speed

 

Hahaha didnt even know that was there. Awesome

Share this post


Link to post
Share on other sites
HazardX

Okay, i've finally managed to get rid of the crashes on script/game reloading! happy.gif

 

If you care about the details: Scripts are running in their own AppDomain now, isolating them from the rest of the application. The whole AppDomain can be unloaded and thus all related memory can be freed at once. Additinally i've implemented my own fiber thread architecture, where each script is running in a fully managed .Net thread. Native scripting calls are then passed to an unmanaged game thread, which is waiting in background while the managed threads are running. The unmanaged thread executes the native call and hands the result back to the managed thread.

 

This way i was able to fix the crashes, but as a downside i have to add special treatment to critical native functions. Sadly i do not know which natives are critical. I found some already, but surely not all of them. If a critical native function is executed without the special treatment, it will result in an error (AccessViolation) or a game crash.

 

This is the point where i need your help. I'm unable to test every function myself. Thus my request for all script developers: Please download this test version. Test your scripts with it and report every function that causes an error or crash. Every function reported within the next 5 hours will most likely be fixed in the upcoming release.

 

Download the Testversion HERE!

 

IMPORTANT: This download ist a TESTVERSION for developers only! Don't release scripts for it and don't downlaod it if you do not intend to write you own scripts! A new full version will be released later (likely in 5-8 hours).

 

@CoMPMStR: Please test your "crash on INI loading" problem with this version. I hope that the new threading architecture fixed the problem.

Edited by HazardX

Share this post


Link to post
Share on other sites
Intosia

Awesome job man! Gonne try it out!

 

 

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.