Jump to content

colshape alternative for sound detection?


GhostXoP

Recommended Posts

Posted

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?

Posted

I think that you can use the weapon fire event plus the function to calculate the distance.

onClientPlayerWeaponFire

getDistanceBetweenPoints3D 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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