Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onClientPlayerWeaponFire returns wrong hit position for weapons after enabling 1st person weapon flag #1088

Open
Yamsha75 opened this issue Sep 10, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@Yamsha75
Copy link

Describe the bug
If you enable 1st person aim flag via setWeaponProperty for a weapon that doesn't have 1st person aim by default (in GTA:SA), then onClientPlayerWeaponFire event returns wrong hit position. More precisely, hit position returned is always the last hit position of a bullet that was shot using a weapon that either has 1st person by default or a 3rd person weapon that doesn't have this flag enabled. Shooting a ped or a vehicle inflicts damaage correctly, despite the event returning bad position.

To reproduce
Use the code provided below. When shooting the pistol without any modifications, the line drawn ends at the exact hit position. After enabling 1st person flag, each shot's hit position will be wrongly returned as the hit position of the last shot before enabling the flag. Turn the flag off and it works properly again.

--client
startPos = nil
endPos = nil

function weaponFireHandler(_, _, _, ex, ey, ez, _, sx, sy, sz)
    startPos = Vector3(sx, sy, sz)
    endPos = Vector3(ex, ey, ez)
end
addEventHandler('onClientPlayerWeaponFire', localPlayer, weaponFireHandler)

function drawTracer()
    if startPos and endPos then
       dxDrawLine3D(startPos, endPos, 0xFFFF0000, 5)
    end 
end
addEventHandler('onClientRender', root, drawTracer)
--server
-- lines below give you a pistol and ensure you have 'std' skill level with pistol
player = getPlayerFromName(<your nickname in game>)
giveWeapon(player, 22, 1000, true)
setPedStat(player, 69, 500)
-- use the line below in runcode to toggle the 1st person flag on/off
setWeaponProperty(22, 'std', 'flags', 4)

Expected behaviour
The bullet hit position should be returned properly. A weapon with 1st person enabled by default (a sniper rifle for example) is working properly, so it shouldn't be impossible.

Version
Server and client version: v1.5.7-release-18957

@Yamsha75 Yamsha75 added the bug Something isn't working label Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant