Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

    2. Forum Support

    3. Suggestions

Getting Coordinates of all Objects seen on Screen


husseinh
 Share

Recommended Posts

Hallo, i am trying to get the coordinates of the (Cars, Peds, Trains etc..) around me while walking or driving.

 

I've got my position using (Game.Player.character.Position) and saved them in a .txt file.

 

Do anyone know how to get the positions for others?

 

Thanks!!

Link to comment
Share on other sites

World.GetAllEntities()

​Thank you it works:)

I'm now using World.getAllPeds() and World.getAllvehicles() to know if it is Ped or Vehicle.

Is there any way to know the Kind of the Vehicle? i mean to know if it's a Car or Bus or Train for example?

How can i do this in external?

 

Your way just works in an internal or?

what do you mean by Internal and external? if you mean online and offline so i'm trying it just for offline

Link to comment
Share on other sites

To find what the vehicle is, you can do something like this

if (collectedVehicle.Model.IsCar){}else if (collectedVehicle.Model.IsHelicopter){}

Or you can test the Class, like this

switch (collectedVehicle.ClassType){    case VehicleClass.Coupes:        break;    case VehicleClass.Helicopters:        break;}
Edited by Guest
Link to comment
Share on other sites

 

what do you mean by Internal and external? if you mean online and offline so i'm trying it just for offline

 

Internal is mostly a dll which you inject into the process and then play with its NATIVES and stuff.

 

External is only memory manipulating by accessing the Basepointer + Offsets. From an external coded tool (no injection needed)

Link to comment
Share on other sites

 

To find what the vehicle is, you can do something like this

if (collectedVehicle.Model.IsCar){}else if (collectedVehicle.Model.IsHelicopter){}

Or you can test the Class, like this

switch (collectedVehicle.ClassType){    case VehicleClass.Coupes:        break;    case VehicleClass.Helicopters:        break;}

Great.it working!

Is there anyway to start the Mod Automaticaly? i mean without pressing any Key...so i would like to get the cars around me in real Time!

I tried to use:

While(Player.isAlive)

{

//Do

}

 

but the Game stoped due to the BigData

 

 

what do you mean by Internal and external? if you mean online and offline so i'm trying it just for offline

 

Internal is mostly a dll which you inject into the process and then play with its NATIVES and stuff.

 

External is only memory manipulating by accessing the Basepointer + Offsets. From an external coded tool (no injection needed)

 

 

 

 

 

what do you mean by Internal and external? if you mean online and offline so i'm trying it just for offline

 

Internal is mostly a dll which you inject into the process and then play with its NATIVES and stuff.

 

External is only memory manipulating by accessing the Basepointer + Offsets. From an external coded tool (no injection needed)

 

ok so i'm trying it internal...you can send me a link for external modifications

Link to comment
Share on other sites

While and Do loops are intended to be used for situations where you know the condition will change, allowing them to drop out of the loop, they are not ideal for collection processing because they don't iterate through a collection. You could make them do that but there are better solutions.

 

Collect the vehicles into an array or List, then use either a foreach() loop, or a simple for() loop.

foreach (Vehicle v in vehiclearray){// Do some stuff}

or

for (int x = 0; x < vehiclearray.Count; x++){    Vehicle v = vehiclearray[x];    // Do some stuff}

That way, once the collection has been processed, the game can continue.

 

I actually wrote up a topic on this subject on GTA5-Mods with an optimised collection/processing system I designed. If you want to have a read of that, it's here. https://forums.gta5-mods.com/topic/5499/tip-code-optimised-getnearbyvehicles-ped-process

 

It's marked as guest now because I closed my account there but I asked them to leave all the posts intact so that the information was left available for other users.

Edited by Guest
Link to comment
Share on other sites

While and Do loops are intended to be used for situations where you know the condition will change, allowing them to drop out of the loop, they are not ideal for collection processing because they don't iterate through a collection. You could make them do that but there are better solutions.

 

Collect the vehicles into an array or List, then use either a foreach() loop, or a simple for() loop.

foreach (Vehicle v in vehiclearray){// Do some stuff}

or

for (int x = 0; x < vehiclearray.Count; x++){    Vehicle v = vehiclearray[x];    // Do some stuff}

That way, once the collection has been processed, the game can continue.

 

I actually wrote up a topic on this subject on GTA5-Mods with an optimised collection/processing system I designed. If you want to have a read of that, it's here. https://forums.gta5-mods.com/topic/5499/tip-code-optimised-getnearbyvehicles-ped-process

 

It's marked as guest now because I closed my account there but I asked them to leave all the posts intact so that the information was left available for other users.

            float x = Game.Player.Character.Position.X;            float y = Game.Player.Character.Position.Y;            float z = Game.Player.Character.Position.Z;            Vehicle[] CollectedVehicle = World.GetNearbyVehicles(Game.Player.Character, 10f);            foreach (Vehicle collectedVeh in CollectedVehicle)            {                                       Vector3 VehPosition = new Vector3(collectedVeh.Position.X, collectedVeh.Position.Y, collectedVeh.Position.Z);                    Vector3 PlayerPosition = new Vector3(x, y, z);                                                  }
Edited by husseinh
Link to comment
Share on other sites

@LeeC2202 I checked the link you sent it and it is really very interresting in how you get the Zones and the Area for the CollectedVehicles and specially the red 3D BOX which is surrounding the Helicopter.

 

v.Model.GetDimensions(); gives me the 3 dimensions of a Car like (X: Y: Z:), but could you tell me please how to get it drown on Screen as you made for your Helicopter?

 

Thank you very much!

Link to comment
Share on other sites

@LeeC2202 I checked the link you sent it and it is really very interresting in how you get the Zones and the Area for the CollectedVehicles and specially the red 3D BOX which is surrounding the Helicopter.

 

v.Model.GetDimensions(); gives me the 3 dimensions of a Car like (X: Y: Z:), but could you tell me please how to get it drown on Screen as you made for your Helicopter?

 

Thank you very much!

 

It's actually very simple. Use the function that gets you the minimum and maximum dimensions and build a List<Vector3> of corner points, you will get 8 points.

Vector3 MinDimensions = new Vector3();Vector3 MaxDimensions = new Vector3();Vehicle.Model.GetDimensions(out MinDimensions, out MaxDimensions);

then something like this. If MinDimensions and MaxDimensions are not defined globally, then you need to put this code in the same function as the one that gets the dimensions above.

private void CreatePoints(){	CornerPoints.Clear();	CornerPoints.Add(new Vector3(MinDimensions.X, MinDimensions.Y, MinDimensions.Z));	CornerPoints.Add(new Vector3(MinDimensions.X, MaxDimensions.Y, MinDimensions.Z));	CornerPoints.Add(new Vector3(MaxDimensions.X, MaxDimensions.Y, MinDimensions.Z));	CornerPoints.Add(new Vector3(MaxDimensions.X, MinDimensions.Y, MinDimensions.Z));	CornerPoints.Add(new Vector3(MinDimensions.X, MinDimensions.Y, MaxDimensions.Z));	CornerPoints.Add(new Vector3(MinDimensions.X, MaxDimensions.Y, MaxDimensions.Z));	CornerPoints.Add(new Vector3(MaxDimensions.X, MaxDimensions.Y, MaxDimensions.Z));	CornerPoints.Add(new Vector3(MaxDimensions.X, MinDimensions.Y, MaxDimensions.Z));}

Then use the GetOffsetInWorldCoords() function on each of those corner points from the Vehicle and draw lines between them using a drawline function like this.

public static void DrawLine(Vector3 start, Vector3 end, Color colour){	Function.Call(Hash.DRAW_LINE, start.X, start.Y, start.Z, end.X, end.Y, end.Z, colour.R, colour.G, colour.B, colour.A);}

That will ensure that no matter how the model rotates, the corners will rotate relative to it. This also works for Peds and Props of course, it's not just for Vehicles.

 

I should just add, you should only collect the corner points once and then store those in a class that links those corners with that Vehicle. You don't want to be grabbing model dimensions every frame, it's just wasted cycles if you do that.

 

Or you could create a Dictionary<int, List<Vector3>> that has the model hash as the key and the corner points as the DIctionary value. Like everything, there are many ways to achieve the goal, you just have to find the one that you are most comfortable using.

Edited by Guest
Link to comment
Share on other sites

 

@LeeC2202 I checked the link you sent it and it is really very interresting in how you get the Zones and the Area for the CollectedVehicles and specially the red 3D BOX which is surrounding the Helicopter.

 

v.Model.GetDimensions(); gives me the 3 dimensions of a Car like (X: Y: Z:), but could you tell me please how to get it drown on Screen as you made for your Helicopter?

 

Thank you very much!

 

It's actually very simple. Use the function that gets you the minimum and maximum dimensions and build a List<Vector3> of corner points, you will get 8 points.

Vector3 MinDimensions = new Vector3();Vector3 MaxDimensions = new Vector3();Vehicle.Model.GetDimensions(out MinDimensions, out MaxDimensions);

then something like this. If MinDimensions and MaxDimensions are not defined globally, then you need to put this code in the same function as the one that gets the dimensions above.

private void CreatePoints(){	CornerPoints.Clear();	CornerPoints.Add(new Vector3(MinDimensions.X, MinDimensions.Y, MinDimensions.Z));	CornerPoints.Add(new Vector3(MinDimensions.X, MaxDimensions.Y, MinDimensions.Z));	CornerPoints.Add(new Vector3(MaxDimensions.X, MaxDimensions.Y, MinDimensions.Z));	CornerPoints.Add(new Vector3(MaxDimensions.X, MinDimensions.Y, MinDimensions.Z));	CornerPoints.Add(new Vector3(MinDimensions.X, MinDimensions.Y, MaxDimensions.Z));	CornerPoints.Add(new Vector3(MinDimensions.X, MaxDimensions.Y, MaxDimensions.Z));	CornerPoints.Add(new Vector3(MaxDimensions.X, MaxDimensions.Y, MaxDimensions.Z));	CornerPoints.Add(new Vector3(MaxDimensions.X, MinDimensions.Y, MaxDimensions.Z));}

Then use the GetOffsetInWorldCoords() function on each of those corner points from the Vehicle and draw lines between them using a drawline function like this.

public static void DrawLine(Vector3 start, Vector3 end, Color colour){	Function.Call(Hash.DRAW_LINE, start.X, start.Y, start.Z, end.X, end.Y, end.Z, colour.R, colour.G, colour.B, colour.A);}

That will ensure that no matter how the model rotates, the corners will rotate relative to it. This also works for Peds and Props of course, it's not just for Vehicles.

 

I should just add, you should only collect the corner points once and then store those in a class that links those corners with that Vehicle. You don't want to be grabbing model dimensions every frame, it's just wasted cycles if you do that.

 

Or you could create a Dictionary<int, List<Vector3>> that has the model hash as the key and the corner points as the DIctionary value. Like everything, there are many ways to achieve the goal, you just have to find the one that you are most comfortable using.

 

thanks alot for your help:)

Link to comment
Share on other sites

  • 2 weeks later...

@LeeC2202​ can i get the Coordinates and the Dimensions of the Buildings Around me like what i made by Cars and Peds?

I don't believe the buildings are simple model files, they are map based entities as far as I am aware. So as far as I know (which is very little when it comes to maps) I don't think you can.

 

I know that's a very ambiguous answer but I don't know enough to say a definite yes or no, sorry.

Edited by Guest
Link to comment
Share on other sites

 

@LeeC2202​ can i get the Coordinates and the Dimensions of the Buildings Around me like what i made by Cars and Peds?

I don't believe the buildings are simple model files, they are map based entities as far as I am aware. So as far as I know (which is very little when it comes to maps) I don't think you can.

 

I know that's a very ambiguous answer but I don't know enough to say a definite yes or no, sorry.

 

@LeeC2202 And what about roads, greenery or sidewalks etc? Do you think any alternating method exist to capture information about them?

Link to comment
Share on other sites

I am sure there is a way because Camxxcore's Camera Info tool mod does it I think.

 

You need some input from someone with more experience in getting map info, all I have done is basic props, peds and vehicles.

Link to comment
Share on other sites

@LeeC2202 sorry am asking too much. But i like to know how to detect Animals!

​i tried using GetPeds(),GetEntities(),GetProps​() but no one of them helps!!

Link to comment
Share on other sites

  • 2 weeks later...

@LeeC2202 sorry am asking too much. But i like to know how to detect Animals!

​i tried using GetPeds(),GetEntities(),GetProps​() but no one of them helps!!

 

Peds work perfectly fine to detect animals, as you can see from the image below. I would suggest that in Visual Studio, you look at the properties that a Ped has and the ones you can check against.

 

I am not just going to give you the answer because doing what I have said, is precisely how you learn what an API lets you do. You need to get used to doing that because it answers a lot of questions without you having to ask for the answer.

 

So if you had Ped myPed, then typing myPed followed by a full-stop, would show a list of all the Ped properties.

 

zHi04yx.jpg

Edited by Guest
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

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