Coordiantes above and behind? -
0ne - 17.04.2010
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?
Re: Coordiantes above and behind? -
Torran - 17.04.2010
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);
Re: Coordiantes above and behind? -
snoob - 17.04.2010
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 !!
Re: Coordiantes above and behind? -
0ne - 18.04.2010
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
Re: Coordiantes above and behind? -
Torran - 18.04.2010
Thats what i said lol
pawn Код:
GetPlayerPos(playerid,x,y,z);
AttachObjectToPlayer(objectid,x,y,z+1);
Re: Coordiantes above and behind? -
snoob - 18.04.2010
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.