PDA

View Full Version : Not play music if the player is in car


Pachino
03/09/2018, 01:07 AM
Sorry for my bad english, i have made boombox system but i have one problem, when te player drive the car and listen music in the car, stream from boombox on the street appears in hes car, and that makes the problem.
Can you guys help me to solve that problem, in this checks make if player is in car to not play music for him?


public OnPlayerEnterDynamicArea(playerid, areaid)
{
foreach(new i : Player)
{
if(GetPVarType(i, "BBArea"))
{
if(areaid == GetPVarInt(i, "BBArea"))
{
new station[256];
GetPVarString(i, "BBStation", station, sizeof(station));
if(!isnull(station))
{
PlayStream(playerid, station, GetPVarFloat(i, "BBX"), GetPVarFloat(i, "BBY"), GetPVarFloat(i, "BBZ"), 30.0, 1);
}
return 1;
}
}
}
return 1;
}


And this if you want:

stock PlayStream(playerid, url[], Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = 0)
{
if(GetPVarType(playerid, "pAudioStream")) StopAudioStreamForPlayer(playerid);
else SetPVarInt(playerid, "pAudioStream", 1);
PlayAudioStreamForPlayer(playerid, url, posX, posY, posZ, distance, usepos);
}

Sew_Sumi
03/09/2018, 01:18 AM
http://wiki.sa-mp.com/wiki/GetPlayerState

new tempstate = GetPlayerState(i);
if(tempstate==PLAYER_STATE_DRIVER||tempstate==PLAY ER_STATE_PASSENGER)

This will make for a check that you would deny the stream based on them being in a car.

if(tempstate==PLAYER_STATE_DRIVER||tempstate==PLAY ER_STATE_PASSENGER)

This will make a check to confirm that they are not in a car, and able to be ready to hear the stream.

if(tempstate==PLAYER_STATE_DRIVER&&tempstate==PLAYER_STATE_PASSENGER)

Notice the OR (||) versus the AND (&&) in each of them. (Don't use both, it's highly likely the simplest usage of it would be the && check in your application).

Pachino
03/09/2018, 01:46 AM
Doesn't work, can you please help me with importing that in my code? Thanks