Music for players near 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: Music for players near car (
/showthread.php?tid=407033)
Music for players near car -
DJGama101 - 12.01.2013
Hello. I wanted to make script that will play music for players near ceratin car and stop if they move out from that car.
Here is my code:
Код:
new BusMuza;
public OnFilterScriptInit()
{
BusMuza = CreateVehicle(437,914.2512,-1692.9191,13.5017,179.9307,5,5, 5000);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "Muzyka", 0);
SetPVarString(playerid, "BoomboxURL", "http://djmixes.radioparty.pl:8888/listen.pls");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
new BusMuza;
if((vehicleid == BusMuza) && (GetPVarInt(forplayerid, "Muzyka") == 0)) {
SetPVarInt(forplayerid, "Muzyka", 1);
new streamurl[256];
GetPVarString(forplayerid, "BoomboxURL", streamurl, 256);
PlayAudioStreamForPlayer(forplayerid, streamurl);
return 1;
}
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
new BusMuza;
if((vehicleid == BusMuza) && (GetPVarInt(forplayerid, "Muzyka") == 1)) {
SetPVarInt(forplayerid, "Muzyka", 0);
StopAudioStreamForPlayer(forplayerid);
return 1;
}
return 1;
}
But it isn't working at all
Any ideas?
Re: Music for players near car -
[MG]Dimi - 12.01.2013
Should be good. That's all you need. PlayAudioStreamForPlayer has build-in params for location, use them.
PHP код:
new BusMuza;
public OnFilterScriptInit()
{
BusMuza = CreateVehicle(437,914.2512,-1692.9191,13.5017,179.9307,5,5, 5000);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "Muzyka", 0);
SetPVarString(playerid, "BoomboxURL", "http://djmixes.radioparty.pl:8888/listen.pls");
new streamurl[256],Float:Pos[3];
GetPVarString(forplayerid, "BoomboxURL", streamurl, 256);
GetVehiclePos(BusMuza,Pos[0],Pos[1],Pos[2]);
PlayAudioStreamForPlayer(playerid, streamurl,Pos[0],Pos[1],Pos[2],20.0,1);
return 1;
}
Re: Music for players near car -
DJGama101 - 24.01.2013
Yes, but i wanted to attach music to car, so if player is near moving car will hear this audio stream
And when he is gone away from that car the audio stream will stop
Re: Music for players near car -
SuperViper - 24.01.2013
You can't attach audio to a vehicle without timers, which wouldn't be a good way of doing it.