SA-MP Forums Archive
About Position - 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: About Position (/showthread.php?tid=646770)



About Position - sampkinq - 23.12.2017

Hi, I am working on a code. The problem is if I go to a car in the area, I want you to throw me backwards. This is the code I'm working on, but I did not get the result I wanted. Can you help me ?


I'm sorry for my bad english.

Код:
new Float: vPos[4];
GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
GetVehicleZAngle(GetPlayerVehicleID(playerid), vPos[3]);
GetXYInFrontOfPlayer(playerid, vPos[0], vPos[1], 6.0);
SetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
SetVehicleZAngle(GetPlayerVehicleID(playerid), vPos[3]);
new Float:sPos[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid), sPos[0], sPos[1], sPos[2]);
SetVehicleVelocity(GetPlayerVehicleID(playerid), sPos[0] + 1.5, sPos[1], sPos[2]);

stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
	new Float: a;
	GetPlayerPos(playerid, x, y, a);
	GetPlayerFacingAngle(playerid, a);
	if (GetPlayerVehicleID(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
	x += (distance * floatsin(-a, degrees));
	y += (distance * floatcos(-a, degrees));
}