11.05.2015, 22:23
I have a radio station command and i need help. It works fine but when you get out of the vehicle the music doesn't stop playing and i want to fix that. How do i make it so the music stops when the player exits the vehicle. Here is the command.
Код:
CMD:stereo(playerid, params[]) { if(!IsPlayerInAnyVehicle(playerid)) { return SendClientMessageEx(playerid, COLOR_WHITE, "You must be in a car to use a car radio."); } else if(isnull(params)) { SendClientMessageEx(playerid, COLOR_WHITE, "TIP: /stereo [station] (0 - 3)"); SendClientMessageEx(playerid, COLOR_WHITE, "0:OFF 1:COUNTRY 2:80'S HAIRBAND 3:COMING SOON"); return 1; } new string[128], station[256]; switch(strval(params)) { case 0: { format(string, sizeof(string), "%s turns off the radio.",GetPlayerNameEx(playerid)); foreach(Player, i) if(GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid)){ StopAudioStreamForPlayer(i); //stationidp[i] = 0; stationidv[GetPlayerVehicleID(playerid)] = 0; } } case 1: { format(string, sizeof(string), "%s changes the station to Kickin' Country",GetPlayerNameEx(playerid)); PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=446371"); stationidv[GetPlayerVehicleID(playerid)] = 1; } case 2: { format(string, sizeof(string), "%s changes the station to 80's Hairband",GetPlayerNameEx(playerid)); PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=226429"); stationidv[GetPlayerVehicleID(playerid)] = 2; } case 3: { format(string, sizeof(string), "%s changes the station to TechnoBase",GetPlayerNameEx(playerid)); PlayAudioStreamForPlayer(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1377200"); stationidv[GetPlayerVehicleID(playerid)] = 3; } default: return SendClientMessageEx(playerid, COLOR_WHITE, "Invalid station specified."); } ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); foreach(Player, i) if(GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid) && Audio_IsClientConnected(i)) { Audio_Stop(i, stationidp[i]); stationidp[i] = Audio_PlayStreamed(i, station, false, true, false); Audio_SetVolume(i, stationidp[i], 30); } return 1; }