Automatic Music Changer
#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


Messages In This Thread
Automatic Music Changer - by Dancsika - 22.03.2018, 19:15
Re: Automatic Music Changer - by BulletRaja - 22.03.2018, 20:35
Re: Automatic Music Changer - by Dancsika - 23.03.2018, 06:02
Re: Automatic Music Changer - by TadePoleMG - 08.05.2018, 08:14
Re: Automatic Music Changer - by Dancsika - 08.05.2018, 12:20
Re: Automatic Music Changer - by TadePoleMG - 08.05.2018, 13:19
Re: Automatic Music Changer - by TadePoleMG - 08.05.2018, 13:23
Re: Automatic Music Changer - by CrystalGamer - 08.05.2018, 15:34
Re: Automatic Music Changer - by TadePoleMG - 08.05.2018, 15:49
Re: Automatic Music Changer - by CrystalGamer - 08.05.2018, 15:52

Forum Jump:


Users browsing this thread: 1 Guest(s)