Music when joining/registering to the server
#1

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
Reply
#2

OnConnect
PlayAudioStreamForPlayer(playerid, ...)

OnPlayerRequestSpawn
StopAudioStreamForPlayer(playerid)
Reply
#3

Quote:
Quote:
Originally Posted by Jamester
Посмотреть сообщение
OnConnect
PlayAudioStreamForPlayer(playerid, ...)

OnPlayerRequestSpawn
StopAudioStreamForPlayer(playerid)
Need a whole code that i can add in the script.
Reply
#4

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
Reply
#5

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

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(playeridsoundidFloat:xFloat:yFloat: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(playeridsoundid+1Float:xFloat:yFloat: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
Reply
#7

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 
04++)
    {
        
DriveThruItems[playerid][i] = 0;
    }
    if(
Security != 0)
    { 
Reply
#8

Quote:
Originally Posted by tomacraft2011
Посмотреть сообщение
Here is what i have, tried add but it did not work

PHP код:
}
public 
OnPlayerConnect(playerid)
{
    for (new 
04++)
    {
        
DriveThruItems[playerid][i] = 0;
    }
    if(
Security != 0)
    { 
It should work.

PHP код:
public OnPlayerConnect(playerid

    
PlayAudioStreamForPlayer(playerid"direct link to your mp3");
    for (new 
04++) 
    { 
        
DriveThruItems[playerid][i] = 0
    } 
    if(
Security != 0
    { 
Reply
#9

Quote:
Originally Posted by Mokless
Посмотреть сообщение
It should work.

PHP код:
public OnPlayerConnect(playerid

    
PlayAudioStreamForPlayer(playerid"direct link to your mp3");
    for (new 
04++) 
    { 
        
DriveThruItems[playerid][i] = 0
    } 
    if(
Security != 0
    { 
Will the music stop when they enter the game?
Reply
#10

PHP код:
public OnPlayerSpawn(playerid)
{
    
StopAudioStreamForPlayer(playerid);  
    return 
1;

This will stop it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)