Music when joining/registering to the server -
tomacraft2011 - 31.01.2017
Can anyone help me. I want to be aveble to put a music url in my script so when people join they will hear a song. intill they press spawn
Re: Music when joining/registering to the server -
J0sh... - 31.01.2017
OnConnect
PlayAudioStreamForPlayer(playerid, ...)
OnPlayerRequestSpawn
StopAudioStreamForPlayer(playerid)
Re: Music when joining/registering to the server -
tomacraft2011 - 31.01.2017
Quote:
Quote:
Originally Posted by Jamester
OnConnect
PlayAudioStreamForPlayer(playerid, ...)
OnPlayerRequestSpawn
StopAudioStreamForPlayer(playerid)
|
|
Need a whole code that i can add in the script.
Re: Music when joining/registering to the server -
J0sh... - 31.01.2017
This is not a do it for you section, I told you how to do it.
https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer
https://sampwiki.blast.hk/wiki/StopAudioStreamForPlayer
https://sampwiki.blast.hk/wiki/OnPlayerConnect
https://sampwiki.blast.hk/wiki/OnPlayerRequestSpawn
Re: Music when joining/registering to the server -
Mokless - 01.02.2017
Search for the "public OnPlayerConnect(playerid)" callback on your script, under that add following code:
Код:
PlayAudioStreamForPlayer(playerid, "direct link to your mp3");
Then under "public OnPlayerRequestSpawn(playerid)" callback, add the following code. This will stop the above music once player is spawned.
Код:
StopAudioStreamForPlayer(playerid);
Re: Music when joining/registering to the server -
Eoussama - 01.02.2017
If you want to play a song you found online for players when they join, then use
PHP код:
PlayAudioStreamForPlayer(playerid, "Song Link");
You can stop that song when they spawn or when they switch to a different class
PHP код:
StopAudioStreamForPlayer(playerid);
This is not the only choice, The game has already few songs that you can use without the need to any external links, to use that, when players join, add
PHP код:
PlayerPlaySound(playerid, soundid, Float:x, Float:y, Float:z); //Just leave the Float parameters put to 0 if you want the song to be heard from any distance, which is what we want in this case, as for the sound ID, there are few that you can use, e.g 1062, 1068 ...etc
To stop the song, use
PHP код:
PlayerPlaySound(playerid, soundid+1, Float:x, Float:y, Float:z); //Why we used soundid+1? Well, because, if we played the sound id 1062, to stop it, we have to play sound id 1063, the same goes for other sound ids
Here is a list of useful sound ids
Код:
SOUND_GOGO_TRACK_START 1062 (music) //This plays soundid = 1062
SOUND_GOGO_TRACK_STOP 1063 (music) //This stops soundid = 1062
SOUND_DUAL_TRACK_START 1068 (music) //This plays soundid = 1098
SOUND_DUAL_TRACK_STOP 1069 (music) //This stops soundid = 1098
SOUND_BEE_TRACK_START 1076 (music) //This plays soundid = 1076
SOUND_BEE_TRACK_STOP 1077 (music) //This stops soundid = 7076
SOUND_AWARD_TRACK_START 1097 (music) //This plays soundid = 1097
SOUND_AWARD_TRACK_STOP 1098 (music) //This stops soundid = 1098
Source:
https://sampwiki.blast.hk/wiki/SoundID
Re: Music when joining/registering to the server -
tomacraft2011 - 01.02.2017
Quote:
Originally Posted by Mokless
Search for the "public OnPlayerConnect(playerid)" callback on your script, under that add following code:
Код:
PlayAudioStreamForPlayer(playerid, "direct link to your mp3");
Then under "public OnPlayerRequestSpawn(playerid)" callback, add the following code. This will stop the above music once player is spawned.
Код:
StopAudioStreamForPlayer(playerid);
|
Here is what i have, tried add but it did not work
PHP код:
}
public OnPlayerConnect(playerid)
{
for (new i = 0; i < 4; i ++)
{
DriveThruItems[playerid][i] = 0;
}
if(Security != 0)
{
Re: Music when joining/registering to the server -
Mokless - 01.02.2017
Quote:
Originally Posted by tomacraft2011
Here is what i have, tried add but it did not work
PHP код:
}
public OnPlayerConnect(playerid)
{
for (new i = 0; i < 4; i ++)
{
DriveThruItems[playerid][i] = 0;
}
if(Security != 0)
{
|
It should work.
PHP код:
public OnPlayerConnect(playerid)
{
PlayAudioStreamForPlayer(playerid, "direct link to your mp3");
for (new i = 0; i < 4; i ++)
{
DriveThruItems[playerid][i] = 0;
}
if(Security != 0)
{
Re: Music when joining/registering to the server -
tomacraft2011 - 01.02.2017
Quote:
Originally Posted by Mokless
It should work.
PHP код:
public OnPlayerConnect(playerid)
{
PlayAudioStreamForPlayer(playerid, "direct link to your mp3");
for (new i = 0; i < 4; i ++)
{
DriveThruItems[playerid][i] = 0;
}
if(Security != 0)
{
|
Will the music stop when they enter the game?
Re: Music when joining/registering to the server -
AndreiWow - 01.02.2017
PHP код:
public OnPlayerSpawn(playerid)
{
StopAudioStreamForPlayer(playerid);
return 1;
}
This will stop it.