IsPlayerInRangeOfPoint not working.
#1

I'm trying to create a simple timer that checks to see if the player is within range, and if so, burns them. However the timer isn't working. After debugging, I found out the issue is with the IsPlayerInRangeOfPoint line, but can't figure how to fix it.

Or could the issue be the double loop? I was simply trying to save space.
pawn Код:
public FireBurn()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            for(new j=0; j<MAX_FIRES; j++)
            {
                if(IsValidDynamicObject(fire[j]))
                {
                    new Float:x, Float:y, Float:z;
                    GetDynamicObjectPos(fire[j], x, y, z);
                    if(IsPlayerInRangeOfPoint(i, 1, x, y, z))
                    {
                        new Float:health;
                        GetPlayerHealth(i, health);
                        SetPlayerHealth(i, (health - 5));
                        SendClientMessage(i, -1, "burning...");
                    }
                }
                else continue;
            }
        }
        else continue;
    }
    return 1;
}
Reply
#2

Hello!

My server developer suggests you to change:

pawn Код:
if(IsPlayerInRangeOfPoint(i, 1, x, y, z))
with

pawn Код:
if(IsPlayerInRangeOfPoint(i, 1.0, x, y, z))
Reply
#3

No luck, but rep for effort, thank you.
Reply
#4

I am his Developer, I'll try to help , Can you show me how your timer is defined and how it is called?
Reply
#5

I know from experience that Get(Dynamic)ObjectPos does not always work on certain objects, especially when they move. Get(Dynamic)ObjectPos returns the position where it was created, not the actual position after it moved.

Try to debug these coords and see if they are actually close together.

pawn Код:
Float:x, Float:y, Float:z, Float:px, Float:py, Float:pz;
GetDynamicObjectPos(fire[j], x, y, z);
GetPlayerPos(i, px, py, pz);
printf("Objectpos: %.2f, %.2f, %.2f \n Playerpos: %.2f, %.2f, %.2f", x, y, z, px, py, pz);
printf("Distance: %.2f", floatsqroot(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2))+((z1-z2)*(z1-z2))));
Reply
#6

Quote:
Originally Posted by Schneider
Посмотреть сообщение
I know from experience that Get(Dynamic)ObjectPos does not always work on certain objects, especially when they move. Get(Dynamic)ObjectPos returns the position where it was created, not the actual position after it moved.

Try to debug these coords and see if they are actually close together.

pawn Код:
Float:x, Float:y, Float:z, Float:px, Float:py, Float:pz;
GetDynamicObjectPos(fire[j], x, y, z);
GetPlayerPos(i, px, py, pz);
printf("Objectpos: %.2f, %.2f, %.2f \n Playerpos: %.2f, %.2f, %.2f", x, y, z, px, py, pz);
printf("Distance: %.2f", floatsqroot(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2))+((z1-z2)*(z1-z2))));
You called it, the Z returned on the fire object was > 2 from the original placement coords. Will adjust accordingly, +rep.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)