Jump to content

Sirens


WhoAmI

Recommended Posts

Posted

Hi guys!

I have one question. Is it possible to do new sound of cop's car and ambulance's sirens? I was looking for event, which start when someone turns on sirens, but there is no event like that, so... Is there antoher way? Someone has an idea?

Posted

You could do it in quite a few ways, however this is the kind of direction I'd go with;

Use the event onClientKey to detect when the horn key is pressed. (You can also use getBoundKeys to retrieve all the keys bound to horn and store them in a table for better compatibility)

Then check if the player is in a vehicle, and if in a defined vehicle. You can define the IDs in whatever way you want - but I would recommend using a table.

Run a basic for check to see if the current vehicle model exists in the table - if it does, disable the horn using toggleControl. If it doesn't exist in the table - do nothing(Unless you want a different default horn).

Then you can use these to play the sound and attach it to the vehicle;

getElementPosition -- The vehicle's position, send this data to the server using triggerServerEvent. 
triggerServerEvent -- Trigger a server event which in return triggers an event for all clients, which 
triggerClientEvent -- Trigger a client-side event for all clients 
playSound3D  -- Play the sound at the vehicle's position 
attachElements -- Attach the sound to the vehicle. 

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