SA-MP Forums Archive
[Help] > Radio listeners.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help] > Radio listeners.. (/showthread.php?tid=479198)



[Help] > Radio listeners.. - Jacapo - 03.12.2013

Hello sa-mp forum!

I trying to make radio system with listeners..

pawn Код:
public OnDialogResponse(playerid, dialogid, response)
{
    switch(dialogid)
    {
        case RADIO_STATIONS:
        {
            switch(listitem)
            {
                case 0: //HipHop
                {
                    //Play music...
                    radio1++;
                }
                case 1: //Country
                {
                    //Play music...
                    radio2++;
                }
                case 2: //Oldies
                {
                    //Play music...
                    radio3++;
                }
            }
        }
    }
    return 1;
}

CMD:radio(playerid, params[])
{
    new r_str[200];
    format(r_str, sizeof(r_str), "Radio HipHop [%i listeners]\nRadio Country [%i listeners]\nRadio Oldies [%i listeners]", radio1, radio2, radio3);
    ShowPlayerDialog(playerid, RADIO_STATIONS, DIALOG_STYLE_LIST, "Radio stations:", r_str, "Stream", "Close");
    return 1;
}
But it is buggy.. when player change radio station, the count of listeners are same..
Sorry for my bad English.

Thanks for any reply/help!


Re: [Help] > Radio listeners.. - ]Rafaellos[ - 03.12.2013

You should remove the player from the previous station, so you can have the correct results. An idea how to do it:

pawn Код:
new radio[3];
new currentstation[MAX_PLAYERS];

public OnDialogResponse(playerid, dialogid, response)
{
    switch(dialogid)
    {
        case RADIO_STATIONS:
        {
            switch(listitem)
            {
                new i = currentstation[playerid];
                case 0: //HipHop
                {
                    //Play music...
                    radio[i]--;
                    radio[0]++;
                    i = 0;
                }
                case 1: //Country
                {
                    //Play music...
                    radio[i]--;
                    radio[1]++;
                    i = 1;
                }
                case 2: //Oldies
                {
                    //Play music...
                    radio[i]--;
                    radio[2]++;
                    i = 2;
                }
            }
        }
    }
    return 1;
}

CMD:radio(playerid, params[])
{
    new r_str[200];
    format(r_str, sizeof(r_str), "Radio HipHop [%i listeners]\nRadio Country [%i listeners]\nRadio Oldies [%i listeners]", radio[0], radio[1], radio[2]);
    ShowPlayerDialog(playerid, RADIO_STATIONS, DIALOG_STYLE_LIST, "Radio stations:", r_str, "Stream", "Close");
    return 1;
}
Not tested, improve it as much as you can for no bugs.


Re: [Help] > Radio listeners.. - Jacapo - 03.12.2013

This code wont work, it add -1 to the first radio station so for example: Radio HipHop [-5 listeners] and also when player stream same radio 2x it will add +1.


Re: [Help] > Radio listeners.. - ]Rafaellos[ - 03.12.2013

pawn Код:
new radio[3] = 0;
new currentstation[MAX_PLAYERS] = -1;
Try it like that.


Re: [Help] > Radio listeners.. - Jacapo - 03.12.2013

nothing changed


Re: [Help] > Radio listeners.. - Jacapo - 03.12.2013

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
pawn Код:
new radio[3] = 0;
new currentstation[MAX_PLAYERS] = -1;
Try it like that.
When i changed currentstation to -1 everything is null. Now i trying my other way to do it.


Re: [Help] > Radio listeners.. - ]Rafaellos[ - 03.12.2013

In theory it should work. Get the idea and customise it so it will work! Don't wait everything from others, work something on you'r own!


Re: [Help] > Radio listeners.. - Jacapo - 03.12.2013

You are right. In theory it should work.
Yes, but i dont only waiting for others a than copy&paste, because thats not my style. I still work my own scripts, only when i really need help i post help on this forum, so now i made this radio system, pretty simple.
It checks what a radio player streaming and system cant add +1 to listeners when he is already streaming same radio station... and when player called function stop than system detects what player has listening to and than system give -1 for specific radio station.

Anyway thanks for helping me, sometimes i dont have idea how to do, but only when i post help on this forum i got idea (sorry for bad ENG)