StAfFMaN Posted June 18, 2016 Share Posted June 18, 2016 Hi everybody !! I'm trying to use this function but all my tests are grashing my game... : Function.Call<bool>(Hash.GET_CLOSEST_FIRE_POS, MarkerIntervention.Position.Length(), MarkerIntervention.Position.X, MarkerIntervention.Position.Y, MarkerIntervention.Position.Z); I've put this code in a loop ( tick(); ) with many terms to return everytime if it's true. If it's true, i would like get the vector3 coord and ask to my teammates to go at this point and do something. I've found this information : (here) FIRE::GET_CLOSEST_FIRE_POSHashes: 0x352A9F6BCF90081F 0xC4977B47BOOL GET_CLOSEST_FIRE_POS(Vector3 *outPosition, float x, float y, float z) // 0x352A9F6BCF90081F 0xC4977B47Returns TRUE if it found something. FALSE if not. But the problem is : i don't know what can i inquire to Vector3 *outPosition, float x, y and z... This is a part of my code (from my FireFighterMod) : bool existeFeu = Function.Call<bool>(Hash.GET_CLOSEST_FIRE_POS, MarkerIntervention.Position.Length(), MarkerIntervention.Position.X, MarkerIntervention.Position.Y, MarkerIntervention.Position.Z);if (PositionEntrePompierEtFeu < 15){ if (listeObjetsFeu[o].IsOnFire) { listePompier[i].Task.RunTo(PositionObjetEnFeu.Around(2f)); PompierVaAuFeu = true; } if (existeFeu == true) { UI.ShowSubtitle("existeFeu = " + existeFeu.ToString(), 2000); /*Vector3 PositionFeu = Function.Call<Vector3>(Hash.GET_CLOSEST_FIRE_POS, MarkerIntervention.Position.X + 15f, MarkerIntervention.Position.Y + 15f, MarkerIntervention.Position.Z + 15f); listePompier[i].Task.RunTo(PositionFeu.Around(2f)); PompierVaAuFeu = true;*/ }} Anybody have an example ? Anybody can help me please ? Thank a lot guys !! Best regard, [stAfF]MaN --- MaNfr Link to comment Share on other sites More sharing options...
Jitnaught Posted June 18, 2016 Share Posted June 18, 2016 OutputArgument outPos = new OutputArgument(); bool existeFeu = Function.Call<bool>(Hash.GET_CLOSEST_FIRE_POS, outPos, MarkerIntervention.Position.X, MarkerIntervention.Position.Y, MarkerIntervention.Position.Z); Vector3 pos = outPos.GetResult<Vector3>(); StAfFMaN 1 Link to comment Share on other sites More sharing options...
ins1de Posted June 18, 2016 Share Posted June 18, 2016 Here is how you should proceed : Get the position from where you want to start checking for fires Use an output argument Retrieve the result from the native call Code : OutputArgument argument = new OutputArgument(); // Create our argument ; this is the raw data we are getting from the native GET_CLOSEST_FIRE_POS Vector3 StartPosition = new Vector3(0F, 0F, 0F); // Position where we start looking for fires, of course you have to decide where to start looking for fires (replace 0F, 0F, 0F with your coords). Vector3 RealFirePosition; // If there is a close fire, this will be our Vector3 we need. bool closeFireExists = Function.Call<bool>(Hash.GET_CLOSEST_FIRE_POS, new InputArgument[] {argument, StartPosition.X, StartPosition.Y, StartPosition.Z}); if (closeFireExists) { RealFirePosition = argument.GetResult<Vector3>(); // Get our Vector3 new position } Normally this should work. StAfFMaN 1 Link to comment Share on other sites More sharing options...
StAfFMaN Posted June 18, 2016 Author Share Posted June 18, 2016 OutputArgument outPos = new OutputArgument();bool existeFeu = Function.Call<bool>(Hash.GET_CLOSEST_FIRE_POS, outPos, MarkerIntervention.Position.X, MarkerIntervention.Position.Y, MarkerIntervention.Position.Z);Vector3 pos = outPos.GetResult<Vector3>(); Here is how you should proceed : Get the position from where you want to start checking for fires Use an output argument Retrieve the result from the native call Code : OutputArgument argument = new OutputArgument(); // Create our argument ; this is the raw data we are getting from the native GET_CLOSEST_FIRE_POS Vector3 StartPosition = new Vector3(0F, 0F, 0F); // Position where we start looking for fires, of course you have to decide where to start looking for fires (replace 0F, 0F, 0F with your coords). Vector3 RealFirePosition; // If there is a close fire, this will be our Vector3 we need. bool closeFireExists = Function.Call<bool>(Hash.GET_CLOSEST_FIRE_POS, new InputArgument[] {argument, StartPosition.X, StartPosition.Y, StartPosition.Z}); if (closeFireExists) { RealFirePosition = argument.GetResult<Vector3>(); // Get our Vector3 new position } Normally this should work. Ok thanks a lot ! I will try that !! Feedback coming later ^^ Link to comment Share on other sites More sharing options...
unknown modder Posted June 19, 2016 Share Posted June 19, 2016 bool closeFireExists = Function.Call<bool>(Hash.GET_CLOSEST_FIRE_POS, new InputArgument[] {argument, StartPosition.X, StartPosition.Y, StartPosition.Z}); there is no need to do the conversion to InputArgument[], the Function.Call functions uses the params keyword which will tell the compiler to implicitly convert all input arguments passed to an InputArgument array. In short this is just as valid, but nicer to write Function.Call<bool>(Hash.GET_CLOSEST_FIRE_POS, argument, StartPosition.X, StartPosition.Y, StartPosition.Z); Jitnaught and StAfFMaN 2 Link to comment Share on other sites More sharing options...
StAfFMaN Posted June 19, 2016 Author Share Posted June 19, 2016 Awesome it's working pretty fine !! This is the code if anybody want an example (In the tick(); ) if (listePompier.Count != 0) // check if the list is different than 0 { if (SurLesLieux == true) { OutputArgument outPos = new OutputArgument(); bool existeFeu = Function.Call<bool>(Hash.GET_CLOSEST_FIRE_POS, outPos, MarkerIntervention.Position.X, MarkerIntervention.Position.Y, MarkerIntervention.Position.Z); // check if any fire exist from the X, Y, Z, pos and return true if it's found something and put the vector3 position in "outPos" foreach (Ped nouveauPompier in listePompier)// for all "nouveauPompier" element in the list { if (nouveauPompier.IsOnFoot)// check if he is on foot { if (existeFeu == true)// Check if "existeFeu" is true to return the vector3 of the fire { Vector3 PositionFeu = outPos.GetResult<Vector3>(); Return the Vector3 of the fire in "PositionFeu" float PositionEntrePompierEtFeu = World.GetDistance(nouveauPompier.Position, PositionFeu); // Get the distance between "nouveauPompier" and "PositionFeu" if (PositionEntrePompierEtFeu < 20) // Check if the distance between "nouveauPompier" and "positionFeu" is under 20 { if (!nouveauPompier.IsShooting)// check if "nouveauPompier" is NOT shooting { if (PompierVaAuFeu == false)// Check if "nouveauPompier" is NOT already running to "PositionFeu" { PompierVaAuFeu = true; nouveauPompier.Task.RunTo(PositionFeu.Around(2f));// If NOT, task for "nouveauPompier" to run at "positionFeu" and indicate "PompierVaAuFeu" is true } } } if (PositionEntrePompierEtFeu <= 3) // check if the distance between "nouveauPompier" and "PositionFeu" is under or equals than 3 { if (!nouveauPompier.IsShooting)// Check if "nouveauPompier" is NOT shooting { if (PompierVaAuFeu == true)// Check if "nouveauPompier" is running to "PositionFeu" { PompierVaAuFeu = false; // Indicate "nouveauPompier" is NOT running because he's arrived at "PositionFeu" nouveauPompier.Weapons.RemoveAll(); // Do remove all weapons nouveauPompier.Weapons.Give(WeaponHash.FireExtinguisher, -1, true, true); // Just give an extinguisher nouveauPompier.ShootRate = 100; // Set the shoot rate nouveauPompier.Task.ShootAt(PositionFeu, 3000, FiringPattern.FullAuto); // Task "nouveauPompier" shoot at the PositionFeu with the extinguisher during 3seconds } } } } } } UI.ShowSubtitle("existeFeu = ~r~" + existeFeu.ToString(), 500); // Debug text to know is any fire exist again } } If you think the code is not optimized, i'm listening you lol Thanks for all guys Best regard, [stAfF]MaN -- MaNfr 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