How to get position near vehicle? - 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: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to get position near vehicle? (
/showthread.php?tid=597103)
How to get position near vehicle? -
Kajlle - 26.12.2015
Can anyone explain me how can I get the position near vehicle? for example: trunk, bumpers, doors... Just around the veh... I think it's something with floatsin, floatcos but I don't understand that...
Re: How to get position near vehicle? -
ikey07 - 26.12.2015
I used this to get right side of the vehicle.
pawn Код:
stock GetXYRightOfCar(vehicleid,&Float:x,&Float:y,Float:distance)
{
new Float:a;
GetVehiclePos( vehicleid, x, y, a );
GetVehicleZAngle( vehicleid, a );
x += ( distance * floatsin( -a+90, degrees ));
y += ( distance * floatcos( -a+90, degrees ));
}
usage would be
GetVehiclePos
GetXYRightOfCar(vehicleid,x,y,1.0) use negative to get left side.
Re: How to get position near vehicle? -
KillerDVX - 27.12.2015
PHP код:
public GetPlayerclosetoveh(playerid)
{
new Float:dis = 99999999.0;
new veh = -1;
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i = 1; i < MAX_VEHICLES; i++)
{
new Float:distance = GetVehicleDistanceFromPoint(i, x, y, z);
if(distance < dis)
{
dis = distance;
veh = i;
}
}
return veh;
}
If it didn't work, please tell me.