Not play music if the player is in car - 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: Not play music if the player is in car (
/showthread.php?tid=658385)
Not play music if the player is in car -
Pachino - 03.09.2018
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);
}
Re: Not play music if the player is in car -
Sew_Sumi - 03.09.2018
https://sampwiki.blast.hk/wiki/GetPlayerState
PHP код:
new tempstate = GetPlayerState(i);
if(tempstate==PLAYER_STATE_DRIVER||tempstate==PLAYER_STATE_PASSENGER)
This will make for a check that you would deny the stream based on them being in a car.
PHP код:
if(tempstate==PLAYER_STATE_DRIVER||tempstate==PLAYER_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.
PHP код:
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).
Re: Not play music if the player is in car -
Pachino - 03.09.2018
Doesn't work, can you please help me with importing that in my code? Thanks