SA-MP Forums Archive
facing 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: facing angle. (/showthread.php?tid=562204)



facing angle. - danish007 - 07.02.2015

hello, how can i make if i use /hi near npc he should look at me?


Re: facing angle. - MicroD - 07.02.2015

http://forum.sa-mp.com/showpost.php?...4&postcount=21


AW: facing angle. - Nero_3D - 07.02.2015

I have no clue what such an outdated code still gets used
He simply didn't knew that the function atan2 existed therefor he discerns all 4 sectors
pawn Code:
stock Float: GetZAngleBetweenPoints(Float: x1, Float: y1, Float: x2, Float: y2) {
    return -atan2(x2 - x1, y2 - y1);
}
pawn Code:
stock SetPlayerLookAtPlayer(playerid, giveplayerid) {
    new
        Float: pX,
        Float: pY,
        Float: gX,
        Float: gY,
        Float: Z,
    ;
    return
        GetPlayerPos(playerid, pX, pY, Z) &&
        GetPlayerPos(giveplayerid, gX, gY, Z) &&
        SetPlayerFacingAngle(playerid, GetZAngleBetweenPoints(pX, pY, gX, gY))
    ;
}



Re: facing angle. - danish007 - 08.02.2015

its usage?