GetPlayerDistanceFromPoint in 0.3c RC3?
#1

How do I use GetPlayerDistanceFromPoint in RC3? Apart from using RC4/5....
Reply
#2

Maths: http://en.wikipedia.org/wiki/Sinus
Reply
#3

Quote:
Originally Posted by ikkentim
Посмотреть сообщение
Get out. http://en.wikipedia.org/Wiki/Lean2Help
Reply
#4

Really, maths is the only way, unfortunately, i am not verry good at maths
Reply
#5

Quote:
Originally Posted by ikkentim
Посмотреть сообщение
Really, maths is the only way, unfortunately, i am not verry good at maths
I asked how I would use the function in RC3, not how I would make the function.
Reply
#6

pawn Код:
stock Float:GetPlayerDistanceFromPoint(playerid, Float:X, Float:Y, Float:Z)
{
   new Float:pPos[3];
   GetPlayerPos(playerid);
   return floatsqroot(floatpower(floatsub(X, pPos[0]), 2.0) + floatpower(floatsub(Y, pPos[1]), 2.0) + floatpower(floatsub(Z, pPos[2]), 2.0));
}
Is that what you mean?
Reply
#7

lol depends on how you define it..
if you do it like this:
pawn Код:
stock GetPlayerDistanceFromPoint(playerid, Float:x, Float:y, Float:z)
stock GetPlayerDistanceFromPoint(playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:rst, Float:Coords[3];
        GetPlayerPos(playerid, Coords[0], Coords[1], Coords[2]);
        Coords[0] = floatabs(Coords[0]) - x;
        Coords[1] = floatabs(Coords[1]) - y;
        Coords[2] = floatabs(Coords[2]) - z;
        rst = floatsqroot((Coords[0] * Coords[0]) + (Coords[1] * Coords[1]) + (Coords[2] * Coords[2]));
        return rst;
    }
    return 0;
}
(not sure if this function is correct, just wrote it for this purpose)

Then you need to use it in code like this:
pawn Код:
new Float:distance = GetPlayerDistanceFromPoint(playerid, Xcoord, Ycoord, Zcoord);
Reply
#8

Quote:
Originally Posted by ikkentim
Посмотреть сообщение
pawn Код:
stock Float:GetPlayerDistanceFromPoint(playerid, Float:X, Float:Y, Float:Z)
{
   new Float:pPos[3];
   GetPlayerPos(playerid);
   return floatsqroot(floatpower(floatsub(X, pPos[0]), 2.0) + floatpower(floatsub(Y, pPos[1]), 2.0) + floatpower(floatsub(Z, pPos[2]), 2.0));
}
Is that what you mean?
That is what I mean, thank you!

Sascha, your code has a tag mismatch on the return.
Reply
#9

He forgot to fill in GetPlayerPos. Please read code before copying it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)