Adding air horn when a key is pressed - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Adding air horn when a key is pressed (
/showthread.php?tid=570900)
Adding air horn when a key is pressed -
ShiffeyTheGamer - 14.04.2015
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?
Re: Adding air horn when a key is pressed -
d3ll - 14.04.2015
pawn Код:
PlayerPlaySound(playerid, 3201, 0, 0, 0);
This is the airhorn sound, do with it as you choose.
Re: Adding air horn when a key is pressed -
ShiffeyTheGamer - 14.04.2015
So how do I add it? And where do I place it.
Re: Adding air horn when a key is pressed -
fuckingcruse - 14.04.2015
In on player key state
Код:
If(IsPlayerInVehicle(playerid,vehicleid));
{
//That line...
}
Re: Adding air horn when a key is pressed -
ShiffeyTheGamer - 14.04.2015
Then what about adding the key/command and where do u I it in the script..
Re: Adding air horn when a key is pressed -
MP2 - 14.04.2015
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Re: Adding air horn when a key is pressed -
ShiffeyTheGamer - 14.04.2015
That don't help me.
Re: Adding air horn when a key is pressed -
MP2 - 14.04.2015
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.
Re: Adding air horn when a key is pressed -
ShiffeyTheGamer - 14.04.2015
Yeah I can do that but I don't understand where in the script do I put this.
Re: Adding air horn when a key is pressed -
MP2 - 14.04.2015
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;
}