Get player's Position, More like direction -
Ebisu - 03.07.2017
Greetings,
I want to know if it's possible to make a system like you type a cmd, and it tells you if that specific player is standing in your left side or right side like here.
PHP код:
CMD:getpos(playerid, params[])
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 6.0, x, y ,z) && i != playerid)
{
//what to do here
//and make a string like where the player is standing
//ex: ID 9 is standing at the right side
}
}
return 1;
}
Re: Get player's Position, More like direction -
Lynn - 03.07.2017
You can't tell if someone is standing on your right or left side with accuracy.
You can detect if their next to you, but not what side of you they are on.
For instance, if you're standing and someone is on your right, if you hit W and turn around their now on your left.
The script can't detect that your player turned around(accurately).
Is it possible? Yes,
However it will be completely buggy and not worth the effort.
Re: Get player's Position, More like direction -
Nero_3D - 03.07.2017
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;
}
You could use GetZAngle by itself if the angle is enough, just added the other two functions for you convenience
Re: Get player's Position, More like direction -
Pottus - 03.07.2017
Код:
return strcat((dest[0] = EOS, dest), direction[floatround((angle + 11.25) / 22.5, floatround_floor)], size);
That is rather clever.