Quantcast

Jump to content

» «
Photo

Getting Coordinates of all Objects seen on Screen

16 replies to this topic
husseinh
  • husseinh

    Player Hater

  • Members
  • Joined: 01 Sep 2017
  • Germany

#1

Posted 11 September 2017 - 09:18 AM

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


Ezio Baggins
  • Ezio Baggins

    Player Hater

  • Members
  • Joined: 07 Jun 2017
  • India

#2

Posted 4 weeks ago

World.GetAllEntities()

  • jedijosh920 likes this

Zeziroth
  • Zeziroth

    Player Hater

  • Members
  • Joined: 4 weeks ago
  • Germany

#3

Posted 4 weeks ago

How can i do this in external?

 

Your way just works in an internal or?


husseinh
  • husseinh

    Player Hater

  • Members
  • Joined: 01 Sep 2017
  • Germany

#4

Posted 4 weeks ago

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 


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#5

Posted 4 weeks ago Edited by LeeC2202, 4 weeks ago.

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;
}

Zeziroth
  • Zeziroth

    Player Hater

  • Members
  • Joined: 4 weeks ago
  • Germany

#6

Posted 4 weeks ago

 

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)


husseinh
  • husseinh

    Player Hater

  • Members
  • Joined: 01 Sep 2017
  • Germany

#7

Posted 4 weeks ago

 

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 


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#8

Posted 4 weeks ago Edited by LeeC2202, 4 weeks ago.

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


husseinh
  • husseinh

    Player Hater

  • Members
  • Joined: 01 Sep 2017
  • Germany

#9

Posted 4 weeks ago Edited by husseinh, 4 weeks ago.

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-...les-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);
                    
                 
             }

husseinh
  • husseinh

    Player Hater

  • Members
  • Joined: 01 Sep 2017
  • Germany

#10

Posted 4 weeks ago

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


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#11

Posted 4 weeks ago Edited by LeeC2202, 4 weeks ago.

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


husseinh
  • husseinh

    Player Hater

  • Members
  • Joined: 01 Sep 2017
  • Germany

#12

Posted 3 weeks ago

 

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

  • LeeC2202 likes this

husseinh
  • husseinh

    Player Hater

  • Members
  • Joined: 01 Sep 2017
  • Germany

#13

Posted A week ago

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


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#14

Posted A week ago Edited by LeeC2202, A week ago.

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


mmuaz
  • mmuaz

    Player Hater

  • Members
  • Joined: 3 weeks ago
  • Germany

#15

Posted A week ago

 

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


LeeC2202
  • LeeC2202

    Snitch

  • Members
  • Joined: 24 Oct 2015
  • United-Kingdom

#16

Posted A week ago

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.


husseinh
  • husseinh

    Player Hater

  • Members
  • Joined: 01 Sep 2017
  • Germany

#17

Posted A week ago

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users