SA-MP Forums Archive
[Include] VehiclePartPosition - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] VehiclePartPosition (/showthread.php?tid=620512)



VehiclePartPosition - Ivan_Ino - 30.10.2016

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


Re: VehiclePartPosition - xDaemon - 30.10.2016

Nice release


Re: VehiclePartPosition - Spmn - 30.10.2016

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)


Re: VehiclePartPosition - Ivan_Ino - 30.10.2016

True that (for now)


Re: VehiclePartPosition - Kaliber - 30.10.2016

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


Re: VehiclePartPosition - Ivan_Ino - 31.10.2016

Update

Now support if vehicle is not on flat ground
require ColAndreas


Re: VehiclePartPosition - Romz - 31.10.2016

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


Re: VehiclePartPosition - Ivan_Ino - 31.10.2016

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


Re: VehiclePartPosition - Spmn - 31.10.2016

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


Re: VehiclePartPosition - PT - 31.10.2016

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


Re: VehiclePartPosition - Spmn - 31.10.2016

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.


Re: VehiclePartPosition - Lucky13 - 31.10.2016

Looks good! Very nicely done!


Re: VehiclePartPosition - Ivan_Ino - 01.11.2016

https://*********/cx8h20qHLxc


Re: VehiclePartPosition - renatog - 05.11.2016

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.