SA-MP Forums Archive
Making a AirHorn Button help - 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: Making a AirHorn Button help (/showthread.php?tid=406848)



Making a AirHorn Button help - jakejohnsonusa - 11.01.2013

Ok so I want to make a airhorn button (Will be the KEY_FIRE button), I'm not new to scripting so I know how to do most of the button scripting, but how do I make it so that when they press it it plays the .mp3 sound, but it plays until they stop pressing it?

So like it plays as long as it's pressed, when they release the Key_Fire key it would stop playing the .mp3 sound.

How can I do this?


Thanks in advance!


Re: Making a AirHorn Button help - Vince - 11.01.2013

OnPlayerKeyStateChange, if PRESSED -> play, if RELEASED -> stop.


Re: Making a AirHorn Button help - park4bmx - 11.01.2013

Check I it's pressed
pawn Код:
if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE)) PlayAudioStream//so on
And then when it's released
pawn Код:
if ((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE)) StopAudioaStream//so on



Re: Making a AirHorn Button help - kaisersouse - 11.01.2013

In OnPlayerKeyStateChange
Код:
if ((newkeys & KEY_CROUCH) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
                    new Float:x;
                    new Float:y;
                    new Float:z;
                    GetPlayerPos(playerid,x,y,z);
		    foreach(Player,i)
		    {
			    PlayerPlaySound(i,3200,x,y,z); //play sound for everyone, but only at horn users pos
	  	    }
	}
You don't need an MP3. Airhorn is in-game sound