Can I use several songs?
#1

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");
Reply
#2

Help please.
Reply
#3

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.
cheers
Reply
#4

Quote:
Originally Posted by RayDcosta
Посмотреть сообщение
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.
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
	}
}
Reply
#5

Quote:
Originally Posted by Songason
Посмотреть сообщение
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.
Reply
#6

pawn Код:
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)