Help with radio script?
#1

Hello , so I have a radio script but I would like it to save the radio on the car (when a player gets out and enters again the stream should be the same) and also close on the /exit command. A bit of help?
Pwn file: https://www.dropbox.com/s/1rhletddd62ud1x/yradio.pwn

thank you
Reply
#2

When the player selects a stream, add a variable, like, streamid or something.
Then, when a player enters a vehicle, check what the last streamid was.
if(streamid == 1)
{
//some stream
}
if(streamid == 2)
{
//some other stream
}

And so on.
Reply
#3

Quote:
Originally Posted by Jari_Johnson*
Посмотреть сообщение
When the player selects a stream, add a variable, like, streamid or something.
Then, when a player enters a vehicle, check what the last streamid was.
if(streamid == 1)
{
//some stream
}
if(streamid == 2)
{
//some other stream
}

And so on.
A bit more noob-friendly? XD
Reply
#4

In your script, add under the includes: new Laststream[MAX_PLAYERS];
Then, go to OnDialogResponse, and add the id of the case to laststream.
pawn Код:
if(response) {
        switch(dialogid == 2)
        {
            case 1: {
                switch(listitem)
                {
                    case 0: {
                        StopAudioStreamForPlayer(playerid);
                        PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
                        PlayAudioStreamForPlayer(playerid, "http://stream.profm.ro:8012/profm.mp3");
                        SendClientMessage(playerid,0x00FFFAFF,"ProFM");
                        Laststream[playerid] = 0;
                        return 1;
                    }
                    case 1: {
                        StopAudioStreamForPlayer(playerid);
                        PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
                        PlayAudioStreamForPlayer(playerid, "http://radiotaraf.no-ip.biz:7100");
                        SendClientMessage(playerid,0x00FFFAFF,"Radio Taraf");
                        Laststream[playerid] = 1;
                        return 1;
                    }
                    case 2: {
                        StopAudioStreamForPlayer(playerid);
                        PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
                        PlayAudioStreamForPlayer(playerid, "http://srv04.bigstreams.de/bigfm-mp3-64");
                        SendClientMessage(playerid,0x00FFFAFF,"BigFM");
                        Laststream[playerid] = 2;
                        return 1;
                    }
I showed the first 3 cases, just do the same for the remaining cases.
Then, under OnPlayerStateChange, add something like this:
pawn Код:
if(Laststream[playerid] == 0)
{
//Play the audio stream from case 0
}
if(Laststream[playerid] == 1)
{
//play the audio stream from case 1
}
And so on.
I hope you get what I mean :P
Reply
#5

Quote:
Originally Posted by Jari_Johnson*
Посмотреть сообщение
In your script, add under the includes: new Laststream[MAX_PLAYERS];
Then, go to OnDialogResponse, and add the id of the case to laststream.
pawn Код:
if(response) {
        switch(dialogid == 2)
        {
            case 1: {
                switch(listitem)
                {
                    case 0: {
                        StopAudioStreamForPlayer(playerid);
                        PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
                        PlayAudioStreamForPlayer(playerid, "http://stream.profm.ro:8012/profm.mp3");
                        SendClientMessage(playerid,0x00FFFAFF,"ProFM");
                        Laststream[playerid] = 0;
                        return 1;
                    }
                    case 1: {
                        StopAudioStreamForPlayer(playerid);
                        PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
                        PlayAudioStreamForPlayer(playerid, "http://radiotaraf.no-ip.biz:7100");
                        SendClientMessage(playerid,0x00FFFAFF,"Radio Taraf");
                        Laststream[playerid] = 1;
                        return 1;
                    }
                    case 2: {
                        StopAudioStreamForPlayer(playerid);
                        PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
                        PlayAudioStreamForPlayer(playerid, "http://srv04.bigstreams.de/bigfm-mp3-64");
                        SendClientMessage(playerid,0x00FFFAFF,"BigFM");
                        Laststream[playerid] = 2;
                        return 1;
                    }
I showed the first 3 cases, just do the same for the remaining cases.
Then, under OnPlayerStateChange, add something like this:
pawn Код:
if(Laststream[playerid] == 0)
{
//Play the audio stream from case 0
}
if(Laststream[playerid] == 1)
{
//play the audio stream from case 1
}
And so on.
I hope you get what I mean :P
And that will save the radio on the car , right?
Also how can I make it so everyone inside the car can hear the radio?
Reply
#6

It will save it only for when the player is online, if the player reconnects, the stream will be reset to 0 again.
If you want everyone in the car to hear it, you will need to loop trough the people in the vehicle, you can use this stock for that.
pawn Код:
stock PlayAudioStreamForPlayersInCar(vehicleid,url[])
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            if(GetPlayerVehicleID(i) == vehicleid)
            {
            PlayAudioStreamForPlayer(i,url);
            }
        }
    }
}
I haven't tested it, just made it in a few minutes, so it might not work.
To use this, you will need to replace the PlayAudioStreamForPlayer with PlayAudioStreamForPlayersInVehicle(vehicleid,strea m_url_here);
Reply
#7

Quote:
Originally Posted by Jari_Johnson*
Посмотреть сообщение
It will save it only for when the player is online, if the player reconnects, the stream will be reset to 0 again.
If you want everyone in the car to hear it, you will need to loop trough the people in the vehicle, you can use this stock for that.
pawn Код:
stock PlayAudioStreamForPlayersInCar(vehicleid,url[])
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            if(GetPlayerVehicleID(i) == vehicleid)
            {
            PlayAudioStreamForPlayer(i,url);
            }
        }
    }
}
I haven't tested it, just made it in a few minutes, so it might not work.
To use this, you will need to replace the PlayAudioStreamForPlayer with PlayAudioStreamForPlayersInVehicle(vehicleid,strea m_url_here);
Код:
C:\Users\yoomx\Dropbox\yradio.pwn(71) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(71) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(86) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(86) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(99) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(99) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(227) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(227) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(229) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(229) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(234) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(234) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(236) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(236) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(241) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(241) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(243) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(243) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(248) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(248) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(250) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(250) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(255) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(255) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(257) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(257) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(262) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(262) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(264) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(264) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(269) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(269) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(271) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(271) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(276) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(276) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(278) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(278) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(283) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(283) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(285) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(285) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(290) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(290) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(292) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(292) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(297) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(297) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


24 Errors.
Reply
#8

Quote:
Originally Posted by yooMx
Посмотреть сообщение
Код:
C:\Users\yoomx\Dropbox\yradio.pwn(71) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(71) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(86) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(86) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(99) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(99) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(227) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(227) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(229) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(229) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(234) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(234) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(236) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(236) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(241) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(241) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(243) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(243) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(248) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(248) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(250) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(250) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(255) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(255) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(257) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(257) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(262) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(262) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(264) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(264) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(269) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(269) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(271) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(271) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(276) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(276) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(278) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(278) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(283) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(283) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(285) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(285) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(290) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(290) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(292) : warning 200: symbol "PlayAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(292) : error 017: undefined symbol "PlayAudioStreamForPlayersInVehi"
C:\Users\yoomx\Dropbox\yradio.pwn(297) : warning 200: symbol "StopAudioStreamForPlayersInVehi" is truncated to 31 characters
C:\Users\yoomx\Dropbox\yradio.pwn(297) : error 017: undefined symbol "StopAudioStreamForPlayersInVehi"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


24 Errors.
Someone help please?
Reply
#9

You copy/pasted something wrong..
StopAudioStreamForPlayersInVehi
Change it to StopAudioStreamForPlayersInCar.
Did you copy de StopAudioStreamForPlayersInVehicle that I posted in the snippets topic? If not, here it is:
pawn Код:
stock StopAudioStreamForPlayersInCar(vehicleid)
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            if(GetPlayerVehicleID(i) == vehicleid)
            {
            StopAudioStreamForPlayer(i);
            }
        }
    }
}
Reply
#10

Quote:
Originally Posted by Jari_Johnson*
Посмотреть сообщение
You copy/pasted something wrong..
StopAudioStreamForPlayersInVehi
Change it to StopAudioStreamForPlayersInCar.
Did you copy de StopAudioStreamForPlayersInVehicle that I posted in the snippets topic? If not, here it is:
pawn Код:
stock StopAudioStreamForPlayersInCar(vehicleid)
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            if(GetPlayerVehicleID(i) == vehicleid)
            {
            StopAudioStreamForPlayer(i);
            }
        }
    }
}
Ok , to be sure , where do I copy it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)