Radio Problem
#1

The problem is that when you enter the server, and if you go in to anycar as passanger the radio will start palying and never stop, also when you enter a car with radio and turn it on off, leave enter there is no effect, radio just plays, the code is below:

pawn Код:
new RadioIsOn2[MAX_VEHICLES] = 0;
new RadioIsOn[MAX_PLAYERS] = 0;
Turn Radio On
pawn Код:
CarRadio[0][playerid] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1821702",false,false,false);
                    new vehicleid = GetPlayerVehicleID(playerid);
                    RadioIsOn2[vehicleid] = 1;
                    for(new i=0; i<MAX_PLAYERS; i++)
                    {
                        if(GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid))
                        {
                            CarRadio[0][i] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1821702",false,false,false);
                        }
                    }
Turn Radio OFF
pawn Код:
Audio_Stop(playerid, CarRadio[0][playerid]);
                    new vehicleid = GetPlayerVehicleID(playerid);
                    RadioIsOn2[vehicleid] = 0;
                    for(new i=0; i<MAX_PLAYERS; i++)
                    {
                        if(GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid))
                        {
                            Audio_Stop(i, CarRadio[0][playerid]);
                        }
                    }
When you enter and radio is on, it will play for you.
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {

        if(IsPlayerInVehicle(playerid, Vehicle090[playerid]))
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            if(RadioIsOn2[vehicleid] == 1)
            {
                CarRadio[0][playerid] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1821702",false,false,false);
            }
        }
If you enter as passanger radio will come back on if its on
pawn Код:
if(newstate == PLAYER_STATE_PASSENGER)
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        new vehicleid = GetPlayerVehicleID(playerid);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                for(new i=0; i<MAX_PLAYERS; i++)
                {
                    if(GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid))
                    {
                        CarRadio[0][i] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1821702",false,false,false);
                    }
                }
Stop Radio When you leave the car
pawn Код:
if(newstate == PLAYER_STATE_ONFOOT)
    {
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid))
            {
                Audio_Stop(i, CarRadio[0][i]);
            }
        }
        Audio_Stop(playerid, CarRadio[0][playerid]);
Any ideas?
Reply


Messages In This Thread
Radio Problem - by HondaCBR - 30.11.2011, 08:22
Re: Radio Problem - by blewert - 30.11.2011, 09:04
Re: Radio Problem - by HondaCBR - 30.11.2011, 09:55

Forum Jump:


Users browsing this thread: 1 Guest(s)