Audio Help. - 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: Audio Help. (
/showthread.php?tid=368043)
Audio Help. -
nogh445 - 12.08.2012
This is the code And I get no errors but it doesn't play the URL I put in. The URL is a .mp3 url
pawn Код:
CMD:music(playerid, params[])
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_RED, "You cannot use this command");
return 1;
}
else
{
new string[128];
if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /music [url]");
if(!strcmp(params, "stop", true, 4))
{
StopAudioStreamForPlayer(playerid);
SendClientMessage(playerid, COLOR_RED, " You have stopped listening to music.");
return 1;
}
format(string, sizeof(string), "An Admin Has Started A Song. Use '/music stop' to stop the song");
SendClientMessageToAll(COLOR_ORANGE, string);
foreach(Player, i)
{
PlayAudioStreamForPlayer(i, params);
}
}
return 1;
}
Re: Audio Help. -
Kindred - 12.08.2012
pawn Код:
if(sscanf(params, "s[256]", params))
^ Is that even possible? Isn't it like this?:
if(sscanf(stringtolookin, placeholders, variables to use))?
So I created a variable named url, and used it in place of params.
Try this:
pawn Код:
CMD:music(playerid, params[])
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_RED, "You cannot use this command");
return 1;
}
else
{
new string[128], url[128];
if(sscanf(params, "s[256]", url)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /music [url]");
if(!strcmp(url, "stop", true, 4))
{
StopAudioStreamForPlayer(playerid);
SendClientMessage(playerid, COLOR_RED, " You have stopped listening to music.");
return 1;
}
format(string, sizeof(string), "An Admin Has Started A Song. Use '/music stop' to stop the song");
SendClientMessageToAll(COLOR_ORANGE, string);
foreach(Player, i)
{
PlayAudioStreamForPlayer(i, url);
}
}
return 1;
}
Re: Audio Help. -
nogh445 - 12.08.2012
Quote:
Originally Posted by Kindred
pawn Код:
if(sscanf(params, "s[256]", params))
^ Is that even possible? Isn't it like this?:
if(sscanf(stringtolookin, placeholders, variables to use))?
So I created a variable named url, and used it in place of params.
Try this:
pawn Код:
CMD:music(playerid, params[]) { if(!IsPlayerAdmin(playerid)) { SendClientMessage(playerid, COLOR_RED, "You cannot use this command"); return 1; } else { new string[128], url[128]; if(sscanf(params, "s[256]", url)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /music [url]"); if(!strcmp(url, "stop", true, 4)) { StopAudioStreamForPlayer(playerid); SendClientMessage(playerid, COLOR_RED, " You have stopped listening to music."); return 1; }
format(string, sizeof(string), "An Admin Has Started A Song. Use '/music stop' to stop the song"); SendClientMessageToAll(COLOR_ORANGE, string); foreach(Player, i) { PlayAudioStreamForPlayer(i, url); } } return 1; }
|
:\ That didn't work. I don't get errors but it doesn't work IG
Re: Audio Help. -
Kindred - 12.08.2012
In my opinion, everything looks like it would work, your code & my code.
Mind showing the link, just so I can validate it? I could care less.
Re: Audio Help. -
nogh445 - 12.08.2012
Link of the song?
Re: Audio Help. -
Kindred - 12.08.2012
The reason is highlighted in red.
This is because you use them for placeholders and shit, such as %s for specific string variable, %i for an integer variable, and so forth.
Simply try to get a new link, or upload the song to a seperate website without the %'s.
Re: Audio Help. -
nogh445 - 12.08.2012
Ah ha! Thanks soo much!