PDA

View Full Version : Can I use several songs?


Songason
30/10/2013, 11:18 PM
So on public OnPlayerConnect(playerid) I have that a song plays till you clicked spawn.

Can I set different songs so it's like a different song everytime you relog?

Code currently:
public OnPlayerConnect(playerid)
{
for (new i = 0; i < 4; i ++)
{
DriveThruItems[playerid][i] = 0;
}
if(Security != 0)
{
SendClientMessage(playerid, COLOR_YELLOW, "Host has broken one of the Agreement rules, action has been taken.");
Kick(playerid);
return 1;
}
gPlayerLoggin{playerid} = 1;
TextDrawShowForPlayer(playerid, Website);
gPlayerAnimLibsPreloaded[playerid] = 0;
gActivePlayers[playerid]++;
ShowArea(playerid);
numplayers++;
Spawned[playerid] = 0;
BusID[playerid] = 0;
BusCost[playerid] = 0;
PlayerSitting[playerid] = 0;
PlayAudioStreamForPlayer(playerid,"not necessary atm for you guys ;p");

Songason
30/10/2013, 11:50 PM
Help please.

RayDcosta
31/10/2013, 06:31 AM
u can do something like using a random number.
it cant ensure u listen to a different song every time, but most of the times the user will hear a different song.
make a switch case.
with numbers from 1 to x (x is the total number of songs u have)
so assuming its 1 to 10
make a random number chooser like rand(1,x+1) [remember to put x+1 cause then it will choose a random number from 1 to x]
after that, make switch cases from 1 to x like i said and have this random number chooser right above that.
so every time the user logs in, it chooses like a random number from 1 to x.
and then based on that a song is selected and played. hope i helped u.
:D cheers

Songason
31/10/2013, 09:20 AM
u can do something like using a random number.
it cant ensure u listen to a different song every time, but most of the times the user will hear a different song.
make a switch case.
with numbers from 1 to x (x is the total number of songs u have)
so assuming its 1 to 10
make a random number chooser like rand(1,x+1) [remember to put x+1 cause then it will choose a random number from 1 to x]
after that, make switch cases from 1 to x like i said and have this random number chooser right above that.
so every time the user logs in, it chooses like a random number from 1 to x.
and then based on that a song is selected and played. hope i helped u.
:D cheers

Alright, but where should I put the ehhh rand[1,x+1). My code for example:

new
a = 5;
switch (a)
{
case 1:
{
song
}
case 2:
{
song
}
case 5:
{
song
}
default:
{
song
}
}

Elorreli
31/10/2013, 10:29 AM
Alright, but where should I put the ehhh rand[1,x+1). My code for example:

new
a = 5;
switch (a)
{
case 1:
{
song
}
case 2:
{
song
}
case 5:
{
song
}
default:
{
song
}
}

new a = random(5);

Starts with ID 0 tho, could always +1.

BigETI
31/10/2013, 11:55 AM
static const music_arr[][] =
{
"Link 1st",
"Link 2nd",
"Link 3rd",
// ...
"Link nth"
}; // An array

public OnPlayerConnect(playerid)
{
// Your code...
PlayAudioStreamForPlayer(playerid, music_arr[random(sizeof music_arr)]);
return 1;
}

nuff' said.