SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Bug Reports (https://forum.sa-mp.com/forumdisplay.php?f=20)
-   -   GetPlayerLastShotVector returns wrong information (https://forum.sa-mp.com/showthread.php?t=661485)

Yashas 06/12/2018 07:41 AM

GetPlayerLastShotVector returns wrong information
 
2 Attachment(s)
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


All times are GMT. The time now is 07:52 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.