Coordiantes above and behind?
#1

Hey everyone,

How could i get or set a coordinates up a players head?

And how could i get coordiantes behind of a vehicle while player is in the vehicle?
Reply
#2

You cant get it above there head or behind a vehicle,

But you can get there actual position and set it +whatever

So:

pawn Код:
new Float:x, Float:y, Float:z;

GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z+1);
Reply
#3

this function is to find a position in front of the player. OffDist parameter is how far you want that point ... if you set OffDist to a negative value it will find a position in the back of the player ...


pawn Код:
forward GetPosFrontOfPlayer(playerid, Float:OffDist, &Float:Pxx, &Float:Pyy, &Float:Pzz);
public GetPosFrontOfPlayer(playerid, Float:OffDist, &Float:Pxx, &Float:Pyy, &Float:Pzz)
{
/*******************************************************************************
  Function: GetPosFaInFrontOfPlayer
  Parameter:
    playerid - the player on wich the output pos will be based on
    OffDist - The distance that the X Y point will be from playerid
    Pxx - Val to put x in
    Pyy - Val to put y in
    Pzz - Val to put z in
  Return:
    1 - Sucess
    0 - playerid was not connected
*******************************************************************************/

  if(!IsPlayerConnected(playerid)) return 0;
  new
    Float:playerpos[3],
        Vid,
    Float:FacingA;
  Vid = GetPlayerVehicleID(playerid);
    if(!Vid) //player not in a vehicle
  {
    GetPlayerPos(playerid, playerpos[0], playerpos[1], playerpos[2]);
    GetPlayerFacingAngle(playerid, FacingA);
  }
  else // player is in a vehicle
  {
    GetVehiclePos(Vid, playerpos[0], playerpos[1], playerpos[2]);
    GetVehicleZAngle(Vid, FacingA);
  }
  Pxx = (playerpos[0] + OffDist * floatsin(-FacingA,degrees));
  Pyy = (playerpos[1] + OffDist * floatcos(-FacingA,degrees));
  Pzz = playerpos[2];
  return 1;
}
good luck !!
Reply
#4

No, you don't understand, i need the position above his head so i could attach an object to him, like:

GetPlayerPos(playerid,x,y,z)
AttachObjectToPlayer(objectid,x,y,z)

i don't know how to do an object above or behind him while hes in a vehicle
Reply
#5

Thats what i said lol

pawn Код:
GetPlayerPos(playerid,x,y,z);
AttachObjectToPlayer(objectid,x,y,z+1);
Reply
#6

and me i gave you a function to find a pos behind or in front of the player... so you have both possibility... over and behind.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)