Playing audio stream,based on url user enters
#1

How could this be made?
I tried to make something myself,but it doesn't work,it prints something like playing audio stream and it doesn't put the whole link.Just about half of it.
And it doesn't play anything too.
This is my code
Код:
CMD:deployradio (playerid, params[])
{
	new Float:X;
	new Float:Y;
	new Float:Z;
	GetPlayerPos(playerid, X, Y, Z);
	new songUrl[128];

	if (PRinfo[playerid][radioDeployed]==1)
	{
		SendClientMessage(playerid, 0xF0A20FFF, "Your radio is already deployed.");
	}
	else
	{
		new PName[MAX_PLAYER_NAME];
		new string[40];

		if(sscanf(params, "s", songUrl)) return SendClientMessage(playerid, 0xCFF0FFCF, "USAGE: /deployradio [SONG URL]");
		GetPlayerPos(playerid, X, Y, Z);
		PRinfo[playerid][radioDeployed]=1;
		SendClientMessage(playerid, 0xFFE2E817, "You have deployed your radio at your current position.");
		PRinfo[playerid][locX]=X+2;
		PRinfo[playerid][locY]=Y;
		PRinfo[playerid][locZ]=Z;
		GetPlayerName(playerid, PName, sizeof(PName));
		format(string, sizeof(string), "%s's radio is here", PName);
		radioDeployedLabel[playerid] = Create3DTextLabel(string, 0xFFF900FF, PRinfo[playerid][locX], PRinfo[playerid][locY], PRinfo[playerid][locZ], 35.0, 0, 0);
		radioObject[playerid] = CreateObject(2103, PRinfo[playerid][locX], PRinfo[playerid][locY], PRinfo[playerid][locZ]-1, 0.0, 0.0, 0.0);
		PlayAudioStreamForPlayer(playerid, songUrl, PRinfo[playerid][locX], PRinfo[playerid][locY], PRinfo[playerid][locZ], 20.0, 1);
		playerListeningRadio[playerid]=1;
		for (new i = 0;i<MAX_PLAYERS;i++)
		{
		    if (IsPlayerInRangeOfPoint(i, 10.0, PRinfo[playerid][locX], PRinfo[playerid][locY], PRinfo[playerid][locZ]) && i != playerid)
		    {
		        playerListeningRadio[i]=1;
		        PlayAudioStreamForPlayer(i, "http://mp3rehab.com/user_uploads_10813-12345/C.C.Catch%20-%20Backseat%20Of%20Your%20Cadillac.mp3", PRinfo[playerid][locX], PRinfo[playerid][locY], PRinfo[playerid][locZ], 10.0, 1);
		    }
		}
	}
	return 1;
}
Just ignore the rest of the code,it works fine,it's just a part of the command-the thing i'm trying to do.
It works when i put the link in the script,but i want it dynamic.
Reply
#2

pawn Код:
if(sscanf(params, "s", songUrl)) return SendClientMessage(playerid, 0xCFF0FFCF, "USAGE: /deployradio [SONG URL]");
When you don't specify the size of the string, it's by default 32 (which cannot store the whole url a player inputs). Change to:
pawn Код:
if(sscanf(params, "s[128]", songUrl)) return SendClientMessage(playerid, 0xCFF0FFCF, "USAGE: /deployradio [SONG URL]");
Reply
#3

Alright i'll try that when i can.
I thought it was that,as it didn't put the whole link,just a part of it.
Thanks.
Reply
#4

Wait,now it shows the link,but it wont play.
Reply
#5

try getting in a vehicle before typing the command. works in most cases
Reply
#6

Quote:
Originally Posted by RayDcosta
Посмотреть сообщение
try getting in a vehicle before typing the command. works in most cases
Actually it plays a link i got from SA-MP wiki,not sure why not this one.
By the way,why would i be getting in a vehicle?
I didn't script this for vehicles,it's just a radio.
Out of vehicle radio.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)