SA-MP Forums Archive
song - 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: song (/showthread.php?tid=634722)



song - asri - 25.05.2017

i have script to switchnewsound in the car

PHP код:
forward SwitchNewSound();
public 
SwitchNewSound()
{
 for(new 
0MAX_PLAYERSi++)
        {
            if(
IsPlayerInAnyVehicle(i))
        {
            
StopAudioStreamForPlayer(i);
            
PlayAudioStreamForPlayer(iRandomSongs[random(sizeof(RandomSongs))]);
            
URLNumber++;
            if(
URLNumber == sizeof(RandomSongs)) URLNumber 0;
        }
    }
    return 
1;

but how to stop when out of car any idea


Re: song - CheezIt - 25.05.2017

Quote:

StopAudioStreamForPlayer(id_here);

Note that the function you posted changes the audio for everyone in a vehicle.


Re: song - Aldrago - 25.05.2017

if(IsPlayerInAnyVehicle this code when player in veh and
Use
if(!IsPlayerInAnyVehicle( this ! Sign mean not
So add then code a d then add stopaudiostream
I hope u will understand
I'm using phone otherwise I give you code

If this work don,t forget to +rep


Re: song - Farzam - 25.05.2017

If you mean you want to stop the sound when the player is leaving the vehicle,

Use this code. This callback will be called when the player leaves any vehicle he is in, and you can stop the audio for him.

https://sampwiki.blast.hk/wiki/StopAudioStreamForPlayer
https://sampwiki.blast.hk/wiki/OnPlayerStateChange

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
        // If the player exits a vehicle
	if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) 
	{
	    StopAudioStreamForPlayer(playerid); // Stop the audio stream
	}
	return 1;
}



Re: song - asri - 25.05.2017

not work