Posts: 168
Threads: 115
Joined: Jul 2010
Reputation:
0
Hi can anyone help me with adding random music on player spawn
like playaudiostreamforplayer?
Posts: 256
Threads: 1
Joined: Aug 2014
Reputation:
0
Make an array of audio streams, use the random function to generate a number between 0 and MAX_AUDIO_STREAMS, where MAX_AUDIO_STREAMS is the number of audio streams that you included in your array and use PlayAudioStreamForPlayer(playerid, AudioStreamsArray[random_variable]);
That is the main idea, you should be able to develop it.
Posts: 168
Threads: 115
Joined: Jul 2010
Reputation:
0
I have this code_
stock RandomMusic(playerid)
{
new rand = random(5);
switch(rand)
{
case 0:
{
PlayAudioStreamForPlayer(playerid, "http://mp3.shmidt.net/files/from_flash/2156/f8d0b9b35fccc03a31d990b62940b9e448febe9db1a41661ce/Nelly_-_Here_Comes_The_Boom.mp3");
}
case 1:
{
PlayAudioStreamForPlayer(playerid, "http://raddad.free.fr/musiquepuce///'Til I collapse.mp3");
}
case 2:
{
PlayAudioStreamForPlayer(playerid, "http://a.tumblr.com/tumblr_lpb606uHE91qhb27eo1.mp3");
}
case 3:
{
PlayAudioStreamForPlayer(playerid, "http://a.tumblr.com/tumblr_m0uvryGX7P1r60k0fo1.mp3");
}
case 4:
{
PlayAudioStreamForPlayer(playerid, "http://mp3ska4ka.ru/audio/107519246/54624629/Roy_Jones_Jr-Go_Hard_Or_Go_Home.mp3");
}
}
}
return 1;
}
public OnPlayerSpawn...
{
RandomMusic(playerid);
but this error:
C:\Users\z\Desktop\zv.pwn(1850) : error 017: undefined symbol "RandomMusic"
1850 : RandomMusic(playerid);
Posts: 256
Threads: 1
Joined: Aug 2014
Reputation:
0
Remove one of the 3 closing curly brackets '}' between case 4 and return 1, there should be 2 instead of 3.
This is what bad coding style (indentation) leads to, people. Always indent your code!
Posts: 168
Threads: 115
Joined: Jul 2010
Reputation:
0
I have make to:
case 0:
{
PlayAudioStreamForPlayer(playerid, "http://mp3.shmidt.net/files/from_flash/2156/f8d0b9b35fccc03a31d990b62940b9e448febe9db1a41661ce/Nelly_-_Here_Comes_The_Boom.mp3");
}
case 1:
{
PlayAudioStreamForPlayer(playerid, "http://raddad.free.fr/musiquepuce///'Til I collapse.mp3");
}
case 2:
{
PlayAudioStreamForPlayer(playerid, "http://a.tumblr.com/tumblr_lpb606uHE91qhb27eo1.mp3");
}
case 3:
{
PlayAudioStreamForPlayer(playerid, "http://a.tumblr.com/tumblr_m0uvryGX7P1r60k0fo1.mp3");
}
case 4:
{
PlayAudioStreamForPlayer(playerid, "http://mp3ska4ka.ru/audio/107519246/54624629/Roy_Jones_Jr-Go_Hard_Or_Go_Home.mp3");
}
return 1;
}
compiler complete,but server not on
Posts: 256
Threads: 1
Joined: Aug 2014
Reputation:
0
You have to be more specific. Provide some errors, or server_log if the compiler doesn't give anything but the server doesn't start up.
Posts: 168
Threads: 115
Joined: Jul 2010
Reputation:
0
not errors
I complete compiler
but I start server up,but server not start up