[HELP]How can i make /play play in car im using audio plugin and only in car
#1

How can i make /play play in the vehicle so only me and who ever is in the car can hear it.This is my code right now.
Code:
dcmd_play(playerid, params[])
{
	#pragma unused playerid
	new
		audioid,
		bool:downmix,
		bool:loop,
		bool:pause;
	if (sscanf(params, "dddd", audioid, pause, loop, downmix))
	{
		SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /play <audioid> <pause (0/1)> <loop (0/1)> <downmix (0/1)>");
		return 1;
	}
	/*for(new i; i<MAX_PLAYERS; i++)
	{
	if(IsPlayerConnected(i))
	{
	Audio_Play(i,audioid, pause, loop, downmix);  //Use i instead of playerid here
	}
	}*/
	new vehicleid = GetPlayerVehicleID(playerid);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
   	Audio_Play(playerid,audioid, pause, loop, downmix);  //Use i instead of playerid here
	return 1;

   }
I want to make it so like if the player dat does /play in the vehicle can hear it i want for the people dats in the vehicle with him can hear it also.Not just him.
Reply
#2

Anyone??
Reply
#3

BUMPED BEEN 1 DAY And still no reply damn.If someone can atleast reply with some helpful answer i will appreciate it.
Reply
#4

Find the other people in the car by finding the vehicle ID from the driver and checking everybody in a loop, and if that vehicle id matchs up with them and they're a passenger play them the music.
Reply
#5

Can you show me like what you mean like a example or something thanks.
Reply
#6

BUMPED Been 1 day
Reply
#7

Get the vehicle the main player is driving:
Code:
new VehID = GetPlayerVehicleID(playerid);
Check who else is in the car that isn't the driver:
Code:
for(new i = 0; i < GetMaxPlayers(); i++ )
{
if(GetPlayerVehicleID(i) == VehID && GetPlayerVehicleSeat(i) != 0)
Play them the audio.
Code:
Audio_Play(i,audioid, pause, loop, downmix);
So to conclude:

Code:
new VehID = GetPlayerVehicleID(playerid);
for(new i = 0; i < GetMaxPlayers(); i++ )
{
    if(GetPlayerVehicleID(i) == VehID && GetPlayerVehicleSeat(i) != 0)
    {
        Audio_Play(i,audioid, pause, loop, downmix);
    }
}
That will play the audio to everybody but the driver that's in that vehicle.
Reply
#8

So it wont play for the driver only passangers how can i make it play for driver and passangers?
Reply
#9

Code:
dcmd_play(playerid, params[])
{
        #pragma unused playerid
        new
                audioid,
                bool:downmix,
                bool:loop,
                bool:pause;
        if (sscanf(params, "dddd", audioid, pause, loop, downmix))
        {
                SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /play <audioid> <pause (0/1)> <loop (0/1)> <downmix (0/1)>");
                return 1;
        }
        /*for(new i; i<MAX_PLAYERS; i++)
        {
        if(IsPlayerConnected(i))
        {
        Audio_Play(i,audioid, pause, loop, downmix);  //Use i instead of playerid here
        }
        }*/
    new VehID = GetPlayerVehicleID(playerid);
for(new i = 0; i < GetMaxPlayers(); i++ )
{
    if(GetPlayerVehicleID(i) == VehID && GetPlayerVehicleSeat(i) != 0)
    {
        Audio_Play(i,audioid, pause, loop, downmix);
        Audio_Play(playerid,audioid, pause, loop, downmix);
        }
    }
}
It doesnt work it says "Unknown command"
Reply
#10

Quote:
Originally Posted by Lilcuete
View Post
Code:
dcmd_play(playerid, params[])
{
        #pragma unused playerid
        new
                audioid,
                bool:downmix,
                bool:loop,
                bool:pause;
        if (sscanf(params, "dddd", audioid, pause, loop, downmix))
        {
                SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /play <audioid> <pause (0/1)> <loop (0/1)> <downmix (0/1)>");
                return 1;
        }
        /*for(new i; i<MAX_PLAYERS; i++)
        {
        if(IsPlayerConnected(i))
        {
        Audio_Play(i,audioid, pause, loop, downmix);  //Use i instead of playerid here
        }
        }*/
    new VehID = GetPlayerVehicleID(playerid);
for(new i = 0; i < GetMaxPlayers(); i++ )
{
    if(GetPlayerVehicleID(i) == VehID && GetPlayerVehicleSeat(i) != 0)
    {
        Audio_Play(i,audioid, pause, loop, downmix);
        Audio_Play(playerid,audioid, pause, loop, downmix);
        }
    }
}
It doesnt work it says "Unknown command"
BUMPED it has been 1 day please try to respond to this new problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)