GetXYOnTheRightOfPlayer O.o - 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: GetXYOnTheRightOfPlayer O.o (
/showthread.php?tid=457200)
GetXYOnTheRightOfPlayer O.o -
S0n1COwnsYou - 09.08.2013
i mean somthing like this, but on the right and the left of the player...
PHP код:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
// Created by ******
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));
}
Re: GetXYOnTheRightOfPlayer O.o -
Youarex - 10.08.2013
You could modify that function. One approach, for example:
pawn Код:
enum
{
INFRONT,
LEFT,
BEHIND,
RIGHT
}
pawn Код:
stock GetXYFromPlayer(playerid, &Float:x, &Float:y, direction, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
switch(direction)
{
case LEFT:
{
a += 90;
}
case BEHIND:
{
a += 180;
}
case RIGHT:
{
a += 270;
}
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
Usage example:
pawn Код:
GetXYFromPlayer(playerid, x, y, LEFT, 10.0);
Should work