Raised This Month: $ Target: $400
 0% 

Plugin_handled & main


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Baws
Veteran Member
Join Date: Oct 2012
Old 03-03-2014 , 14:00   Re: Plugin_handled & main
Reply With Quote #8

So what i used up there is good right? OR this is better?

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < colorchat >
 
#define b_PLUGIN  "Advanced Music Player"
#define b_VERSION "1.4"
#define b_AUTHOR  "Baws"

#define MAX_SONGS 5000

new bSongId;
new 
bLastSongbSongCount;

new 
bMusicPlayer1536 ];
new 
b_Song_NamesMAX_SONGS ][ 64 ];
new 
b_Song_LinksMAX_SONGS ][ 512 ];
new 
bLastMusic33 ];

public 
plugin_init( )
{
        
register_pluginb_PLUGINb_VERSIONb_AUTHOR );
        
register_cvarb_PLUGINb_VERSIONFCVAR_SERVER FCVAR_EXTDLL FCVAR_UNLOGGED FCVAR_SPONLY );
       
        
register_clcmd"say""Cmd_Say" );
        
register_clcmd"say_team""Cmd_Say" );
    
        
register_concmd"amx_addsong""b_AddSong"ADMIN_CFG"- Usage: <song name> <song url/link> | Attention: Instead of < > use quotes." );
        
register_concmd"amx_reloadsong""b_ReloadSongList"ADMIN_CFG"- Reload's the songlist.ini file." );
       
        
bInitialize( );
}

public 
client_putinserverid )
        
bLastMusicid ] = 0;

public 
b_AddSongidlevelcid )
{
        if( !
cmd_accessidlevelcid) )
                return 
PLUGIN_HANDLED;
    
        new 
bSongName33 ], bSongLink256 ]
        
read_argv1bSongNamecharsmaxbSongName ) )
        
read_argv2bSongLinkcharsmaxbSongLink ) )
    
        
copyb_Song_NamesbSongId ], charsmaxb_Song_Names[ ] ), bSongName )
        
copyb_Song_LinksbSongId++ ], charsmaxb_Song_Links[ ] ), bSongLink )
    
        new 
bConfigDir128 ], bFile128 ]
        
get_localinfo"amxx_configsdir"bConfigDircharsmaxbConfigDir ) )
    
        
formatexbFilecharsmaxbFile ), "%s/%s"bConfigDir"songlist.ini" )
        if( 
file_existsbFile ) )
        {
                new 
bText512 ]
                
formatexbTextcharsmaxbText ), "^n^"%s^" ^"%s^""bSongNamebSongLink )
                
write_filebFilebText )
        
                
console_printid"* Added %s to songlist.ini *"bSongName )
        }
    
        return 
PLUGIN_HANDLED;
}
 
public 
b_ReloadSongListidlevelcid )
{
        if( !
cmd_accessidlevelcid) )
                return 
PLUGIN_HANDLED;
       
        
bInitialize( )
        
console_printid"* songlist.ini file has been successfully reloaded *" )
       
        return 
PLUGIN_HANDLED;
}
 
public 
Cmd_Sayid )
{
        static 
bSaid192 ], bBaws;
        
read_argsbSaid191 );
        
remove_quotesbSaid );
 
        if( 
equalibSaid,"/",) ) bBaws 1;
        else 
bBaws 0;
       
        new 
bFirstMsg21 ], bAllied];
        
strbreakbSaidbBaws ], bFirstMsg20bAllied)
       
        if( 
equalibFirstMsg"music" ) )
        {
                
SongListid );
                return 
PLUGIN_HANDLED_MAIN;
        }
        else if( 
equalibFirstMsg"stop" ) )
        {      
                static 
bMotd1024 ], bLen;
                
bLen formatexbMotdcharsmaxbMotd ), "<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><pre><body>" )
                
bLen += formatexbMotdbLen ], charsmaxbMotd ) - bLen"<center>Music Stopped. This has been brought you by %s.^n"b_PLUGIN )
                
bLen += formatexbMotdbLen ], charsmaxbMotd ) - bLen"<center>Hope you had fun listening to the nice music!^n" )
                
bLen += formatexbMotdbLen ], charsmaxbMotd ) - bLen"</body></pre></html>^n" )
                       
                
show_motdidbMotdb_PLUGIN )
                       
                return 
PLUGIN_HANDLED_MAIN;
        }
        else if( 
equalibFirstMsg"replay" ) )
        {
                if( 
bLastMusicid ] != )
                {
                        
bPlay_SongidbLastMusicid ] );
                }
                else
                {
                        
ColorChatidGREEN,"[AG] ^x01You have not played any song yet." );
                }

                return 
PLUGIN_HANDLED_MAIN;
        }
        else if( 
equalibFirstMsg"copy" ) )
        {
                
Cmd_CopySongid );
                return 
PLUGIN_HANDLED_MAIN;
        }
        else if( 
equalibFirstMsg"search" ) )
        {      
                new 
bLeft151 ], bRight151 ]
 
                
strbreakbSaidbBaws ], bLeft150bRight150 )
                
strbreakbRightbLeft150bRight150 )
               
                
Cmd_SearchidbLeft );
                return 
PLUGIN_HANDLED_MAIN;
        }
       
        return 
PLUGIN_CONTINUE;
}
 
public 
SongListid )
{
        new 
bMenu menu_create"\yChoose a song to play:\r""SongList_Handler" )
        for( new 
1bSongCounti++ )
        {
                new 
bNum];
                
num_to_stribNum);
                
menu_additembMenub_Song_Names], bNum );
        }
       
        
menu_displayidbMenu );
 
        return 
PLUGIN_HANDLED;
}
 
public 
SongList_HandleridbMenuitem )
{
        if( 
item == MENU_EXIT )
        {
                
menu_destroybMenu );
                return 
PLUGIN_HANDLED;
        }
       
        new 
bData], bName64 ];
        new 
accesscallback;
        
menu_item_getinfobMenuitemaccessbDatacharsmaxbData ), bNamecharsmaxbName ), callback );
       
        new 
bChoice str_to_numbData );
       
        
bPlay_SongidbChoice );
       
        return 
PLUGIN_HANDLED;
}
 
public 
Cmd_SearchidbSearch[ ] )
{
        
ColorChatidGREEN"[AG] ^x01You searched for '^x04%s^x01'^x04."bSearch )

        new 
bSearchMenu menu_create"\ySearching Results:\r""SongList_Handler" )
        new 
bNum];
       
        for( new 
1<= bSongCounti++ )
        {
                if( 
containib_Song_Names], bSearch ) != -)
                {
                        
num_to_stribNum);
                        
menu_additembSearchMenub_Song_Names], bNum );
                }
        }
       
        
menu_displayidbSearchMenu );
   
        return 
PLUGIN_HANDLED;
}
 
public 
Cmd_CopySongid )
        
bPlay_SongidbLastSong );
 
bPlay_Songidkey )
{
        if( !
file_existsbMusicPlayer ) )
                return;
 
        new 
bPlayersizeofbMusicPlayer ) ], bMotdsizeofbMusicPlayer ) ], bLinebLength
        
while( read_filebMusicPlayerbLine++, bPlayercharsmaxbPlayer ), bLength ) )
                
addbMotdcharsmaxbMotd ), bPlayer )
 
        
replace_allbMotdcharsmaxbMotd ), "[MEDIA_NAME]"b_Song_Nameskey ] )
        
replace_allbMotdcharsmaxbMotd ), "[MEDIA_URL]"b_Song_Linkskey ] )
       
        
show_motdidbMotdb_PLUGIN )
       
        new 
bName32 ];
        
get_user_nameidbName31 )
        
ColorChat0GREEN"[AG] ^x03%s ^x01is now listening to ^x04%s^x01. Type ^x04/copy ^x01to copy his song."bNameb_Song_Nameskey ] )

        
bLastSong key
        bLastMusic
id ] = key
}
 
public 
bInitialize( )
{
        new 
bConfigDir128 ], bFile128 ], bFileText2048 ], bLen 0;
        
get_localinfo"amxx_configsdir"bConfigDircharsmaxbConfigDir ) )
       
        
formatexbFilecharsmaxbFile ), "%s/%s"bConfigDir"songlist.ini" )
        if( !
file_existsbFile ) )
        {
                
bLen formatbFileTextcharsmaxbFileText ), "; %s Songs^n"b_PLUGIN )
                
bLen += formatbFileTextbLen ], charsmaxbFileText ) - bLen"; Format: ^"Song Name^"  ^"Song Url/Link^"^n" )
                
bLen += formatbFileTextbLen ], charsmaxbFileText ) - bLen"; eg. ^"Eminem Mockingbird^" ^"http://www.youtube.com/watch?v=S9bCLPwzSC0^n^"" )    
                
write_filebFilebFileText )
        }
       
        
formatexbMusicPlayercharsmaxbMusicPlayer ), "%s/%s"bConfigDir"AdvMusicPlayer.html" ); bLen 0
        bSongCount 
1;

        new 
bText1024 ], bLinebLength
        
while( read_filebFilebLine++, bTextcharsmaxbText ), bLength ) )
        {
                
trimbText )
                if( !
bLength || bText] == ';' )
                        continue;
               
                if( 
bSongCount MAX_SONGS )
                        break;
                       
                static 
bLeft32 ], bRight512 ]
                
strbreakbTextbLeftcharsmaxbLeft ), bRightcharsmaxbRight ) )
               
                
replace_allbLeftcharsmaxbLeft ), "^"", "" )
                replace_all( bRight, charsmax( bRight), "
^"""" )
                
replace_allbRightcharsmaxbRight ), " ""%20" )
               
                
copyb_Song_NamesbSongCount ], charsmaxb_Song_Names[ ] ), bLeft )
                
copyb_Song_LinksbSongCount ], charsmaxb_Song_Links[ ] ), bRight )
                
bSongCount++
        }

__________________
Like my clean plugins and work?

Last edited by Baws; 03-03-2014 at 14:01.
Baws is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode