Adding air horn when a key is pressed
#1

Alright. I would like to make something for my server and I thought of an air horn for the fire department. I don't know how so can anyone help?
Reply
#2

pawn Код:
PlayerPlaySound(playerid, 3201, 0, 0, 0);
This is the airhorn sound, do with it as you choose.
Reply
#3

So how do I add it? And where do I place it.
Reply
#4

In on player key state
Код:
If(IsPlayerInVehicle(playerid,vehicleid));
{
           //That line...
}
Reply
#5

Then what about adding the key/command and where do u I it in the script..
Reply
#6

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#7

That don't help me.
Reply
#8

There's two parts to this - detecting the key press and playing the air horn. The key press code is explained all throughout the link I provided, and d3ll gave you the code to play the air horn.

All you have to do is combine them.

Short of writing the entire code for you, this is all you need to know. You learn by doing.
Reply
#9

Yeah I can do that but I don't understand where in the script do I put this.
Reply
#10

If you already have an instance of OnPlayerKeyStateChange in your mode (check with CTRL+F) then you need to add the check to the existing callback. If, on the other hand, you DON'T have an instance of OnPlayerKeyStateChange in your mode yet, you need to add

pawn Код:
public OnPlayerKeyStateChange(...)
{
    if(newkeys & KEY_???)
    {
        PlayerPlaySound(...);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)