03.07.2017, 20:35
PHP код:
Direction(Float: angle, dest[], size = sizeof dest) {
while(angle >= 348.75) angle -= 360.0;
while(angle < -11.25) angle += 360.0;
static const direction[][] = {
"North",
"North North West",
"North West",
"West North West",
"West",
"West South West",
"South West",
"South South West",
"South",
"South South East",
"South East",
"East South East",
"East",
"East North East",
"North East",
"North North East"
};
return strcat((dest[0] = EOS, dest), direction[floatround((angle + 11.25) / 22.5, floatround_floor)], size);
}
Float: GetZAngle(Float: X1, Float: Y1, Float: X2, Float: Y2) {
return -atan2(X2 - X1, Y2 - Y1); // From Point 1 to Point 2
}
DirectionPlayerToPlayer(playerid, target, dest[], size = sizeof dest) {
new
Float: pX,
Float: pY,
Float: tX,
Float: tY,
Float: Z;
if(GetPlayerPos(playerid, pX, pY, Z) && GetPlayerPos(target, tX, tY, Z)) {
return Direction(GetZAngle(pX, pY, tX, tY), dest, size);
}
return 0;
}