Streaming from MP3 URL with command
#1

Hello,

Instead of using a preset Stream.
How can i make it so anyone can type

/play [URL]

and it streams the URL if its a working Mp3 one?

Im not sure where to start on this so any help would be appreciated
Reply
#2

This code would do when using ZCMD and sscanf:
pawn Код:
CMD:play(playerid,params[])
{
    new url[128]; //Create a string variable for the URL
    if(sscanf(params,"s[128]",url)) return SendClientMessage(playerid,-1,"Usage: /play <url>"); //If the player didn't type an url, send this message
    PlayAudioStreamForPlayer(playerid,url); //Play the audio stream
    return 1; //Sending a signal to the server that the command was successfull
}
^ I think that should work.
Reply
#3

What about if im not using sscanf and zcmd?
Reply
#4

I think it would be like this:

pawn Код:
CMD:play(playerid,params[])
{
    if(isnull(params[0]) return SendClientMessage(playerid,-1,"Usage: /play <url>"); //If the player didn't type an url, send this message
    PlayAudioStreamForPlayer(playerid,params[0]); //Play the audio stream
    return 1; //Sending a signal to the server that the command was successfull
}
Not sure though, as I've always used sscanf. I recommend you to start using it if you're learning anyways.
Reply
#5

Ah okay well i get these errors
Quote:

2793) : error 017: undefined symbol "isnull"
: error 001: expected token: ")", but found "return"

They are both on this line
Quote:

if(isnull(params[0]) return SendClientMessage(playerid,-1,"Usage: /play <url>");

Reply
#6

Код:
CMD:play(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid,-1,"Usage: /play <url>"); //If the player didn't type an url, send this message
    PlayAudioStreamForPlayer(playerid,params); //Play the audio stream
    return 1; //Sending a signal to the server that the command was successfull
}
He was missing a bracket, try that.
Reply
#7

Thanks man But it still says Undefined isnull.
I placed this at the top of my script
Quote:

#if !defined isnull
#define isnull(%1) \
((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif

It compiled but In game /stream does nothing at all :/
Reply
#8

what command processor are you using in your script?
Reply
#9

Make sure that you have the radio volume turned up in options - then try this code:

pawn Код:
#include <zcmd>

CMD:stream(playerid, params[])
{
    if (!isnull(params))
        return SendClientMessage(playerid, -1, "Usage: /stream <url>");

    return PlayAudioStreamForPlayer(playerid, params);
}
Reply
#10

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
Make sure that you have the radio volume turned up in options - then try this code:

pawn Код:
#include <zcmd>

CMD:stream(playerid, params[])
{
    if (!isnull(params))
        return SendClientMessage(playerid, -1, "Usage: /stream <url>");

    return PlayAudioStreamForPlayer(playerid, params);
}
It works mate!

Thankyou so much all who helped and tried! +rep all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)