Jump to content

Weapon stuck check


Kenix

Recommended Posts

Hi guys. I need help, i want to know if player got stuck in the wall or other building and player can't fire weapon. How can i check this more quality?

P.S

1) Check player's "Task" doesn't help.

2) processLineOfSight/isLineOfSightClear is solution, but we need to know where we need to start this line if we need more quality.

25koqdw.png

Link to comment

I have no idea if this will work, and it's not related to processLineOfSight but maybe you can extend it to make it work:

addEventHandler("onClientRender", root, 
function() 
    if getPedWeapon(localPlayer) then --He has a weapon 
        local sx, sy, sz = getPedTargetStart(localPlayer) -- 
        local tx, ty, tz = getPedTargetCollision(localPlayer) --Can be replaced by getPedWeaponMuzzlePosition if it doesn't work. 
        if sx and tx then 
            local dist = getDistanceBetweenPoints3D(sx, sy, sz, tx, ty, tz) 
            if dist < 1.5 then --Blocked by a close object. You need to figure out the distance here. 
                --BLOCKED. 
            end 
        end 
    end 
end) 
  
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...