Wiebrendh Posted May 1, 2014 Share Posted May 1, 2014 Hi all, i am currently working on The Heist for my robbery mod, but i have some troubles with one part.. How do i spawn a a car, with niko on the drivers seat, and a ped on the other seat. And when niko leaves the car, the ped will follow niko and kill the police. Thanks in advance! Link to comment Share on other sites More sharing options...
Rugz007 Posted May 1, 2014 Share Posted May 1, 2014 (edited) let me give you the code for it.... Edited May 1, 2014 by Rugz007 Link to comment Share on other sites More sharing options...
julionib Posted May 1, 2014 Share Posted May 1, 2014 (edited) you can create a gta group and add the passenger to it, then this guy will follow niko and help him, give some guns to him the car you can create then task warp player inside Edited May 1, 2014 by julionib Link to comment Share on other sites More sharing options...
Wiebrendh Posted May 1, 2014 Author Share Posted May 1, 2014 you can create a gta group and add the passenger to it, then this guy will follow niko and help him, give some guns to him the car you can create then task warp player inside Could you give me an example? I don't understand natives very good.. Especially when there is no description attached http://www.gtamodding.com/index.php?title=CREATE_GROUPto it Link to comment Share on other sites More sharing options...
NTAuthority Posted May 1, 2014 Share Posted May 1, 2014 you typically don't create a group, you'd GET_PLAYER_GROUP the player's group which automatically has the player as a leader Inactive in GTA/R* title modification indefinitely pursuant to a court order obtained by TTWO. Good job acting against modding! Link to comment Share on other sites More sharing options...
julionib Posted May 1, 2014 Share Posted May 1, 2014 you typically don't create a group, you'd GET_PLAYER_GROUP the player's group which automatically has the player as a leader cool @Wiebrendh: example of warp: player.character.task.warpIntoVehicle(desiredVeh, vehicleSeat.driver) or, less safe way: player.character.warpIntoVehicle(desiredVeh, vehicleSeat.driver) Link to comment Share on other sites More sharing options...
Wiebrendh Posted May 1, 2014 Author Share Posted May 1, 2014 you typically don't create a group, you'd GET_PLAYER_GROUP the player's group which automatically has the player as a leader Oke, that is kinda logic And, how do i spawn a ped? And set the ped id into an int Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 1, 2014 Share Posted May 1, 2014 (edited) Hi all, i am currently working on The Heist for my robbery mod, but i have some troubles with one part.. How do i spawn a a car, with niko on the drivers seat, and a ped on the other seat. And when niko leaves the car, the ped will follow niko and kill the police. Thanks in advance! namespace PlayerGroupExample{ using System; using System.Windows.Forms; using GTA; public class Main : Script { private Ped bodyguard; public Main() { BindKey(Keys.Insert, delegate { if (Game.Exists(bodyguard)) return; Vehicle v = World.CreateVehicle(World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(5f))); Game.LocalPlayer.Character.WarpIntoVehicle(v, VehicleSeat.Driver); bodyguard = v.CreatePedOnSeat(VehicleSeat.RightFront); bodyguard.Weapons.MP5.Ammo = 500; Game.LocalPlayer.Group.AddMember(bodyguard); Tick += BodyguardTick; }); } private void BodyguardTick(object sender, EventArgs e) { if (!Game.Exists(bodyguard)) { Tick -= BodyguardTick; return; } if (!bodyguard.isAliveAndWell) { if (Game.LocalPlayer.Group.isMember(bodyguard)) { BugFreeRemovePlayerGroupMember(bodyguard); } bodyguard.NoLongerNeeded(); bodyguard = null; Tick -= BodyguardTick; return; } //in this method u can provide any specific instructions u like for your bodyguard // I already made sure he exists and is alive... so do whatever u want with him } private void BugFreeRemovePlayerGroupMember(Ped groupMember) { //removing members is bugged so u have to remove all and add back who u wanted to keep Ped[] group = Game.LocalPlayer.Group.ToArray(false); Game.LocalPlayer.Group.RemoveAllMembers(); for (int i = 0; i < group.Length; i++) { if (group[i] == groupMember) continue; Game.LocalPlayer.Group.AddMember(group[i]); } } }} btw i notice lots of new scripthookdotnet developers constantly trying to use natives that are already wrapped in the scripthookdotnet. U dont need to lookup native functions most of the time. The scripthookdotnet already does most of what u need to do Edited May 1, 2014 by LordOfTheBongs Link to comment Share on other sites More sharing options...
Wiebrendh Posted May 1, 2014 Author Share Posted May 1, 2014 Hi all, i am currently working on The Heist for my robbery mod, but i have some troubles with one part.. How do i spawn a a car, with niko on the drivers seat, and a ped on the other seat. And when niko leaves the car, the ped will follow niko and kill the police. Thanks in advance! namespace PlayerGroupExample{ using System; using System.Windows.Forms; using GTA; public class Main : Script { private Ped bodyguard; public Main() { BindKey(Keys.Insert, delegate { if (Game.Exists(bodyguard)) return; Vehicle v = World.CreateVehicle(World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(5f))); Game.LocalPlayer.Character.WarpIntoVehicle(v, VehicleSeat.Driver); bodyguard = v.CreatePedOnSeat(VehicleSeat.RightFront); bodyguard.Weapons.MP5.Ammo = 500; Game.LocalPlayer.Group.AddMember(bodyguard); Tick += BodyguardTick; }); } private void BodyguardTick(object sender, EventArgs e) { if (!Game.Exists(bodyguard)) { Tick -= BodyguardTick; return; } if (!bodyguard.isAliveAndWell) { if (Game.LocalPlayer.Group.isMember(bodyguard)) { BugFreeRemovePlayerGroupMember(bodyguard); } bodyguard.NoLongerNeeded(); bodyguard = null; Tick -= BodyguardTick; return; } //in this method u can provide any specific instructions u like for your bodyguard // I already made sure he exists and is alive... so do whatever u want with him } private void BugFreeRemovePlayerGroupMember(Ped groupMember) { //removing members is bugged so u have to remove all and add back who u wanted to keep Ped[] group = Game.LocalPlayer.Group.ToArray(false); Game.LocalPlayer.Group.RemoveAllMembers(); for (int i = 0; i < group.Length; i++) { if (group[i] == groupMember) continue; Game.LocalPlayer.Group.AddMember(group[i]); } } }} btw i notice lots of new scripthookdotnet developers constantly trying to use natives that are already wrapped in the scripthookdotnet. U dont need to lookup native functions most of the time. The scripthookdotnet already does most of what u need to do nice, thanks! This will definitely help me a lot! Thanks mate! LordOfTheBongs 1 Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 1, 2014 Share Posted May 1, 2014 (edited) you typically don't create a group, you'd GET_PLAYER_GROUP the player's group which automatically has the player as a leader cool @Wiebrendh: example of warp: player.character.task.warpIntoVehicle(desiredVeh, vehicleSeat.driver) or, less safe way: player.character.warpIntoVehicle(desiredVeh, vehicleSeat.driver) they both do the exact same thing, what do u mean by safer? they do use different natives... maybe one wasnt meant to be used Ped: http://i.imgur.com/QuuR66u.png Task: http://i.imgur.com/8l1PMoH.png Edited May 1, 2014 by LordOfTheBongs Link to comment Share on other sites More sharing options...
pedro2555 Posted May 1, 2014 Share Posted May 1, 2014 you typically don't create a group, you'd GET_PLAYER_GROUP the player's group which automatically has the player as a leader cool @Wiebrendh: example of warp: player.character.task.warpIntoVehicle(desiredVeh, vehicleSeat.driver) or, less safe way: player.character.warpIntoVehicle(desiredVeh, vehicleSeat.driver) they both do the exact same thing, what do u mean by safer? they do use different natives... maybe one wasnt meant to be used Ped: http://i.imgur.com/QuuR66u.png Task: http://i.imgur.com/8l1PMoH.png I might be wrong on this, I've never tested it. But it looks like to me, that Ped.WarpIntoVehicle() simply warps the ped to a specified vehicle upon calling, whitest Taks.WarpIntoVehicle() warps the ped to a specified vehicle respecting a task sequence execution. Link to comment Share on other sites More sharing options...
pedro2555 Posted May 1, 2014 Share Posted May 1, 2014 @LordOfTheBongs I've noticed you using iLSpy for finding the underlying operations from .NET Scripthook, but actually .NET Scripthook is open source and the full solution is available for download at HazardX website. You get a better acurary reading the actual source, Ped.WarpIntoVehicle is actually like this: void Ped::WarpIntoVehicle(GTA::Vehicle^ Vehicle, VehicleSeat Seat) { NON_EXISTING_CHECK(); OBJECT_NON_EXISTING_CHECK(Vehicle); if (Seat <= VehicleSeat::None) return; if (Seat == VehicleSeat::Driver) { Scripting::WarpCharIntoCar(pHandle,Vehicle->Handle); } else { if (isInVehicle(Vehicle)) Scripting::WarpCharFromCarToCar(pHandle,Vehicle->Handle,(int)Seat); // change seat else Scripting::WarpCharIntoCarAsPassenger(pHandle,Vehicle->Handle,(int)Seat); }} Link to comment Share on other sites More sharing options...
LordOfTheBongs Posted May 1, 2014 Share Posted May 1, 2014 (edited) @LordOfTheBongs I've noticed you using iLSpy for finding the underlying operations from .NET Scripthook, but actually .NET Scripthook is open source and the full solution is available for download at HazardX website. You get a better acurary reading the actual source, Ped.WarpIntoVehicle is actually like this: void Ped::WarpIntoVehicle(GTA::Vehicle^ Vehicle, VehicleSeat Seat) { NON_EXISTING_CHECK(); OBJECT_NON_EXISTING_CHECK(Vehicle); if (Seat <= VehicleSeat::None) return; if (Seat == VehicleSeat::Driver) { Scripting::WarpCharIntoCar(pHandle,Vehicle->Handle); } else { if (isInVehicle(Vehicle)) Scripting::WarpCharFromCarToCar(pHandle,Vehicle->Handle,(int)Seat); // change seat else Scripting::WarpCharIntoCarAsPassenger(pHandle,Vehicle->Handle,(int)Seat); }} i know i have it, i like using the treeview control in ilspy than navigating the files in the project... for me it's faster plus c++/clr coding style is ugly, id rather read it in c# Edited May 1, 2014 by LordOfTheBongs Wiebrendh 1 Link to comment Share on other sites More sharing options...
pedro2555 Posted May 2, 2014 Share Posted May 2, 2014 @LordOfTheBongs I've noticed you using iLSpy for finding the underlying operations from .NET Scripthook, but actually .NET Scripthook is open source and the full solution is available for download at HazardX website. You get a better acurary reading the actual source, Ped.WarpIntoVehicle is actually like this: void Ped::WarpIntoVehicle(GTA::Vehicle^ Vehicle, VehicleSeat Seat) { NON_EXISTING_CHECK(); OBJECT_NON_EXISTING_CHECK(Vehicle); if (Seat <= VehicleSeat::None) return; if (Seat == VehicleSeat::Driver) { Scripting::WarpCharIntoCar(pHandle,Vehicle->Handle); } else { if (isInVehicle(Vehicle)) Scripting::WarpCharFromCarToCar(pHandle,Vehicle->Handle,(int)Seat); // change seat else Scripting::WarpCharIntoCarAsPassenger(pHandle,Vehicle->Handle,(int)Seat); }} i know i have it, i like using the treeview control in ilspy than navigating the files in the project... for me it's faster plus c++/clr coding style is ugly, id rather read it in c# Fair enough. LordOfTheBongs 1 Link to comment Share on other sites More sharing options...
julionib Posted May 2, 2014 Share Posted May 2, 2014 the thing about use Task.Warp... instead of Warp... is that sometimes the direct warp causes memory error in script and we cant handle in exception, this result in script crash i had this issue in the first mod i made (myTelekinesis powers) and started to use Task, the problem with task is that it may take some extra time to warp even to a free passenger seat pedro2555, Wiebrendh and LordOfTheBongs 3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now