[Help] New GetXYZInFrontOfPlayer
#1

A New GetXYZInFrontOfPlayer?

Exist a Function similar at this for Get NOT the Front Point Central of Player, but a little Side (Right / Left) ?

Код:
forward GetXYZInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:z, Float:distance);
public GetXYZInFrontOfPlayer(playerid, &Float:x, &Float:y, &Float:z, Float:distance) {
new Float:a; GetPlayerFacingAngle(playerid, a);
GetPlayerVelocity(playerid, x, y, z);
if (GetPlayerVehicleID(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees)); }
Reply
#2

Why are you using GetPlayerVelocity? You would use GetPlayerPos to return their coordinates.

And you would need to adjust the following lines to detect the position to the left/right instead of the position in front of the player (I just don't know how to change it )
pawn Код:
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
Reply
#3

Owh yes... my Error, I have used GetPlayerVelocity for a Testing, but use GetPlayerPos.

Quote:

(I just don't know how to change it )

Idem...

Thanks anyway Grim_
Reply
#4

Adding something to a should move the point left of the player (+90 = left side of player), removing something then makes it go right. If not, it is just the other way round
You could just add another parameter, that is added to a, after getting the facingangle.
Reply
#5

Quote:

forward GetXYZInFrontOfPlayer(playerid, &Float, &Float:y, &Float:z, Float:distance);
public GetXYZInFrontOfPlayer(playerid, &Float, &Float:y, &Float:z, Float:distance) {
new Float:a; GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x, y, z);
if (GetPlayerVehicleID(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);

x += 0.9 // Example
y += 0.9 // Example

x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees)); }

I have try to this, but nothing. There is a problem with FacingAngle...
Reply
#6

Mauzen Can you help me please?
Reply
#7

pawn Код:
x += (distance * floatsin(-a, degrees));
That line calculates the location of the X-axis, so you need to adjust that to make the 'side-position' bigger/smaller.

pawn Код:
y += (distance * floatcos(-a, degrees));
That line calculates the location of the Y-axis, so basically how far the "position" sticks out for the player. Make it smaller for a shorter distance to the player.
Reply
#8

Thanks Hiddos, now i do testing.
PS: I do not speak English, I did not understand well, but I try to do it.
Reply
#9

I have try to make this:

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


If i look at N(orth) works, else not...
problem whit FacingAngle, please can you make a example code for a Point Front Side(Dx or Sx) of Player?
Reply
#10

Do not change x or y, this will just move the starting point (player position) a bit. Change a like i explained:

pawn Код:
forward GetXYInFrontOfPlayer2(playerid, &Float, &Float:y, Float:distance, Float:angle);
public GetXYInFrontOfPlayer2(playerid, &Float, &Float:y, Float:distance, Float:angle) {
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if (GetPlayerVehicleID(playerid))
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    a += angle;
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
angle=0 : front of the player
angle>0 : degrees to the left side
angle<0 : right side (maybe the other way round, test it)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)