GetDynamicObjectPos & OnPlayerShootDynamicObject reading wrong coordinates
#1

Hi everyone,

I have problem with GetDynamicObjectPos and OnPlayerShootDynamicObject which are not getting coordinates right. I spent few hours trying to find solution but without any luck so I was hopping you guys can help me. You can see at the picture below that script is clearly getting coordinates and distance between player and object wrong.

This is object I created.
pawn Код:
CreateDynamicObject(19315, 1227.5359, -4454.4858, 23.4837,   0.00000, 0.00000, 0.00000, -1, -1, -1, 300.00, 300.00);
This is a code from script.
pawn Код:
public OnPlayerShootDynamicObject(playerid, weaponid, objectid, Float:x, Float:y, Float:z)
{
    new
        Float: fDistance = GetPlayerDistanceFromPoint(playerid, x, y, z),
        sString[256],
        sString2[256];
       
    format(sString, sizeof(sString), "Weapon %i. Object: %i. Pos of Object: %f, %f, %f", weaponid, objectid, x, y, z);
    format(sString2, sizeof(sString2), "Distance between you and Object is %0.2f.", fDistance);
    SendClientMessage(playerid, -1, sString);
    SendClientMessage(playerid, 0xA9C4E4FF, sString2);
    return 1;
}
Any help would be appreciated.
Reply
#2

Those seem to be the offsets of the shot hit position to the object's center position.

You could use GetDynamicObjectPos to obtain the object's position. Then add the offset to the center position and you have the correct hit coords.
Reply
#3

Quote:
Originally Posted by NaS
Посмотреть сообщение
Those seem to be the offsets of the shot hit position to the object's center position.

You could use GetDynamicObjectPos to obtain the object's position. Then add the offset to the center position and you have the correct hit coords.
I just realized I inserted wrong function in thread title and explained another thing in post . Thank you, you're answer helped
Reply
#4

Here's a suggestion for you that might help accomplishing what you want: https://forum.sa-mp.com/showpost.php...postcount=2639
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)