need help with a command to play audio url
#1

i want it to be a command like this (in this format CMD

the command ide like would be: CMD: cops


i want it to play this url: http://db.tt/WtNku5d4

i would also like for the create dynamic object to attatch to player so i may drive / walk with it playing

and i dont want it showing a url stream msg

this is the filter script that i want it edited into
I DO NOT TAKE ANY CREDIT FOR THE FILTER SCRIPT

Код:
// Includes
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <streamer>


// Defines
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_LIGHTBLUE 0x33CCFFFF
#define COLOR_GREY 0xAFAFAFFF

// Variables
new Boombox[MAX_PLAYERS];
new BoomboxObject[MAX_PLAYERS];
new BoomboxStream[MAX_PLAYERS];
new BoomboxPlayer[MAX_PLAYERS];
new BoomboxURL[MAX_PLAYERS][256];
new Float:bpos[MAX_PLAYERS][4];

// Clearing variables
public OnPlayerConnect(playerid)
{
    Boombox[playerid] = 0;
    BoomboxPlayer[playerid] = -1;
    BoomboxStream[playerid] = 0;
    bpos[playerid][0] = 0; bpos[playerid][1] = 0; bpos[playerid][2] = 0; bpos[playerid][3] = 0;
    format(BoomboxURL[playerid], 256, "");
    if(IsValidDynamicObject(BoomboxObject[playerid])) DestroyDynamicObject(BoomboxObject[playerid]);
    return 1;
}

// Clearing variables & Stopping boombox music on disconnect (Double check)
public OnPlayerDisconnect(playerid)
{
    Boombox[playerid] = 0;
    BoomboxPlayer[playerid] = -1;
    BoomboxStream[playerid] = 0;
    bpos[playerid][0] = 0; bpos[playerid][1] = 0; bpos[playerid][2] = 0; bpos[playerid][3] = 0;
    format(BoomboxURL[playerid], 256, "");
    if(IsValidDynamicObject(BoomboxObject[playerid])) DestroyDynamicObject(BoomboxObject[playerid]);
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(BoomboxPlayer[i] == playerid)
            {
                BoomboxStream[i] = 0;
                BoomboxPlayer[i] = -1;
                StopAudioStreamForPlayer(i);
                SendClientMessage(i, COLOR_GREY, " The dj has disconnected from the server.");
            }
        }
    }
    return 1;
}


// Boombox command - Usage: /boombox [URL]
CMD:cops(playerid, params[])
{
    new string[128];
    if(!Boombox[playerid])
    {
        if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cops");
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                    if(Boombox[i])
                    {
                        if(IsPlayerInRangeOfPoint(playerid, 30, bpos[i][0], bpos[i][1], bpos[i][2]))
                        {
                            SendClientMessage(playerid, COLOR_GREY, " You are too close to another cop.");
                            return 1;
                        }
                    }
            }
        }
        Boombox[playerid] = 1;
        format(string, sizeof(string), " Cops is being filmed near your location.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        GetPlayerPos(playerid, bpos[playerid][0], bpos[playerid][1], bpos[playerid][2]); bpos[playerid][2] = bpos[playerid][2] - 1;
        GetPlayerFacingAngle(playerid, bpos[playerid][3]); bpos[playerid][3] = bpos[playerid][3] +180;
        BoomboxObject[playerid] = CreateDynamicObject(0, bpos[playerid][0], bpos[playerid][1], bpos[playerid][2], 0, 0, bpos[playerid][3]);
        format(BoomboxURL[playerid], 256, "%s", params);
    }
    else
    {
        Boombox[playerid] = 0;
        format(string, sizeof(string), " You have removed your cops filming.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        DestroyDynamicObject(BoomboxObject[playerid]);
        format(BoomboxURL[playerid], 256, "");
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(BoomboxPlayer[i] == playerid)
                {
                    BoomboxStream[i] = 0;
                    BoomboxPlayer[i] = -1;
                    StopAudioStreamForPlayer(i);
                    SendClientMessage(i, COLOR_GREY, " The cop has finished they're arrest.");
                }
            }
        }
    }
    return 1;
}

// Boombox editing - Usage: /boomboxnext [url]
CMD:copsnext(playerid, params[])
{
    if(!Boombox[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You don't have a boombox placed.");
    if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /djnext [music url]");
    SendClientMessage(playerid, COLOR_GREY, " You have changed the mix your turntables are playing.");
    format(BoomboxURL[playerid], 256, "%s", params);
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
                if(BoomboxPlayer[i] == playerid)
                {
                    PlayAudioStreamForPlayer(i, BoomboxURL[playerid], bpos[playerid][0], bpos[playerid][1], bpos[playerid][2], 30, 1);
                    SendClientMessage(i, COLOR_GREY, " The track you're dj is spinning has changed.");
                }
        }
    }
    return 1;
}


// Playing/Stopping boombox music for nearby players
public OnPlayerUpdate(playerid)
{
    if(!BoomboxStream[playerid])
    {
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(Boombox[i])
                {
                    if(IsPlayerInRangeOfPoint(playerid, 50, bpos[i][0], bpos[i][1], bpos[i][2]))
                    {
                        PlayAudioStreamForPlayer(playerid, BoomboxURL[i], bpos[i][0], bpos[i][1], bpos[i][2], 50, 1);
                        BoomboxPlayer[playerid] = i;
                        BoomboxStream[playerid] = 1;
                        SendClientMessage(playerid, COLOR_GREY, " You are listening to a cops filming near your location.");
                    }
                }
            }
        }
    }
    else
    {
        new i = BoomboxPlayer[playerid];
        if(!IsPlayerInRangeOfPoint(playerid, 50, bpos[i][0], bpos[i][1], bpos[i][2]))
        {
            BoomboxStream[playerid] = 0;
            BoomboxPlayer[playerid] = -1;
            StopAudioStreamForPlayer(playerid);
            SendClientMessage(playerid, COLOR_GREY, " You have moved too far away from the cop.");
        }
    }
    return 1;
}
Reply
#2

Quote:

and i dont want it showing a url stream msg

You can't remove that message from sending to players, only the client themself can remove it (/audiomsg).
Reply
#3

pawn Код:
CMD:play(playerid, params[])
{
    if(isnull(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /play [link]");
    PlayAudioStreamForPlayer(playerid, params);
    return 1;
}
Reply
#4

pawn Код:
CMD:radio(playerid,params[])
{
            if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,-1,"You need to be in a vehicle to play the radio!");
            else
            PlayAudioStreamForPlayer(playerid,"http://dl.dropbox.com/u/33255359/COPS.mp3");
            return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER && newstate == PLAYER_STATE_ONFOOT)
    {
            StopAudioStreamForPlayer(playerid);
     }
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)