Boombox in GM help
#1

Ok so I have a boombox script in my GM, it works awesome... except for one thing... If It's on and a player later connects they don't hear it. They only hear it if its truned on WHILE they are connected. How do I fix this so it plays when a player connects if it's on?

Here is the code (the song part isn't included. Ask if I need to give that too):
pawn Код:
if(strcmp(cmd, "/playradio", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
        }
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[USAGE]:{FFFFFF} /playradio {009900}(on/off){FFFFFF}");
            return 1;
        }
        if(strcmp(tmp,"on",true) == 0)
        {
            if(PlayerInfo[playerid][pAdmin] == 1337)
            {
                ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
                new Float:X, Float:Y, Float:Z;
                GetPlayerPos(playerid, X, Y, Z);
                playerBoombox[playerid] = CreateObject(2103, X, Y+1, Z, 1.5, 0.0, 0.0, 0.0);
                ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Los Santos Radio","Top Teen Radio\nTop Radio\nClassic Hits Radio\nRock Radio\nTop Teen Radio (ALL)\nTop Radio (ALL)\nChristmas Songs\nChristmas Songs (ALL)","Select","Cancel");        }
        }
        if(strcmp(tmp,"off",true) == 0)
        {
            if(PlayerInfo[playerid][pAdmin] == 1337)
            {
                DestroyObject(playerBoombox[playerid]);
                for(new i = 0; i < MAX_PLAYERS; i++)
                StopAudioStreamForPlayer(i);
            }
        }
        return 1;
    }
Thanks: jakejohnsonusa
Reply
#2

Is it an MP3 or a livestream?
If it is an MP3, music of new players will start at the beginning of the MP3.

You will need to save the coordinates of the boombox. When a player connects check if there are any boomboxes, if so, start the audiostream.

Another advisable thing, is that if you are using a 'range' on your stream, to not start the stream for people not withing that range.
Check if anyone enters the range, with a timer or the 'streamer' plugin.
Reply
#3

Thanks, I am a begginer scripter though. So I am a bit confused what to do. I use live streams and ranges.
Here is the other part of the script:
pawn Код:
if(dialogid == 1 && response)
        {
            switch(listitem)//playradio
            {
                case 0:
                { // Top Teen Radio
                    new Float:X, Float:Y, Float:Z, Float:Distance = 500.0;
                    GetPlayerPos(playerid, X, Y, Z);
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    PlayAudioStreamForPlayer(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=104760", X, Y, Z, Distance, 500);//Teen Top Music
                }
                case 1:
                { // Top Radio
                    new Float:X, Float:Y, Float:Z, Float:Distance = 500.0;
                    GetPlayerPos(playerid, X, Y, Z);
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    PlayAudioStreamForPlayer(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1078816", X, Y, Z, Distance, 500);//Top Music Songs
                }
                case 2:
                { // Classic Hits Radio
                    new Float:X, Float:Y, Float:Z, Float:Distance = 10.0;
                    GetPlayerPos(playerid, X, Y, Z);
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    PlayAudioStreamForPlayer(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=9472196", X, Y, Z, Distance, 500);//Hit Music (Old and New)
                }
                case 3:
                { // Rock Radio
                    new Float:X, Float:Y, Float:Z, Float:Distance = 10.0;
                    GetPlayerPos(playerid, X, Y, Z);
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    PlayAudioStreamForPlayer(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1331010", X, Y, Z, Distance, 500);//Rock
                }
                case 4:
                { // Top Teen Radio (ALL)
                    new Float:X, Float:Y, Float:Z, Float:Distance = 100.0;
                    GetPlayerPos(playerid, X, Y, Z);
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    PlayAudioStreamForPlayer(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=104760", X, Y, Z, Distance, 100);//Teen Top Music (ALL)
                }
                case 5:
                { // Top Radio (ALL)
                    new Float:X, Float:Y, Float:Z, Float:Distance = 10.0;
                    GetPlayerPos(playerid, X, Y, Z);
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    PlayAudioStreamForPlayer(i, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1078816", X, Y, Z, Distance, 500);//Top Music Songs (ALL)
                }
                case 6:
                { // Christmas Songs
                    new Float:X, Float:Y, Float:Z, Float:Distance = 100.0;
                    GetPlayerPos(playerid, X, Y, Z);
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    PlayAudioStreamForPlayer(i, "http://listen.sky.fm/public3/christmas.pls", X, Y, Z, Distance, 100);//Christmas Music
                }
                case 7:
                { // Christmas Songs (ALL)
                    new Float:X, Float:Y, Float:Z, Float:Distance = 500.0;
                    GetPlayerPos(playerid, X, Y, Z);
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    PlayAudioStreamForPlayer(i, "http://listen.sky.fm/public3/christmas.pls", X, Y, Z, Distance, 500);//Christmas Music (ALL)
                }
            }
        }
Reply
#4

I still need to have it where the players can hear the boombox if they connect AFTER they boombox is turned on. As now they can only hear it if its turned on when they are connected. How should I fix this in my GM script.

Please help, I usually Rep I get helped
Thanks: jakejohnsonusa
Reply
#5

If somebody connects, you need to check, if BoomBox is playing, if it is, then you need to get BoomBox range, and if player is in range, you need to play audio stream.
For that you need to make a script what get the state of BoomBox(On or Off)
You should make this to OnPlayerSpawn.

Sorry for my bad English, very bad Englis
Reply
#6

Is there a way to do this with my current script? I am a very begginer scripter, so including codes would be excellent!

Thanks,
jakejohnsonusa
Reply
#7

Use OnPlayerUpdate. If he is near positions of boombox turn it on.
Reply
#8

So if player is in range of playerBoombox[playerid] ?
Reply
#9

Ahhh, I'm confused which is why I need help.

How would I do range as is depends on stream being played (somtimes it's 500 and somtimes 100)?
How would I do the code that it's on?
Please tell me exactly what to put based on my code (sorry, but I am a very begginer to this type of thing).

Thanks so much!

+1 Rep for the help so far.
Reply
#10

Quote:
Originally Posted by jakejohnsonusa
Посмотреть сообщение
Ahhh, I'm confused which is why I need help.

How would I do range as is depends on stream being played (somtimes it's 500 and somtimes 100)?
How would I do the code that it's on?
Please tell me exactly what to put based on my code (sorry, but I am a very begginer to this type of thing).

Thanks so much!

+1 Rep for the help so far.
Download 0.3e server kit and in FS's find iradio.pwn. That is example how to use internet radio. Or check boombox system from FS forum.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)