Play audio stream for everyone in the car help
#1

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

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?
Reply
#3

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

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;
}
Reply
#5

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.
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)