Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,905 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

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

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. 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

    2. Red Dead Redemption

    3. 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. Forum Support

    2. Site Suggestions

husseinh

Getting Coordinates of all Objects seen on Screen

Recommended Posts

husseinh

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!!

Share this post


Link to post
Share on other sites
Ezio Baggins

World.GetAllEntities()

Share this post


Link to post
Share on other sites
Zeziroth

How can i do this in external?

 

Your way just works in an internal or?

Share this post


Link to post
Share on other sites
husseinh

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

Share this post


Link to post
Share on other sites
LeeC2202

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 LeeC2202

Share this post


Link to post
Share on other sites
Zeziroth

 

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)

Share this post


Link to post
Share on other sites
husseinh

 

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

Share this post


Link to post
Share on other sites
LeeC2202

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 LeeC2202

Share this post


Link to post
Share on other sites
husseinh

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

Share this post


Link to post
Share on other sites
husseinh

@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!

Share this post


Link to post
Share on other sites
LeeC2202

@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 LeeC2202

Share this post


Link to post
Share on other sites
husseinh

 

@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:)

Share this post


Link to post
Share on other sites
husseinh

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

Share this post


Link to post
Share on other sites
LeeC2202

@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 LeeC2202

Share this post


Link to post
Share on other sites
mmuaz

 

@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?

Share this post


Link to post
Share on other sites
LeeC2202

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.

Share this post


Link to post
Share on other sites
husseinh

@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!!

Share this post


Link to post
Share on other sites
LeeC2202

@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 LeeC2202

Share this post


Link to post
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

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.