[Include] VehiclePartPosition
#1

VehiclePartPosition


This is include but more like just function which allows you to get exact position for next parts of any vehicle

Left front tire
Right front tire
Left rear tire
Right rear tire
Hood
Trunk


Function:
Код:
GetXYZOfVehiclePart(vehicleid, part, &Float:x, &Float:y, &Float:z, Float:offset = 0.5)
Код:
 * vehicleid - Id of vehicle
 * part - Part (https://github.com/Ino42O/VehiclePar...sition.inc#L43), 
 * &Float:x - Out var 
 * &Float:y - Out var
 * &Float:z - Out var
 * Float:offset = 0.5 - Side offset with default value
Example:
Create a car with next command:
Код:
new car;
CMD:car(playerid, params[])
{
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);

	car = CreateVehicle(strval(params), x, y+5.0, z, 0.0, -1, -1, 0);
	return 1;
}
And then try function
Код:
CMD:part(playerid, params[])
{
	new Float:x, Float:y, Float:z;
	GetXYZOfVehiclePart(car, strval(params), x, y, z);

	SetPlayerPos(playerid, x, y, z);
	return 1;
}
Changes:
31/10/2016
- Support if vehicle is not on flat ground (ColAndreas)


Download
https://github.com/Ino42O/VehiclePartPosition
Reply
#2

Nice release
Reply
#3

if vehicle is rotated on X or Y axis, then this function won't return the correct position. (eg: up-side down or driving up a hill)
Reply
#4

True that (for now)
Reply
#5

Quote:
Originally Posted by Spmn
Посмотреть сообщение
if vehicle is rotated on X or Y axis, then this function won't return the correct position. (eg: up-side down or driving up a hill)
...yeah but can fix that with:

https://sampwiki.blast.hk/wiki/GetVehicleRotationQuat

...but actually thats not such a big deal
Reply
#6

Update

Now support if vehicle is not on flat ground
require ColAndreas
Reply
#7

And what about the flight transport? For example the hood Make adjustments to the coordinates for each vehicle
Reply
#8

Quote:
Originally Posted by Kolstin
Посмотреть сообщение
And what about the flight transport? For example the hood Make adjustments to the coordinates for each vehicle
if i understand you... coordinates will be just in front vehicle / plane / heli...
Reply
#9

Quote:
Originally Posted by Ivan_Ino
Посмотреть сообщение
Update

Now support if vehicle is not on flat ground
require ColAndreas
You could use this function instead of ColAndreas
http://forum.sa-mp.com/showpost.php?...postcount=3972
Reply
#10

Quote:
Originally Posted by Spmn
Посмотреть сообщение
You could use this function instead of ColAndreas
http://forum.sa-mp.com/showpost.php?...postcount=3972
In my opinion colandreas is better, but I will not say i'm 100% correct
Reply
#11

Quote:
Originally Posted by PT
Посмотреть сообщение
In my opinion colandreas is better, but I will not say i'm 100% correct
ColAndreas might be better, but not here. It has nothing to do with vehicle rotation.
Reply
#12

Looks good! Very nicely done!
Reply
#13

https://*********/cx8h20qHLxc
Reply
#14

Quote:
Originally Posted by Spmn
Посмотреть сообщение
You could use this function instead of ColAndreas
http://forum.sa-mp.com/showpost.php?...postcount=3972
You know if this function works on unoccupied vehicles?

@topic
You can get vehicle doors position using the same math on tires, but with seat info and adding the model X size (wide) divided by 2.0 ~ 3.0. Look:
PHP код:
// left front door
new Float:offXD;
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_FRONTSEAToffXoffYoffZ);
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZEoffXDoffZoffZ); // You'll never use OffZ value, so it's an "unused" var :D
fX += ( ( (offX + (offXD/2.5) + offset) * floatsin( -90.0degrees ) ) + ( ( offY floatsin( -Adegrees ) ) ) );
fY += ( ( (offX + (offXD/2.5) + offset) * floatcos( -90.0degrees ) ) + ( ( offY floatcos( -Adegrees ) ) ) );
// left back door
new Float:offXD;
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_REARSEAToffXoffYoffZ);
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZEoffXDoffZoffZ);
fX += ( ( (offX + (offXD/2.5) + offset) * floatsin( -90.0degrees ) ) + ( ( offY floatsin( -Adegrees ) ) ) );
fY += ( ( (offX + (offXD/2.5) + offset) * floatcos( -90.0degrees ) ) + ( ( offY floatcos( -Adegrees ) ) ) ); 
I'm dividing by 2.5 because it worked for my purposes and I haven't tested on all vehicles!

Sorry for my english.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)