Play the music only on area?
#1

I'm creating a DJ system.
It doesn't work.

I use IsPlayerInArea if player is in area of the club.
To make it work.

But it doesn't work.
Codes

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == MUSIC)
    {
        if(!response) return 1;
        else if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    Music = 1;
                    Playing = 1;
                    PlayAudioStreamForPlayer(playerid, "http://scfire-ntc-aa04.stream.aol.com:80/stream/1093");
                    format(str, sizeof(str), "DjCmd: Dj %s(%d) has played the Energy 98 radio on the Party Club! (/club)", GetName(playerid), playerid);
                    SendClientMessageToAll(COLOR_YELLOW, str);
                    SendClientMessage(playerid, COLOR_LIME, "[Dj]: You played the Energy 98 radio on the club!");
                }
                case 1:
                {
                    Music = 2;
                    Playing = 1;
                    PlayAudioStreamForPlayer(playerid, "http://72.232.2.83:8000");
                    format(str, sizeof(str), "DjCmd: Dj %s(%d) has played the Dubstep FM radio on the Party Club! (/club)", GetName(playerid), playerid);
                    SendClientMessageToAll(COLOR_YELLOW, str);
                    SendClientMessage(playerid, COLOR_LIME, "[Dj]: You played the Dubstep FM radio on the club!");
                }
                case 2:
                {
                    ShowPlayerDialog(playerid, MUSIC2, DIALOG_STYLE_INPUT, ""white"Input the URL", ""white"Input the URL that you want to play in the club!", "Play", "Back");
                }
                case 3:
                {
                    StopAudioStreamForPlayer(playerid);
                    Music = 0;
                    Playing = 0;
                    format(str, sizeof(str), "DjCmd: Dj %s(%d) has stopped playing the music on the Party Club! (/club)", GetName(playerid), playerid);
                    SendClientMessageToAll(COLOR_YELLOW, str);
                    SendClientMessage(playerid, COLOR_LIME, "[Dj]: You stopped playing the music on the club!");
                }
            }
        }
    }
    if(dialogid == MUSIC2)
    {
        if(!response) return ShowPlayerDialog(playerid, MUSIC, DIALOG_STYLE_LIST, ""white"DJ Dialog", "Energy 98\nDupstep FM\nPlay music from URL", "Play", "Cancel");
        else if(response)
        {
            Music = 3;
            Playing = 1;
            new m[956];
            format(m, 956, "%s", inputtext);
            MusicT = m;
            PlayAudioStreamForPlayer(playerid, inputtext);
            format(str, sizeof(str), "DjCmd: Dj %s(%d) has played the Custom Music on the Party Club! (/club)", GetName(playerid), playerid);
            SendClientMessageToAll(COLOR_YELLOW, str);
            SendClientMessage(playerid, COLOR_LIME, "[Dj]: You played the custom music on the club!");
        }
    }
    return 1;
}


public OnPlayerUpdate(playerid)
{
    if(IsPlayerInArea(playerid, 1268.768432,-1638.078857,1213.523315,-1677.192504))
    {
        if(Playing == 1)
        {
            if(Music == 1)
            {
                PlayAudioStreamForPlayer(playerid, "http://scfire-ntc-aa04.stream.aol.com:80/stream/1093");
            }
            else if(Music == 2)
            {
                PlayAudioStreamForPlayer(playerid, "http://72.232.2.83:8000");
            }
            else if(Music == 3)
            {
                PlayAudioStreamForPlayer(playerid, MusicT);
            }
        }
    }
    else
    {
        if(Playing == 1)
        {
            StopAudioStreamForPlayer(playerid);
        }
    }
    return 1;
}

stock IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
{
    new Float:xx, Float:xy, Float:xz;
    GetPlayerPos(playerid, xx, xy, xz);
    if(xx >= MinX && xx <= MaxX && xy >= MinY && xy <= MaxY) return 1;
    return 0;
}
Reply
#2

Why using IsPlayerInArea
PlayAudioStreamForPlayer has its own specific position params
(playerid, url[], Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = 0)
https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)