PDA

View Full Version : GetXYOnTheRightOfPlayer O.o


S0n1COwnsYou
09/08/2013, 11:34 PM
i mean somthing like this, but on the right and the left of the player...
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));
}

Youarex
10/08/2013, 08:09 PM
You could modify that function. One approach, for example:


enum
{
INFRONT,
LEFT,
BEHIND,
RIGHT
}


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:


GetXYFromPlayer(playerid, x, y, LEFT, 10.0);


Should work :)