crosire Posted May 17, 2015 Author Share Posted May 17, 2015 Hello @Crosire do you think you will implement the getclosestped that was in the gta iv .net scripthook? as that would be great and help me out with getting the closestped to the player instead of basically having no easy way of doing it. See https://github.com/crosire/scripthookvdotnet/commit/2fc0f5de388f768eaaced449f19be62c7a1f822a. But it didn't test it yet. I've been trying to have some functions execute as soon as the game loads but I can't seem to get it to work. The onTick event seems to begin firing before the story mode has fully loaded, and I have tried waiting for Player.CanControlCharacter to return true before calling the functions but even that seems to return true before the game loads. An event like 'onGameLoad' would be very helpful, or just something that is definitely true only when the game has fully loaded that I can check. The game starts executing scripts when still on the loading screen, not much can be done about that. I don't know if there is a native to check if one is still sitting on the loading screen or not? But without that such an event is a bit complicated. The wiki probably should be updated with the following to work with the latest version of the .net loader. Done. Thanks for reporting! Link to comment Share on other sites More sharing options...
qwerasdzxc Posted May 17, 2015 Share Posted May 17, 2015 Can someone show me function and usage for GET_VEHICLE_PED_IS_USING please? I can't get it to work. Link to comment Share on other sites More sharing options...
crosire Posted May 17, 2015 Author Share Posted May 17, 2015 Can someone show me function and usage for GET_VEHICLE_PED_IS_USING please? Why not simply: Ped myPed = ...;Vehicle myVehicle = myPed.CurrentVehicle; Link to comment Share on other sites More sharing options...
qwerasdzxc Posted May 17, 2015 Share Posted May 17, 2015 Can someone show me function and usage for GET_VEHICLE_PED_IS_USING please? Why not simply: Ped myPed = ...;Vehicle myVehicle = myPed.CurrentVehicle; Okay, I realised that that's not what I wanted at first place. I want to spawn last vehicle that I was driving, any help for that? Link to comment Share on other sites More sharing options...
Mcfloy Posted May 17, 2015 Share Posted May 17, 2015 Okay, I realised that that's not what I wanted at first place. I want to spawn last vehicle that I was driving, any help for that? Just use LastVehicle on your player object. Link to comment Share on other sites More sharing options...
qwerasdzxc Posted May 17, 2015 Share Posted May 17, 2015 (edited) Okay, I realised that that's not what I wanted at first place. I want to spawn last vehicle that I was driving, any help for that? Just use LastVehicle on your player object. 'GTA.Ped' does not contain a definition for 'LastVehicle'And also when I try to spawn the car it says that it cannot convert from 'GTA.Vehicle' to 'GTA.Model' if I use something like Crosire suggested me. I am new to this so sorry if I'm acting a little newbish Edited May 17, 2015 by qwerasdzxc Link to comment Share on other sites More sharing options...
Mcfloy Posted May 17, 2015 Share Posted May 17, 2015 (edited) Try GTA.Player Game.Player* (That's a big difference, sorry) ;-) Edited May 17, 2015 by Mcfloy qwerasdzxc 1 Link to comment Share on other sites More sharing options...
unknown modder Posted May 17, 2015 Share Posted May 17, 2015 Hello @Crosire do you think you will implement the getclosestped that was in the gta iv .net scripthook? as that would be great and help me out with getting the closestped to the player instead of basically having no easy way of doing it. GetClosestPed like how iv net hook worked wont be here for a while. the way it worked on iv was manually searching the ped pool in memory. The GET_CLOSEST_PED native works, but wont find every kind of ped. GET_PED_NEARBY_PEDS only works with a ped handle, you cant plug game coordinates into there. Link to comment Share on other sites More sharing options...
Andross90 Posted May 17, 2015 Share Posted May 17, 2015 The game starts executing scripts when still on the loading screen, not much can be done about that. I don't know if there is a native to check if one is still sitting on the loading screen or not? But without that such an event is a bit complicated. Damn. Essentially what I want to do is create a blank or 'sandbox' environment in order to run my new planned single player game mode in, with no story elements getting in the way. What I currently do is kill all the game scripts currently active, using this list kindly provided by MulleDK19: http://link.to.mycomputer.treesoft.dk:1337/temp/clipboard%2816%29.txt This works fine if I activate this while in game, e.g. with a button press, but if its exectued during the loading screen it prevents the game from loading - and I've yet to figure out how to call the scripts just after the game has fully loaded. I wonder if the devs ever hardcoded in a sandbox environment themselves for testing, or if there is some other way to go about what I'm trying to achieve? Any help would be greatly appreciated. Incidentally do you use IRC at all? Link to comment Share on other sites More sharing options...
qwerasdzxc Posted May 17, 2015 Share Posted May 17, 2015 Try GTA.Player Game.Player* (That's a big difference, sorry) ;-) Nah, can't get it to work I'll PM you so we can keep the conversation there if you don't mind? Link to comment Share on other sites More sharing options...
NXT Posted May 17, 2015 Share Posted May 17, 2015 I may be wrong questioning this in this topic, but: How can I get the actual heading of the player, ingame? If there was an obvious way, I apologize for not getting it in the first place, but anyway I haven't found it yet. Since it's my first post here, let me say great job to all of you who make modding better every day. PD: and my English is not perfect, apologies for it. Link to comment Share on other sites More sharing options...
Inco Posted May 17, 2015 Share Posted May 17, 2015 (edited) Try GTA.Player Game.Player* (That's a big difference, sorry) ;-) Nah, can't get it to work I'll PM you so we can keep the conversation there if you don't mind? Vehicle veh = Game.Player.LastVehicle;Vehicle newVeh = World.CreateVehicle( veh.Model, Game.Player.Character.Position ); I may be wrong questioning this in this topic, but: How can I get the actual heading of the player, ingame? If there was an obvious way, I apologize for not getting it in the first place, but anyway I haven't found it yet. float heading = Game.Player.Character.Heading; Edited May 17, 2015 by Inco qwerasdzxc 1 Link to comment Share on other sites More sharing options...
qwerasdzxc Posted May 17, 2015 Share Posted May 17, 2015 Try GTA.Player Game.Player* (That's a big difference, sorry) ;-) Nah, can't get it to work I'll PM you so we can keep the conversation there if you don't mind? Vehicle veh = Game.Player.LastVehicle;Vehicle newVeh = World.CreateVehicle( veh.Model, Game.Player.Character.Position ); Yeah, thanks works now, I didn't use veh.Model, just veh so that was the problem. Link to comment Share on other sites More sharing options...
Cyron43 Posted May 17, 2015 Share Posted May 17, 2015 (edited) I am about to migrate my Undertaker mod from GTA IV but my code doesn't recognize dead peds. Here are the responsible excerpts: private IEnumerable<Ped> GetPedsAround() { var pedsAround = World.GetNearbyPeds(Game.Player.Character, _commonObjects.Configuration.CollectionRadius).ToList(); if(pedsAround.Count == 0) ReleaseUndertaker("Whoops, the undertaker had an accident! Call him again."); UI.Notify("DEBUG: " + pedsAround.Count + " peds found."); return pedsAround; } private void RegisterDeadBodies() { lock(SyncLock) { if(!CommonFunctions.PedExists(Game.Player.Character)) { _fail = true; UI.ShowSubtitle( "ERROR: Game claims player character doesn't exist anymore. Please try again.", 5000); return; } foreach(var ped in GetPedsAround().Where(ped => !ped.IsAlive || ped.IsDead || ped.Health <= 0)) { if(CommonFunctions.PedExists(ped)) { var newDeadPed = EnsureDeadPedIsNotAlreadyRegistered(ped); if(newDeadPed == null) continue; newDeadPed.SetRequiredForMission(true); _commonObjects.DeadPedsAround.Add(newDeadPed); } } UI.Notify("DEBUG: " + _commonObjects.DeadPedsAround.Count + " dead peds found."); } } private Ped EnsureDeadPedIsNotAlreadyRegistered(Ped ped) { if(_commonObjects.DeadPedsAround.Exists(p => ReferenceEquals(p, ped))) return null; return ped; } Usually I just check the Ped.IsDead property but that didn't work and so I also checked !Ped.IsAlive and Ped.Health but still nothing. As you can see by the debug messages in the screenshot the code finds two peds but allegedly none of them is dead. Edited May 17, 2015 by Cyron43 Link to comment Share on other sites More sharing options...
Mcfloy Posted May 17, 2015 Share Posted May 17, 2015 How can i get the purple target position on the map ? (If there's a function uncrypted) Link to comment Share on other sites More sharing options...
Inco Posted May 17, 2015 Share Posted May 17, 2015 (edited) I am about to migrate my Undertaker mod from GTA IV bu my code doesn't recognize dead peds. Here are the responsible excerpts: private IEnumerable<Ped> GetPedsAround() { var pedsAround = World.GetNearbyPeds(Game.Player.Character, _commonObjects.Configuration.CollectionRadius).ToList(); if(pedsAround.Count == 0) ReleaseUndertaker("Whoops, the undertaker had an accident! Call him again."); UI.Notify("DEBUG: " + pedsAround.Count + " peds found."); return pedsAround; } private void RegisterDeadBodies() { lock(SyncLock) { if(!CommonFunctions.PedExists(Game.Player.Character)) { _fail = true; UI.ShowSubtitle( "ERROR: Game claims player character doesn't exist anymore. Please try again.", 5000); return; } foreach(var ped in GetPedsAround().Where(ped => !ped.IsAlive || ped.IsDead || ped.Health <= 0)) { if(CommonFunctions.PedExists(ped)) { var newDeadPed = EnsureDeadPedIsNotAlreadyRegistered(ped); if(newDeadPed == null) return; newDeadPed.SetRequiredForMission(true); _commonObjects.DeadPedsAround.Add(newDeadPed); } } UI.Notify("DEBUG: " + _commonObjects.DeadPedsAround.Count + " dead peds found."); } } private Ped EnsureDeadPedIsNotAlreadyRegistered(Ped ped) { if(_commonObjects.DeadPedsAround.Exists(p => ReferenceEquals(p, ped))) return null; return ped; }Usually I just check the Ped.IsDead property but that didn't work and so I also checked !Ped.IsAlive and Ped.Health but still nothing.As you can see by the debug messages in the screenshot the code finds two peds but allegedly none of them is dead. Add some debug message to check if you got in foreach. The problem could be in your CommonFunctions.PedExists() method. How can i get the purple target position on the map ? (If there's a function uncrypted) Wait for approval World::GetActiveBlips() method. With this method you can do following: // type 4 - player's markerBlip blip = World.GetActiveBlips().FirstOrDefault( b => b.Type == 4 );if ( blip != null ){ player.Position = blip.Position; UI.ShowSubtitle( "Done", 2000 );}else{ UI.ShowSubtitle( "Not found", 2000 );} Edited May 17, 2015 by Inco Link to comment Share on other sites More sharing options...
Cyron43 Posted May 17, 2015 Share Posted May 17, 2015 (edited) Hi @Inco. CommonFunctions.PedExists just adds a null check to the Exists method of the .net script hook. I don't know if this is necessary with this one. It's a remnant from EFLC times where it was a necessity. I will do as you suggest just to make sure. I'll be back soon... public static bool PedExists(Ped ped) { lock(SyncLock) { return ped != null && ped.Exists(); } } Edited May 17, 2015 by Cyron43 Link to comment Share on other sites More sharing options...
Inco Posted May 17, 2015 Share Posted May 17, 2015 @Cyron43, just checked IsDead property and it's works fine. Link to comment Share on other sites More sharing options...
Cyron43 Posted May 17, 2015 Share Posted May 17, 2015 (edited) @Cyron43, just checked IsDead property and it's works fine. I have set a debug message into the foreach loop right at the start but it never appeared in the game. So my conclusion is that none of the checks in the Where clause returned true. Heck! o_0 EDIT: Found something interesting. I inserted a kill for debugging and the fresh kills got registered (6). I dismissed the undertaker before he could collect the dead bodies. Then I waited for a few seconds and called him again and 4 new peds got killed and registered BUT not the other 6 from before! Is it, by any chance, possible that the game replaces dead peds after a short while with some "puppet" objects that just look like peds? EDIT2: Yep Trevor was surrounded by 10 dead bodies but the debug message claims there were 0 peds (dead or alive) around. private void RegisterDeadBodies() { lock(SyncLock) { if(!CommonFunctions.PedExists(Game.Player.Character)) { _fail = true; UI.ShowSubtitle( "ERROR: Game claims player character doesn't exist anymore. Please try again.", 5000); return; } foreach(var ped in GetPedsAround()) { UI.Notify("foreach loop"); KillForDebug(ped); if(!ped.IsAlive || ped.IsDead || ped.Health <= 0) { if(CommonFunctions.PedExists(ped)) { var newDeadPed = EnsureDeadPedIsNotAlreadyRegistered(ped); if(newDeadPed == null) continue; //question: shouldn't it be continue? newDeadPed.SetRequiredForMission(true); _commonObjects.DeadPedsAround.Add(newDeadPed); } } } UI.Notify("DEBUG: " + _commonObjects.DeadPedsAround.Count + " dead peds found."); } } private void KillForDebug(Ped ped) { if(!ReferenceEquals(Game.Player.Character, ped)) ped.Kill(); } Edited May 17, 2015 by Cyron43 Link to comment Share on other sites More sharing options...
Inco Posted May 17, 2015 Share Posted May 17, 2015 (edited) It seems like GetNearbyPeds returns only alive peds. Code: IEnumerable<Ped> GetPedsAround(){ return World.GetNearbyPeds( Game.Player.Character, 3f ).ToList();}void OnKeyDown( object sender, KeyEventArgs e ){ Ped player = Game.Player.Character; if ( e.KeyData == Keys.I ) { UI.ShowSubtitle( "Peds: " + this.GetPedsAround().Count(), 2000 ); } if ( e.KeyData == Keys.L ) { _peds.Add( World.CreatePed( PedHash.Beach01AFM, player.Position ) ); _peds.Add( World.CreatePed( PedHash.Beach01AFM, player.Position ) ); foreach ( Ped ped in _peds ) { ped.BlockPermanentEvents = true; } }} Edited May 17, 2015 by Inco Link to comment Share on other sites More sharing options...
Andross90 Posted May 17, 2015 Share Posted May 17, 2015 (edited) Could someone provide me with an example of displaying text clearly at the centre of the screen? Thanks. edit: nevermind figured it out, forgot it had to be drawn every tick! Edited May 17, 2015 by Andross90 Link to comment Share on other sites More sharing options...
Nacorpio Posted May 17, 2015 Share Posted May 17, 2015 (edited) Edit: Nevermind Edited May 17, 2015 by Nacorpio Link to comment Share on other sites More sharing options...
Cyron43 Posted May 17, 2015 Share Posted May 17, 2015 (edited) Thank you for your help @Inco. Now that's a problem. I just had a look into the natives db (keyword "dead") but I couldn't find anything appropriate. :-/ @Nacorpio: That's a misunderstanding. I do the null check because GTA IV caused object disposing all the time to reduce memory consumption and so each time I want to access a vehicle or a ped I had to check for it's existence before. As I said before this is a remnant from GTA IV times and I don't know if this is still necessary with GTA V but at least it shouldn't cause a problem to do an extra check. Inco is right, GetNearbyPeds is the culprit. Anyway I modified the code but that doesn't fix it. The code is just more logical now. //...if(CommonFunctions.PedExists(ped) && !_commonObjects.DeadPedsAround.Contains(ped)) { ped.SetRequiredForMission(true); _commonObjects.DeadPedsAround.Add(ped); } else continue; //... Edited May 18, 2015 by Cyron43 Link to comment Share on other sites More sharing options...
NXT Posted May 17, 2015 Share Posted May 17, 2015 I may be wrong questioning this in this topic, but: How can I get the actual heading of the player, ingame? If there was an obvious way, I apologize for not getting it in the first place, but anyway I haven't found it yet. float heading = Game.Player.Character.Heading; Thanks for that, it did the work. But now I have another concern, and it is regarding ped|car density. I've been looking for natives and there are some lines that would allegedly work, but I can't get them to do the job: void SET_PED_DENSITY_MULTIPLIER_THIS_FRAME(float multiplier) void SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME(float p0) void SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME(float p0) I tried to set the parameters to 0.0 but it did nothing: GTA.Native.Function.Call(Hash.SET_PED_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) GTA.Native.Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) GTA.Native.Function.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) I may be doing something stupid, but even If I am, can't figure what it is. Could someone help me? Link to comment Share on other sites More sharing options...
Ethenal Posted May 17, 2015 Share Posted May 17, 2015 I've been looking for natives and there are some lines that would allegedly work, but I can't get them to do the job: void SET_PED_DENSITY_MULTIPLIER_THIS_FRAME(float multiplier) void SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME(float p0) void SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME(float p0) I tried to set the parameters to 0.0 but it did nothing: GTA.Native.Function.Call(Hash.SET_PED_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) GTA.Native.Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) GTA.Native.Function.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) I may be doing something stupid, but even If I am, can't figure what it is. Could someone help me? Are you calling those in a "Tick" event? They each end in "THIS_FRAME" - so they'll all need to be called once each frame. I think you can do this with a Tick event with Interval set to 0 (once per frame). Link to comment Share on other sites More sharing options...
julionib Posted May 18, 2015 Share Posted May 18, 2015 How we create and handle objecs in .net scripthookv? im trying to use the CREATE_OBJECT native but i cant obtain a entity to handle (dont know what is the correct type to use as return). SO, i sapwn the object but cant control it. Also, someone have used the DELETE_ROPE method? I always obtain scripthook .asi script crash (asi loader message) when i try to use it (im using Native.InputArgument in the parameter) Link to comment Share on other sites More sharing options...
Inco Posted May 18, 2015 Share Posted May 18, 2015 dont know what is the correct type to use as return Try int. Link to comment Share on other sites More sharing options...
Moder L Posted May 18, 2015 Share Posted May 18, 2015 Hello, is there a method which will return all vehicle models? Link to comment Share on other sites More sharing options...
Inco Posted May 18, 2015 Share Posted May 18, 2015 Hello, is there a method which will return all vehicle models? VehicleHash[] allModels = Enum.GetValues( typeof( VehicleHash ) ).Cast<VehicleHash>().ToArray(); Why not Link to comment Share on other sites More sharing options...
Moder L Posted May 18, 2015 Share Posted May 18, 2015 Thanks, and to get vehicle type I need to crete model first, right? 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