SA-MP Forums Archive
Placing player 1 in front of player 2 by angle - 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: Placing player 1 in front of player 2 by angle (/showthread.php?tid=594764)



Placing player 1 in front of player 2 by angle - Riwerry - 22.11.2015

Hello, I'm making script, where you can tackle other person when you aim at him (with right click mark on him) and you are near him + press ENTER, both players will receive animation to fall down to ground, but I want to SetPlayerPos of the player 1 to second player but I want to set player 1 angle so he will be front facing player 2, and I don't know how to do this.


Re: Placing player 1 in front of player 2 by angle - Amads - 22.11.2015

Found those in Useful Functions, didn't use yet tho.
Код:
stock GetPointInfrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) //Credit to Sacky/Simon/****** for this, I haven't actually found out whos the original was
{
    new Float:angle,
	    Float:z;
    
    GetPlayerPos(playerid, x, y, z);
    
    GetPlayerFacingAngle(playerid, angle);
    
    if (IsPlayerInAnyVehicle(playerid))
	 {
		 GetVehicleZAngle(GetPlayerVehicleID(playerid), angle);
	 }
    
    x += (distance * floatsin(-angle + LookingAngle[playerid], degrees));

    y += (distance * floatcos(-angle + LookingAngle[playerid], degrees));
}
Код:
stock Float:AngleToPoint(Float:x,Float:y,Float:x1,Float:y1)
{
    new Float:newang = atan(floatabs((x-x1)/(y-y1)));
    if (x1 <= x && y1 >= y) newang += 90.0;
    else if (x1 < x && y1 < y) newang = -newang + 270.0;
    else if (x1 >= x && y1 <= y) newang += 270.0;
    else if (x1 > x && y1 > y) newang = 90.0 - newang;
    return newang;
}



Re: Placing player 1 in front of player 2 by angle - AbyssMorgan - 23.11.2015

use 3DTryg.inc

https://github.com/AbyssMorgan/ADM/b...SAM/3DTryg.inc