Problem with my radio script (regarding PlayAudioStreamForPlayer)
#1

Hello there folks,

So the past five days I've been working on a radio script. The script allows you to place a radio (object) onto the ground and set it to a specefic channel. Setting this channel will cause all the near players to hear the stream. Once they get out of the range of the radio, the stream will stop. This is basically so different people will be able to place radios on different locations.

pawn Код:
forward Boombox(playerid);
public Boombox(playerid)
{
    foreach(Player,i) // Looping through all the players
    {
        if(pInfo[i][BoomboxStreamOn] == 1) // If a player has a radio which has it's stream on.
        {
            if(IsPlayerInRangeOfPoint(playerid, 40, pInfo[i][BoomboxX], pInfo[i][BoomboxY], pInfo[i][BoomboxZ]))
// If the player (where the timer is set for) is in range of a radio of another player where the stream is on from.
            {
                if(pInfo[playerid][ListeningBoombox] == 0) // Checking if the player already listens to a stream.
                {
                    pInfo[playerid][ListeningBoombox] = 1; // Setting the listening variable to 1.
                    new Float:Distance = 40;
                    PlayAudioStreamForPlayer(playerid, pInfo[i][BoomboxStream], pInfo[i][BoomboxX], pInfo[i][BoomboxY], pInfo[i][BoomboxZ], Distance, 1); // Play the stream.
                }
            }
            else
            {
                pInfo[playerid][ListeningBoombox] = 0; // Listening variable to 0.
                StopAudioStreamForPlayer(playerid); // Stopping stream.
            }
        }
        else
        {
            pInfo[playerid][ListeningBoombox] = 0;
            StopAudioStreamForPlayer(playerid);
        }
    }
   
    return 1;
}
As you can see I made a timer for each player seperatly. This timer will repeat itself every second. It's basically regarding the fact if someone comes near a radio, it will the play the stream for him/her, and if they get out of range, it will stop. My problem seems taking place in this code.

Right now, if I test this and there are a couple of players online, the stream does not start for the person where the radio is from, while the other players will get the stream get spammed in the chat non-stop.

I hope anyone has the right solution for this problem and I'd really appreciate some assistance!

Greetings,
Chilco.
Reply


Messages In This Thread
Problem with my radio script (regarding PlayAudioStreamForPlayer) - by Chilco - 18.01.2012, 15:18
Re: Problem with my radio script (regarding PlayAudioStreamForPlayer) - by Chilco - 20.01.2012, 21:52
Re: Problem with my radio script (regarding PlayAudioStreamForPlayer) - by ғαιιοцт - 20.01.2012, 22:50

Forum Jump:


Users browsing this thread: 1 Guest(s)