Jump to content

colshape alternative for sound detection?


GhostXoP

Recommended Posts

Is there a way or an event that triggers if within range of a sound? Like, an event triggers when someone fires a gun within 20 feet of the element? I would plant a colshape that lasted for a half a second around the person firing a gun using on ped or player weapon fire event, but it wouldnt work as users must "enter" the colshape to trigger the colshape event, if you plant the colshape over an element, while the element is within the colshape, the element must leave and reenter the colshape to trigger the event, Or is that not true?

Link to comment
addEventHandler ( "onClientPlayerWeaponFire", root, 
    function ( ) 
        local x, y, z = getElementPosition ( source ) 
        local lx, ly, lz = getElementPosition ( localPlayer ) 
        local distance = getDistanceBetweenPoints3D ( x, y, z, lx, ly, lz ) 
        outputChatBox ( getPlayerName ( source ) .." fired a weapon at distance: ".. distance ) 
    end 
) 

Test that, I don't know if it'll work.

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...