Raised This Month: $ Target: $400
 0% 

Cells And Array Errors [ Wrong? ]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Baws
Veteran Member
Join Date: Oct 2012
Old 03-04-2014 , 16:59   Re: Cells And Array Errors [ Wrong? ]
Reply With Quote #3

Full code: ( The fprintf worked thanks but others idk )
Didn't test the plugin yet tho.
PHP Code:
#include < amxmodx >
#include < amxmisc >

#define TASK_ID_CMSG 2000

new const g_szPlugin[ ]   = "Advanced Music Player";
new const 
g_szVersion[ ]  = "1.5";
new const 
g_szAuthor[ ]   = "Baws";

enum Color
{
    
NORMAL 1,
    
GREEN
    
TEAM_COLOR,
    
GREY
    
RED
    
BLUE
};

new 
SongId;
new 
LastSongSongCount;

new 
g_MusicPlayer1206 ];
new 
g_Song_NamesMaxSongs ][ 64 ];
new 
g_Song_LinksMaxSongs ][ 512 ];
new 
g_LastMusic33 ];

new Array:
MaxSongs;

new 
PcvarConnectMsg;

public 
plugin_init( )
{
        
register_pluging_szPluging_szVersiong_szAuthor );
        
register_cvarg_szPluging_szVersionFCVAR_SERVER FCVAR_EXTDLL FCVAR_UNLOGGED FCVAR_SPONLY );
       
        
register_clcmd"say""Cmd_Say" );
        
register_clcmd"say_team""Cmd_Say" );
    
        
register_concmd"amx_addsong""AddSong"ADMIN_CFG"- Usage: <song name> <song url/link> | Attention: Instead of < > use quotes." );
        
register_concmd"amx_reloadfile""ReloadSongList"ADMIN_CFG"- Reload's the songlist.ini file." );
    
        
PcvarConnectMsg register_cvar"sv_connectmessage""1" );
    
        
MaxSongs ArrayCreate);
    
        
register_dictionary_colored"AdvMusicPlayer.txt" );
       
        
Initialize( );
}

public 
client_putinserverid )
{
        
g_LastMusicid ] = 0;

        if( 
get_pcvar_numPcvarConnectMsg ) == )
                
set_task25.0"ConnectMsg"id TASK_ID_CMSG )
}

public 
ConnectMsgid )
{
        
id -= TASK_ID_CMSG
    
        
if( get_pcvar_numPcvarConnectMsg ) == )
        {
                new 
szName32 ];
                
get_user_nameidszNamecharsmaxszName ) )
                
client_print_coloridNORMAL"%L"szNameid"CONNECT_MSG" )
        }
}

public 
AddSongidlevelcid )
{
        if( !
cmd_accessidlevelcid) )
                return 
PLUGIN_HANDLED;
    
        new 
szSongName36 ], szSongLink256 ]
        
read_argv1szSongNamecharsmaxszSongName ) )
        
read_argv2szSongNamecharsmaxszSongLink ) )
    
        
copyg_Song_NamesSongId ], charsmaxg_Song_Names[ ] ), szSongName )
        
copyg_Song_LinksSongId++ ], charsmaxg_Song_Links[ ] ), szSongLink )
    
        new 
iConfigDir128 ], iFile128 ]
        
get_localinfo"amxx_configsdir"iConfigDircharsmaxiConfigDir ) )
    
        
formatexiFilecharsmaxiFile ), "%s/%s"iConfigDir"songlist.ini" )
        if( 
file_existsiFile ) )
        {
                new 
iText512 ]
                
formatexiTextcharsmaxiText ), "^n^"%s^" ^"%s^""szSongNameszSongLink )
                
write_fileiFileiText )
        
                
console_printid"%L"szSongNameid"SONG_ADDED" )
        }
    
        return 
PLUGIN_HANDLED;
}
 
public 
ReloadSongListidlevelcid )
{
        if( !
cmd_accessidlevelcid) )
                return 
PLUGIN_HANDLED;
       
        
Initialize( )
        
console_printid"%L"id"FILE_RELOADED" )
       
        return 
PLUGIN_HANDLED;
}

public 
Cmd_Sayid )
{
        static 
Said192 ], Baws;
        
read_argsSaid191 );
        
remove_quotesSaid );
 
        if( 
equaliSaid"/") ) Baws 1;
        else 
Baws 0;
       
        new 
szFirstMsg21 //szAllied[ 2 ]; //strbreak( Said[ Baws ], szFirstMsg, 20, szAllied, 1 )
       
        
if( equaliszFirstMsg"music" ) )
        {
                
SongListid );
                return 
PLUGIN_HANDLED;
        }
        else if( 
equaliszFirstMsg"stop" ) )
        {      
                static 
Motd1024 ], Len;
                
Len formatexMotdcharsmaxMotd ), "<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><pre><body>" )
                
Len += formatexMotdLen], charsmaxMotd ) - Len"<center><b>Music Stopped</b>." )
                
Len += formatexMotdLen ], charsmaxMotd ) - Len"<center>This has been brought you by %s.^n"g_szAuthor )
                
Len += formatexMotdLen ], charsmaxMotd ) - Len"<center>%s is the most powerful music player plugin ever!"g_szPlugin )
                
Len += formatexMotdLen ], charsmaxMotd ) - Len"<center>Hope you had fun listening to the nice music!^n" )
                
Len += formatexMotdLen ], charsmaxMotd ) - Len"</body></pre></html>^n" )
                       
                
show_motdidMotdg_szPlugin )
                       
                return 
PLUGIN_HANDLED;
        }
        else if( 
equaliszFirstMsg"replay" ) )
        {
                if( 
g_LastMusicid ] != )
                {
                        
Play_Songidg_LastMusicid ] );
                }
                else
                {
                        
client_print_coloridNORMAL"%L"id"NO_SONG_PLAYED" );
                }

                return 
PLUGIN_HANDLED;
        }
        else if( 
equaliszFirstMsg"copy" ) )
        {
                
Cmd_CopySongid );
                return 
PLUGIN_HANDLED;
        }
        else if( 
equaliszFirstMsg"search" ) )
        {      
                new 
Left151 ], Right151 ];
 
                
parseSaidBaws ], Left150Right150 //strbreak( Right, Left, 150, Right, 150 )
               
                
Cmd_SearchidLeft );
                return 
PLUGIN_HANDLED;
        }
       
        return 
PLUGIN_CONTINUE;
}
 
public 
SongListid )
{
        new 
Menu menu_create"\yChoose a song to play:\r""SongList_Handler" )

        new 
Num];
        for( new 
0SongCounti++ )
        {
                
num_to_striNum);
                
menu_additemMenug_Song_Names], Num );
        }
       
        
menu_displayidMenu );
 
        return 
PLUGIN_HANDLED;
}

public 
SongList_HandleridMenuitem )
{
        if( 
item == MENU_EXIT )
        {
                
menu_destroyMenu );
                return 
PLUGIN_HANDLED;
        }
       
        
Play_Songiditem );
       
        return 
PLUGIN_HANDLED;
}

public 
Cmd_SearchidSearch[ ] )
{
        
client_print_coloridNORMAL"%L"Searchid"SEARCHED_FOR" )

        new 
SearchMenu menu_create"\ySearching Results:\r""SongList_Handler" )
    
        new 
Num];
        for( new 
0<= SongCounti++ )
        {
                if( 
containig_Song_Names], Search ) != -)
                {
                        
num_to_striNum);
                        
menu_additemSearchMenug_Song_Names], Num );
                }
        }
       
        
menu_displayidSearchMenu );
   
        return 
PLUGIN_HANDLED;
}
 
public 
Cmd_CopySongid )
        
Play_SongidLastSong );
 
Play_Songidkey )
{
        if( !
file_existsg_MusicPlayer ) )
                return;

        new 
szPlayercharsmaxg_MusicPlayer ) ], szMotdcharsmaxg_MusicPlayer ) ], szLineszLength
        
while( read_fileg_MusicPlayerszLine++, szPlayercharsmaxszPlayer ), szLength ) )
                
addszMotdcharsmaxszMotd ), szPlayer )
 
        
parseszMotdcharsmaxszMotd ), "[MEDIA_NAME]"g_Song_Nameskey ] )
        
parseszMotdcharsmaxszMotd ), "[MEDIA_URL]"g_Song_Linkskey ] )
       
        
show_motdidszMotdg_szPlugin )
       
        new 
szName32 ];
        
get_user_nameidszName31 )
        
client_print_color0NORMAL"%L"szNameg_Song_Nameskey ], id"LISTENING_TO" )

        
LastSong key
        g_LastMusic
id ] = key
}
 
public 
Initialize( )
{
        new 
iConfigDir128 ], iFile128 ]//, iFileText[ 2048 ], iLen = 0;
        
get_localinfo"amxx_configsdir"iConfigDircharsmaxiConfigDir ) )
    
        
format(iFile127"configs/songlist.ini")
        if( !
file_existsiFile ) )  
        {
                new 
FileP fopeniFile"+a" )
                
fprintfFileP"; %s Songs^n"g_szPlugin )
                
fprintfFileP"; Format: ^"Song Name^"  ^"Song Url/Link^"^n" )
                
fprintfFileP"; eg. ^"Eminem Mockingbird^" ^"http://www.youtube.com/watch?v=S9bCLPwzSC0^n^"" )
                
fcloseFileP )
                
server_print"%L"iFile"FILE_ADDED" )
        }
        
/*formatex( iFile, charsmax( iFile ), "%s/%s", iConfigDir, "songlist.ini" )
        if( !file_exists( iFile ) )
        {
                iLen = format( iFileText, charsmax( iFileText ), "; %s Songs^n", g_szPlugin )
                iLen += format( iFileText[ iLen ], charsmax( iFileText ) - iLen, "; Format: ^"Song Name^"  ^"Song Url/Link^"^n" )
                iLen += format( iFileText[ iLen ], charsmax( iFileText ) - iLen, "; eg. ^"Eminem - Mockingbird^" ^"http://www.youtube.com/watch?v=S9bCLPwzSC0^n^"" )    
                write_file( iFile, iFileText )
        }*/
       
        
formatexg_MusicPlayercharsmaxg_MusicPlayer ), "%s/%s"iConfigDir"AdvMusicPlayer.html" ); //iLen = 0
        
SongCount 1;

        new 
szText1024 ], LineLength;
        while( 
read_fileiFileLine++, szTextcharsmaxszText ), Length ) )
        {
                
trimszText )
                if( !
Length || szText] == ';' )
                        continue;
               
                if( 
SongCount MaxSongs )
                        break;
                       
                static 
Left35 ], Right512 ]
                
parseszTextLeftcharsmaxLeft ), RightcharsmaxRight ) )
               
                
parseLeftcharsmaxLeft ), "^"", "" )
                parse( Right, charsmax( Right), "
^"""" )
                
parseRightcharsmaxRight ), " ""%20" )
               
                
copyg_Song_NamesSongCount ], charsmaxg_Song_Names[ ] ), Left )
                
copyg_Song_LinksSongCount ], charsmaxg_Song_Links[ ] ), Right )
                
SongCount++
        }
}

register_dictionary_colored( const iFile[ ] ) 
{
        if( !
register_dictionaryiFile ) ) 
                return 
0;
    
        new 
iLangDir128 ];
        
get_localinfo"amxx_datadir"iLangDircharsmaxiLangDir ) )
        
formatexiLangDircharsmaxiLangDir ), "%s/lang/%s"iLangDiriFile )

        new 
FileP fopeniLangDir"rt" );
    
        if( !
FileP 
        {
                
log_amx"Failed to open: %s"iLangDir );
        
                return 
0;
        }
    
        new 
szBuffer512 ], szLang], szKey64 ], szTranslation256 ], TransKey:iKey;
    
        while( !
feofFileP ) ) 
        {
                
fgetsFilePszBuffer511 );
        
                if( 
szBuffer] == '[' 
                {
                        
strtokszBuffer], szLang2szBuffer1']' );
                } 
                else if( 
szBuffer] ) 
                {
                        
strbreakszBufferszKey63szTranslation255 );
                        
iKey GetLangTransKeyszKey );
            
                        if( 
iKey != TransKey_Bad 
                        {
                                
replace_allszTranslation255"!g""^4" );
                                
replace_allszTranslation255"!t""^3" );
                                
replace_allszTranslation255"!n""^1" );
                
                                
AddTranslationszLangiKeyszTranslation] );
                        }
                }
        }
    
        
fcloseFileP );
    
        return 
1;
}

client_print_color(idColor:type, const msg[], {Float,Sql,Result,_}:...) 
{
    static 
SayText;

    if(!
SayText)
        
SayText get_user_msgid("SayText");

    static 
message[256];

    switch(
type)
    {
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        case 
TEAM_COLOR// Team Color. Ie. Red (Terrorist) or blue (Counter-Terrorist).
        
{
            
message[0] = 0x03;
        }
        default: 
// Yellow.
        
{

            
message[0] = 0x01;
        }
    }

    
vformat(message[1], 251msg4);

    
message[192] = '^0';

    if(
id)
    {
        if(
is_user_connected(id))
        {
            
message_begin(MSG_ONESayText, {000}, id);
            
write_byte(id);
            
write_string(message);
            
message_end();
        }
    } else {
        static 
players[32]; new countindex;
        
get_players(playerscount);

        for(new 
0counti++)
        {
            
index players[i];

            
message_begin(MSG_ONESayText, {000}, index);
            
write_byte(index);
            
write_string(message);
            
message_end();

        }
    }

Also Array by connor he gave me lol: https://forums.alliedmods.net/showthread.php?t=236414
__________________
Like my clean plugins and work?

Last edited by Baws; 03-04-2014 at 16:59.
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 06:04.


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