Automatic Music Changer
#1

Hi guys,
I wanna add an automatic music changer to my server but i dont know how to make it.
I want it to change randomly between different musics.
I'm not so good at pawno so i cant wirte the codes by my own.
Could you help me with it please?
Thank you so much.
Reply
#2

PHP код:
new Songs[][] = 
    {
        
"Song1 link",
        
"Song2 link",
        
"Song3 link",
        
"Song4 link"
    
};
//OnGameModeInit
SetTimer("AutoSong"60000true);
forward AutoSong();
public 
AutoSong()
{
    new 
autosrandom(sizeof(Songs));
        for(new 
i;i<MAX_PLAYERS;i++)  PlayAudioStreamForPlayer(iSongs[autos]);

i hope this will work
Reply
#3

Thank you so much
Reply
#4

Hi

PHP код:
// Server Auto Song Change System
//----Includes-----
#include <a_samp>
#include <zcmd>
#include <sscanf2>
//-----------------
//-----------------------------Defines----------------------------
#define                   GREEN                         0x33AA33AA
#define                   RED                           0xFF0000AA
#define SCM SendClientMessage
#define SCMTA SendClientMessageToAll
//----------------------------------------------------------------
new SongsList[][][] = {
        
"Song 1 Link, Music Name",
        
"Song 2 Link, Music Name",
        
"Song 3 Link, Music Name",
        
"Song 4 Link, Music Name",
        
"Song 5 Link, Music Name",
        
"Song 6 Link, Music Name",
        
"Song 7 Link, Music Name",
        
"Song 8 Link, Music Name",
        
"Song 9 Link, Music Name",   
        
"Song 10 Link, Music Name"
};
//----------Forwards-----
forward AutoSongChange();
forward AutoSongChange2();
//-----------------------
// OnFilterScriptInit()
    
print("\n-----------------------------------------------");
    print(
"    Auto Song Changer By TadePoleMG - Loaded     ");
    print(
"-----------------------------------------------\n");
        
// Here we set the timer(repeat) for auto songs change
        
SetTimer("AutoSongChange"1000false);
    return 
1;
//----------------
// OnFilterScriptExit()
    
print("\n-----------------------------------------------");
    print(
"    Auto Song Changer By TadePoleMG - Unloaded   ");
    print(
"-----------------------------------------------\n");
        
KillTimer(AutoSongChange); // Here we kill that both timers
        
KillTimer(AutoSongChange2); 
    return 
1;
//----------------
// Here We Starting Timer function 
public AutoSongChange()
{
    new 
SelectAutoSong random(sizeof(SongsList)); // here we selecting random songs to play
    
    
for(new all;all<MAX_PLAYERS;all++)  
    {
    if(
IsPlayerConnected(all))
    {
    
PlayAudioStreamForPlayer(iSongsList[SelectAutoSong][0]);
    }
    }
    new 
string[128];
    
format(string,128,"Current playing Song - %s"SongsList[SelectAutoSong][1]);
    
SCMTA(GREENstring);
    
// Here we setting again timer of aabout time equal to audio stream time.
    
new Time random(2);
    switch(
Time)
    {
    case 
0:
    {
    
SetTimer("AutoSongChange2"180*1000false); // 3minutes, edit as your need
    
}
    case 
1:
    {
    
SetTimer("AutoSongChange2"240*1000false); // 4 minutes, edit as your need
    
}
    case 
2:
    {
    
SetTimer("AutoSongChange2"300*1000false); // 5 minutes, edit as your need
    
}
    }
    return 
1;
}  
public 
AutoSongChange2()
{
    new 
SelectAutoSong2 random(sizeof(SongsList)); // here we selecting random songs to play
    
    
for(new all;all<MAX_PLAYERS;all++)  
    {
    if(
IsPlayerConnected(all))
    {
    
PlayAudioStreamForPlayer(iSongsList[SelectAutoSong2][0]);
    }
    }
    new 
string[128];
    
format(string,128,"Current playing Song - %s"SongsList[SelectAutoSong2][1]);
    
SCMTA(GREENstring);
    new 
Time random(2);
    switch(
Time)
    {
    case 
0:
    {
    
SetTimer("AutoSongChange"180*1000false); // 3minutes, edit as your need
    
}
    case 
1:
    {
    
SetTimer("AutoSongChange"240*1000false); // 4 minutes, edit as your need
    
}
    case 
2:
    {
    
SetTimer("AutoSongChange"300*1000false); // 5 minutes, edit as your need
    
}
    }     
    return 
1;
}  
// You can also start stop by commands
CMD:startstream(playerid,params[])
{
    if(
IsPlayerAdmin(playerid))
    {
        new 
select;
        if(
sscanf(params,"s[200]"select)) return SCM(playeridred,"CmdUse: /startstream (0-10)") &&
        
SCM(playeridred,"CmdUse: will start songs, select song number.");
        if(
select || select 10) return SCM(playeridred,"Select from 0-10");
        for(new 
all;all<MAX_PLAYERS;all++)  
        {
        if(
IsPlayerConnected(all))
        {
        
PlayAudioStreamForPlayer(iSongsList[select]);
        
KillTimer(AutoSongChange); 
        
KillTimer(AutoSongChange2);
        }
        }
        new 
string[128];
        
format(string,128,"Admin started new song -  %s"SongsList[select][1]);
        
SCMTA(GREENstring);
    }
    else 
SCM(playeridred"You are not allowed to use this command.");
    return 
1;
}
CMD:stopstream(playerid,params[])
{
    if(
IsPlayerAdmin(playerid))
    {
       
#pragma unused params
       
KillTimer(AutoSongChange); 
       
KillTimer(AutoSongChange2); 
       new 
string[128];
       
format(string,128,"Current playing audio stream is stopped now");
       
SCM(playeridGREENstring);
    }
    else 
SCM(playeridred"You are not allowed to use this command.");
    return 
1;

I think it can work better from above.
Above can't know when the stream comes but it tries about that time (only seconds of diffrence).

Thank You, rep++-If I helped you.
Reply
#5

Ohh thank you It looks better but to be honest i'm good with the first one. I've just wanted to play music in every 10 mins. I use this for RP server so the songs are just soundtracks and they are not longer than 2 mins :'D But this is a really good tutorial for me. Now i can see that how is that working
Reply
#6

If it works good pm me
Reply
#7

Sorry it is my mistake, fixed
Reply
#8

well as you can see what he said he wants a automatic music changer
as BulletRaja(Banned) already gave him and by the way Dancsika also said that he liked that.
so better you guys dont comment on topics which already solved to increase your posts.
Read forum rules for more information.

have fun
SAMP:SAMP

Edit: also tadepole thats looking like you copied the filterscript and edited and shared here, as i see you always wanted to get player kills (Most kills round) even if you cant do that then how you can make fitlerscripts like this, so the comment from me is this is fully copied from another gamemode or filterscript, so please dont do that better you see forum rules copying is not allowed ok.


HAve Fun
SAMP:SAMP
Reply
#9

know and i'm not trying to increase my posts, I'm only trying to help others in all pssibel ways, Understand.
Reply
#10

Quote:
Originally Posted by TadePoleMG
Посмотреть сообщение
know and i'm not trying to increase my posts, I'm only trying to help others in all pssibel ways, Understand.
i see how you are doing that lol.
ok
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)