GetPlayerLastShotVector returns wrong information

Started by SA:MP, May 06, 2023, 02:28 AM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

SA:MP

GetPlayerLastShotVector returns wrong information

The wiki states that "If the player hit nothing, the hit positions will be 0. This means you can't currently calculate how far a bullet travels through open air. ".



While looking into the data, I found that it does not always return (0, 0 ,0). Sometimes, it returns (X, 0, 0) where X appears to be some coordinate not anywhere close to the origin.



Screenshots attached.



UPDATE:

It returns a random hit position far away from origin sometimes. Screenshot attached.




Code:

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
new data[E_SHOT_VECTOR];
    CollectDataOPWS(data, playerid, weaponid, hittype, hitid, fX, fY, fZ);
   
    new buffer[1024];
    EncodeShotVector(data, buffer);
   
    new Float:X, Float:Y, Float:Z, Float:x, Float:y, Float:z;
     GetPlayerLastShotVectors(playerid, X, Y, Z, x, y, z);
     
   
    fwrite(dataFile[playerid], buffer);
    fwrite(dataFile[playerid], "\r\n");
   
    format(buffer, 1024, "O: %.2f %.2f %.2f H: %.2f %.2f %.2f", X, Y, Z, x, y, z);
    SendClientMessageToAll(0x00FF00FF, buffer);
    format(buffer, 1024, "O: %.2f %.2f %.2f H: %.2f %.2f %.2f", data[fOriginX], data[fOriginY], data[fOriginZ],
      data[fHitPosX], data[fHitPosY], data[fHitPosZ]);
    SendClientMessageToAll(0x0000FFFF, buffer);
    return 1;
}

Please ignore the blue messages (they are expected to match exactly with the green messages).



EDIT:

I checked the hittype and it's zero in both cases: (0, 0, 0) and the weird number case

Source: GetPlayerLastShotVector returns wrong information