24.09.2017, 01:43
idk if its possible but...i wanna make a sound car so i want to put a stream audio playing fixed in the car position. can i play an audio from a car in movement? how?
enum E_VEHICLE_DATA
{
bool:VehicleRadioOn,
VehicleRadioURL[128]
}
new VehicleInfo[MAX_VEHICLES][E_VEHICLE_DATA];
CMD:radio(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessgae(playerid, -1, "You aren't in a vehicle...");
new
vehicleid = GetPlayerVehicleID(playerid);
if(VehicleRadioOn[vehicleid][VehicleRadioOn])
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(IsPlayerInVehicle(i, vehicleid))
{
StopAudioStreamForPlayer(i);
SendClientMessage(i, -1, "The radio was stopped.");
}
}
}
else
{
if(isnull(params) || strlen(params) < 3)
return SendClientMessgae(playerid, -1, "/radio [url] to turn it on.");
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(IsPlayerInVehicle(i, vehicleid))
{
PlayAudioStreamForPlayer(i, params);
SendClientMessage(i, -1, "The radio started...");
}
}
}
return 1;
}
It's nothing special. You could do, for example:
PHP код:
You want to make a command to be able to set the station and turn it on and off. PHP код:
If they leave and the radios on, stop the audio stream. If they enter and it's on, start the audio stream. https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer https://sampwiki.blast.hk/wiki/StopAudioStreamForPlayer https://sampwiki.blast.hk/wiki/IsPlayerInVehicle https://sampwiki.blast.hk/wiki/OnPlayerStateChange (There's a full working system for this here: https://sampforum.blast.hk/showthread.php?tid=641235 if you want to check it out.) |