SA-MP Forums Archive
Streaming from MP3 URL with command - 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: Streaming from MP3 URL with command (/showthread.php?tid=479874)



Streaming from MP3 URL with command - KingyKings - 07.12.2013

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


Re: Streaming from MP3 URL with command - Jstylezzz - 07.12.2013

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.


Re: Streaming from MP3 URL with command - KingyKings - 07.12.2013

What about if im not using sscanf and zcmd?


Re: Streaming from MP3 URL with command - Jstylezzz - 07.12.2013

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.


Re: Streaming from MP3 URL with command - KingyKings - 07.12.2013

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>");




Re: Streaming from MP3 URL with command - Mattakil - 07.12.2013

Код:
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.


Re: Streaming from MP3 URL with command - KingyKings - 07.12.2013

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 :/


Re: Streaming from MP3 URL with command - Mattakil - 07.12.2013

what command processor are you using in your script?


Re: Streaming from MP3 URL with command - Emmet_ - 07.12.2013

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);
}



Re: Streaming from MP3 URL with command - KingyKings - 07.12.2013

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