Array/enum help
#1

I have been working on a random radio function and i had it working good then i decided to add names to an array, like this....
pawn Код:
enum randomMusicA
{
    MusicName,
    Url,
}
new randomMusic[MAX_MUSIC_STREAMS][randomMusicA] ={
{"Country","http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283687"},//line 32 error
{"Sky.FM","http://yp.shoutcast.com/sbin/tunein-station.pls?id=728272"},
{"Big R Radio","http://74.86.186.35:8018/listen.pls"},
{"Slow Music","http://yp.shoutcast.com/sbin/tunein-station.pls?id=1658657"}
};
stock NMusicStream(playerid)
{
    StopAudioStreamForPlayer(playerid);
    new randomRadio = random(sizeof(randomMusic)randomMusic[MusicName][Url]);//line 40 error
    PlayAudioStreamForPlayer(playerid, randomMusic[Url]);
    SendClientMessage(playerid, -1, "Next Song/Radio Loading........");
    SendClientMessage(playerid, -1, "Listening to "randomMusic[MusicName]"");
    return 1;
}
stock ANMusicStream(playerid)
{
    StopAudioStreamForPlayer(playerid);
    new randomRadio = random(sizeof(randomMusic)randomMusic[MusicName][Url]);
    PlayAudioStreamForPlayer(playerid, randomMusic[Url]);
    SendClientMessage(playerid, -1, "Listening to "randomMusic[MusicName]"");
}
I get a bunch of errors too ...
Код:
C:\Program Files (x86)\Rockstar Games\samp\gamemodes\stuntfreeroam.pwn(32) : warning 228: length of initialler exceeds size of the enum field
C:\Program Files (x86)\Rockstar Games\samp\gamemodes\stuntfreeroam.pwn(32) : warning 228: length of initialler exceeds size of the enum field
C:\Program Files (x86)\Rockstar Games\samp\gamemodes\stuntfreeroam.pwn(32) : error 018: initialization data exceeds declared size
C:\Program Files (x86)\Rockstar Games\samp\gamemodes\stuntfreeroam.pwn(40) : error 001: expected token: ",", but found "-identifier-"
C:\Program Files (x86)\Rockstar Games\samp\gamemodes\stuntfreeroam(40) : warning 215: expression has no effect
C:\Program Files (x86)\Rockstar Games\samp\gamemodes\stuntfreeroam(40) : error 001: expected token: ";", but found ")"
C:\Program Files (x86)\Rockstar Games\samp\gamemodes\stuntfreeroam(40) : error 029: invalid expression, assumed zero
C:\Program Files (x86)\Rockstar Games\samp\gamemodes\stuntfreeroam(40) : fatal error 107: too many error messages on one line
Guess My first question is, am i doing this somewhat right? I had it working great without the enum and the stream names. Anyone know what i am doing wrong?
Reply
#2

pawn Код:
enum randomMusicA
{
    MusicName[50],
    Url[256],
}
new randomMusic[MAX_MUSIC_STREAMS][randomMusicA] ={
{"Country","http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283687"},
{"Sky.FM","http://yp.shoutcast.com/sbin/tunein-station.pls?id=728272"},
{"Big R Radio","http://74.86.186.35:8018/listen.pls"},
{"Slow Music","http://yp.shoutcast.com/sbin/tunein-station.pls?id=1658657"}
};
stock NMusicStream(playerid)
{
    StopAudioStreamForPlayer(playerid);
    new string[128], randomRadio = random(sizeof(randomMusic));
    PlayAudioStreamForPlayer(playerid, randomMusic[randomRadio][Url]);
    SendClientMessage(playerid, -1, "Next Song/Radio Loading........");
    format(string, sizeof(string), "Listening to %s", randomMusic[randomRadio][MusicName]);
    SendClientMessage(playerid, -1, string);
    return 1;
}
stock ANMusicStream(playerid)
{
    StopAudioStreamForPlayer(playerid);
    new string[128], randomRadio = random(sizeof(randomMusic));
    PlayAudioStreamForPlayer(playerid, randomMusic[randomRadio][Url]);
    format(string, sizeof(string), "Listening to %s", randomMusic[randomRadio][MusicName]);
    SendClientMessage(playerid, -1, string);
}
Reply
#3

this is all i could come up with

Код:
stock NMusicStream(playerid)
{
    StopAudioStreamForPlayer(playerid);
	SendClientMessage(playerid, 0xB4B5B7FF, "Next Song/Radio Loading........");
    new randomRadio = random(sizeof(randomMusic)randomMusic[MusicName][Url]);//line 40 error	
	new rand = random(3);
	  switch(rand)
	  {
		case 0: 
		{
			PlayAudioStreamForPlayer(playerid, http://yp.shoutcast.com/sbin/tunein-stat...2.28474292			SendClientMessage(playerid, 0xB4B5B7FF, "Country");
		}
		case 1:
		{
			PlayAudioStreamForPlayer(playerid, http://yp.shoutcast.com/sbin/tunein-stat...2.28474292			SendClientMessage(playerid, 0xB4B5B7FF, "Sky.FM");
		}
		case 2:
		{
			PlayAudioStreamForPlayer(playerid, http://74.86.186.35:8018/listen.pls);nl6...2.28474292			SendClientMessage(playerid, 0xB4B5B7FF, "Big R Radio");
		}
		case 3:
		{
			PlayAudioStreamForPlayer(playerid, http://yp.shoutcast.com/sbin/tunein-stat...2.28474292			SendClientMessage(playerid, 0xB4B5B7FF, "Slow Music");
		}
	}
return 1;
}
stock ANMusicStream(playerid)
{
	StopAudioStreamForPlayer(playerid);
    new randomRadio = random(sizeof(randomMusic)randomMusic[MusicName][Url]);
	new rand = random(3);
	  switch(rand)
	  {
		case 0: 
		{
			PlayAudioStreamForPlayer(playerid, http://yp.shoutcast.com/sbin/tunein-stat...2.28474292			SendClientMessage(playerid, 0xB4B5B7FF, "Country");
		}
		case 1:
		{
			PlayAudioStreamForPlayer(playerid, http://yp.shoutcast.com/sbin/tunein-stat...2.28474292			SendClientMessage(playerid, 0xB4B5B7FF, "Sky.FM");
		}
		case 2:
		{
			PlayAudioStreamForPlayer(playerid, http://74.86.186.35:8018/listen.pls);nl6...2.28474292			SendClientMessage(playerid, 0xB4B5B7FF, "Big R Radio");
		}
		case 3:
		{
			PlayAudioStreamForPlayer(playerid, http://yp.shoutcast.com/sbin/tunein-stat...2.28474292			SendClientMessage(playerid, 0xB4B5B7FF, "Slow Music");
		}
	}
return 1;
}
it will work
Reply
#4

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
pawn Код:
enum randomMusicA
{
    MusicName[50],
    Url[256],
}
new randomMusic[MAX_MUSIC_STREAMS][randomMusicA] ={
{"Country","http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283687"},
{"Sky.FM","http://yp.shoutcast.com/sbin/tunein-station.pls?id=728272"},
{"Big R Radio","http://74.86.186.35:8018/listen.pls"},
{"Slow Music","http://yp.shoutcast.com/sbin/tunein-station.pls?id=1658657"}
};
stock NMusicStream(playerid)
{
    StopAudioStreamForPlayer(playerid);
    new string[128], randomRadio = random(sizeof(randomMusic));
    PlayAudioStreamForPlayer(playerid, randomMusic[randomRadio][Url]);
    SendClientMessage(playerid, -1, "Next Song/Radio Loading........");
    format(string, sizeof(string), "Listening to %s", randomMusic[randomRadio][MusicName]);
    SendClientMessage(playerid, -1, string);
    return 1;
}
stock ANMusicStream(playerid)
{
    StopAudioStreamForPlayer(playerid);
    new string[128], randomRadio = random(sizeof(randomMusic));
    PlayAudioStreamForPlayer(playerid, randomMusic[randomRadio][Url]);
    format(string, sizeof(string), "Listening to %s", randomMusic[randomRadio][MusicName]);
    SendClientMessage(playerid, -1, string);
}
Ok it works good but for some reason it only plays the same stream and the song name changes. I also had to change it up with the line...
pawn Код:
new string[128], randomRadio = random(sizeof(randomMusic));
//to
new string[128];
new randomRadio = random(sizeof(randomMusic));
Cause it was giving errors. Other than that it is the same. Any suggestions on that?
Reply
#5

if it isnt working just use mine
Reply
#6

Quote:
Originally Posted by Marco_Valentine
Посмотреть сообщение
if it isnt working just use mine
Would rather use the array one cause i eventually want to make it read out of a file and its easyer to add 1 line.
Reply
#7

pawn Код:
enum randomMusicA
{
    MusicName[50],
    Url[256],
}
new randomMusic[MAX_MUSIC_STREAMS][randomMusicA] ={
{"Country","http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283687"},
{"Sky.FM","http://yp.shoutcast.com/sbin/tunein-station.pls?id=728272"},
{"Big R Radio","http://74.86.186.35:8018/listen.pls"},
{"Slow Music","http://yp.shoutcast.com/sbin/tunein-station.pls?id=1658657"}
};
stock NMusicStream(playerid)
{
    StopAudioStreamForPlayer(playerid);
    new string[128], randomRadio = random(sizeof(randomMusic));
    PlayAudioStreamForPlayer(playerid, randomMusic[randomRadio][2]);
    SendClientMessage(playerid, -1, "Next Song/Radio Loading........");
    format(string, sizeof(string), "Listening to %s", randomMusic[randomRadio][1]);
    SendClientMessage(playerid, -1, string);
    return 1;
}
stock ANMusicStream(playerid)
{
    StopAudioStreamForPlayer(playerid);
    new string[128], randomRadio = random(sizeof(randomMusic));


    PlayAudioStreamForPlayer(playerid, randomMusic[randomRadio][2]);
    format(string, sizeof(string), "Listening to %s", randomMusic[randomRadio][1]);
    SendClientMessage(playerid, -1, string);
}
try that then
Reply
#8

Well the problem was cause of my error....imagine that lol
pawn Код:
StopAudioStreamForPlayer(playerid);
    new string[128];
    new randomRadio = random(sizeof(randomMusic));
    PlayAudioStreamForPlayer(playerid, randomMusic[randomRadio][Url]);
    SendClientMessage(playerid, -1, "Next Song/Radio Loading........");
    format(string, sizeof(string), "Listening to %s", randomMusic[randomRadio][MusicName]);
    SendClientMessage(playerid, -1, string);
that is the final code, but this line was the one at fault.
pawn Код:
PlayAudioStreamForPlayer(playerid, randomMusic[randomRadio][Url]);
//i had it this way
PlayAudioStreamForPlayer(playerid, randomMusic[randomRadio][MusicName][Url]);
I guess having the MusicName in that part makes it pick a different url. I thought you needed the MusicName enum to get to the Url enum if you know what i mean. Thanks for the help you two, i really appreciated
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)