SA-MP Forums Archive
Playerid Facing to ID? - 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: Playerid Facing to ID? (/showthread.php?tid=338072)



Playerid Facing to ID? - Admigo - 28.04.2012

Heey all,
I want to detect the location of the ID of arrest.
Then i want to set the angle for playerid so when he arrest him he facing him.
I need this for the aiming animation.
Example:
Код:
           0

270  playerid    90


           ID
          180

//so you see Id is south of him so the playerid angles to 180.
How can i make this?

Thanks Admigo


Re: Playerid Facing to ID? - SnG.Scot_MisCuDI - 28.04.2012

pawn Код:
GetPlayerFacingAngle
Then
pawn Код:
SetPlayerFacingAngle



Re: Playerid Facing to ID? - Crazymax - 29.04.2012

easy...

pawn Код:
//In your command (arrest)
new Float:A;
GetPlayerFacingAngle(id, A);
SetPlayerFacingAngle(playerid, A);



Re: Playerid Facing to ID? - admantis - 29.04.2012

That will only set the facing angle that the other player has, you are not facing towards the other player!
Use this function:
pawn Код:
stock Float:SetPlayerFaceToPoint( playerid, Float:PointX, Float:PointY )
{
    new Float:eX, Float:eY, Float:eZ;
    new Float:eAngle;
    GetPlayerPos(playerid, eX, eY, eZ);

    if(eX > PointX && eY > PointY) eAngle = floatabs(atan2(floatsub(PointX, eX), floatsub(PointY, eY)));
    if(eX > PointX && eY <= PointY) eAngle = floatadd(floatabs(atan2(floatsub(eY, PointY), floatsub(PointX, eX))), 270.0);
    if(eX <= PointX && eY > PointY) eAngle = floatadd(floatabs(atan2(floatsub(PointY, eY), floatsub(eX, PointX))), 90.0);
    if(eX <= PointX && eY <= PointY) eAngle = floatadd(floatabs(atan2(floatsub(eX, PointX), floatsub(eY, PointY))), 180.0);

    if(GetPlayerState( playerid ) == PLAYER_STATE_DRIVER) SetVehicleZAngle(GetPlayerVehicleID( playerid ), eAngle);
    else SetPlayerFacingAngle(playerid, eAngle);

    return eAngle;
}



Re: Playerid Facing to ID? - Crazymax - 29.04.2012

Quote:
Originally Posted by admantis
Посмотреть сообщение
That will only set the facing angle that the other player has, you are not facing towards the other player!
Use this function:
damn, you're right... lol shit this is embarrassing