Making a AirHorn Button help
#1

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!
Reply
#2

OnPlayerKeyStateChange, if PRESSED -> play, if RELEASED -> stop.
Reply
#3

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
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)