Play audio stream for everyone in the car 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: Play audio stream for everyone in the car help (
/showthread.php?tid=356416)
Play audio stream for everyone in the car help -
Euan Hughes - 03.07.2012
Hey so how would i be able to make it so when the player turns the radio on and a audio is played how can i make it so everyone in the car can hear it...
Please help
pawn Код:
command(radiostation, playerid, params[])
{
if(GetPlayerState(playerid) == 2)
{
if(Player[playerid][CarRadio] >= 1)
{
if(Player[playerid][CarRadioOn] == 1)
{
PlayAudioStreamForPlayer(playerid, "Songhere");
}
}
}
}
If you need any more code just ask
Thanks
Re: Play audio stream for everyone in the car help -
.FuneraL. - 03.07.2012
pawn Код:
CMD:radiostation(playerid)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in one car.");
if(IsPlayerInAnyVehicle(playerid)) return PlayAudioStreamForPlayer(playerid, "Songhere");
return 1;
}
This is what you looking for? even need to use the variables?
Re: Play audio stream for everyone in the car help -
Euan Hughes - 03.07.2012
Quote:
Originally Posted by .FuneraL.
pawn Код:
CMD:radiostation(playerid) { if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in one car."); if(IsPlayerInAnyVehicle(playerid)) return PlayAudioStreamForPlayer(playerid, "Songhere"); return 1; }
This is what you looking for? even need to use the variables?
|
Will that play for one car when its played or for ALL the cars
Thanks
Re: Play audio stream for everyone in the car help -
iggy1 - 03.07.2012
Loop through players check if they are in the same vehicle, and play sounds if they are.
pawn Код:
command(radiostation, playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid)
{
for(new i; i < MAX_PLAYERS; ++i)//foreach would be much better
{
if(!IsPlayerConnected(i))continue;
if(IsPlayerInVehicle(i, vehicleid))
{
PlayAudioStreamForPlayer(i, "music.com");
}
}
}
return 1;
}
Re: Play audio stream for everyone in the car help -
[KHK]Khalid - 03.07.2012
here ya go
pawn Код:
new pVeh = GetPlayerVehicleID(playerid); // store the player's vehicle id into the var pVeh
for(new i = 0; i < MAX_PLAYERS; i ++) // looping through all players
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i))
continue;
// here they are connected and not NPCes
if(PVeh == GetPlayerVehicleID(i)) // if pVeh (the id of the player's vehicle) equals to i's (connected player) vehicleid
{
PlayAudioStreamForPlayer(i, "Your URL here"); // plays it for the connected player.
}
}