Hallo Community!
Ich habe mir ein Include runtergeladen für Youtube musik.
Aber das Problem ist einfach, sobald 1 User den Song hört kann ein anderer den nicht mehr aufrufen.
Ich möchte ja das es für alle ist.
//Include:
stock PlayYoutubeVideoForPlayer(playerid,url[])
{
if(strfind(url,"&") != -1) strmid(url,url,0,strfind(url,"&"),128);
format(g_link,sizeof(g_link),"%s",url);
format(url,128,"youtubeinmp3.com/fetch/?api=advanced&video=%s",g_link);
HTTP(playerid, HTTP_GET, url, "", "OnYoutubeResponse");
}
forward OnYoutubeResponse(playerid, response_code, data[]);
public OnYoutubeResponse(playerid, response_code, data[])
{
if(response_code == 200)
{
new content[3][256],stream[256],string[256];
new hours,minutes,seconds,tmp_seconds[8];
explode(content,data,"<br />");
strmid(tmp_seconds,content[1],8,strlen(content[1]));
strmid(stream,content[2],6,strlen(content[2]));
g_duration = strval(tmp_seconds);
g_title = content[0];
formatSeconds(g_duration,hours,minutes,seconds);
format(string,sizeof(string),"{0049FF}[Now playing] {00c9ff}%s (Duration: %02d:%02d:%02d)",GetVideoTitle(),hours,minutes,seconds);
SendClientMessage(playerid,-1,string);
PlayAudioStreamForPlayer(playerid,stream);
g_playing = true;
SetTimerEx("SongFinished",(g_duration+5)*1000,false,"i",playerid);
}
else
{
new error[128];
format(error,sizeof(error),"{0049FF}[ERROR] {00c9ff}An error has occured: %s (%d)",GetError(response_code),response_code);
SendClientMessage(playerid,0xFF0000FF,error);
}
}
//script teil:
ocmd:youtube(playerid,params[])
{
if (pInfo[playerid][a_score] < 2)return SendClientMessage(playerid,COLOR_RED,"ERROR: You are not a high enough level to use this command");
new link[128], pID;
if(sscanf(params,"us[128]",pID, link)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /youtube [playerid/name] [youtube-url]");
if(!IsPlayerConnected(pID))return SendClientMessage(playerid, COLOR_RED, "The Player is not online!");
if(strlen(link) >= 128) return SendClientMessage(playerid, COLOR_RED,"Link too long !");
PlayYoutubeVideoForPlayer(pID,link);
return 1;
}
ocmd:stopyoutube(playerid, params[])
{
if (pInfo[playerid][a_score] < 2)return SendClientMessage(playerid,COLOR_RED,"ERROR: You are not a high enough level to use this command");
new pID;
if(sscanf(params,"u",pID)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /stopyoutube [playerid/name]");
if(!IsPlayerConnected(pID))return SendClientMessage(playerid, COLOR_RED, "The Player is not online!");
StopYoutubeVideoForPlayer(pID);
return 1;
}
ocmd:youtubeforall(playerid,params[])
{
if (pInfo[playerid][a_score] < 2)return SendClientMessage(playerid,COLOR_RED,"ERROR: You are not a high enough level to use this command");
new link[128];
new string[128];
if(sscanf(params,"s[128]", link)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /youtubeforall [youtube-url]");
if(strlen(link) >= 128) return SendClientMessage(playerid, COLOR_RED,"Link too long !");
SendClientMessage(playerid, COLOR_BLUE, "If you want to hear the song, please enter /playmusic a.");
format(string, sizeof(string), "[Music]: %s (Duration: %s)", GetVideoTitle(), GetLengthOfVideo());
SendClientMessageToAll(COLOR_RED, string);
format(string, sizeof(string), "[Music]: Music link: %s", GetVideoLink());
SendClientMessageToAll(COLOR_RED, string);
strmid(song, link, 0, 128, 128); //hatte es jetzt mit variablen gemacht, eigentlich hatte ich vor das es direkt für alle läuft
return 1;
}
ocmd:stopyoutubeforall(playerid,params[])
{
if (pInfo[playerid][a_score] < 2)return SendClientMessage(playerid,COLOR_RED,"ERROR: You are not a high enough level to use this command");
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(playerid))continue;
StopYoutubeVideoForPlayer(i);
}
return 1;
}
ocmd:playmusic(playerid, params[])
{
if (strlen(song) < 1)return SendClientMessage(playerid, COLOR_RED, "There is no music on run.");
PlayYoutubeVideoForPlayer(playerid,song);
return 1;
}