SA-MP Forums Archive
Playing audio stream,based on url user enters - 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: Playing audio stream,based on url user enters (/showthread.php?tid=473826)



Playing audio stream,based on url user enters - Tagathron - 04.11.2013

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.


Re: Playing audio stream,based on url user enters - Konstantinos - 04.11.2013

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



Re: Playing audio stream,based on url user enters - Tagathron - 04.11.2013

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.


Re: Playing audio stream,based on url user enters - Tagathron - 04.11.2013

Wait,now it shows the link,but it wont play.


Re: Playing audio stream,based on url user enters - RayDcosta - 04.11.2013

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


Re: Playing audio stream,based on url user enters - Tagathron - 04.11.2013

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.