View Single Post
Old 06/12/2018, 07:41 AM   #1
Yashas
Gangsta
 
Join Date: Jun 2012
Location: India
Posts: 882
Reputation: 317
Default 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
Attached Images
File Type: jpg sa-mp-005.jpg (191.5 KB, 49 views)
File Type: jpg sa-mp-006.jpg (213.0 KB, 43 views)
Yashas is offline   Reply With Quote