Raised This Month: $ Target: $400
 0% 

Convert const to aray and load data from .ini file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
twix_p
Member
Join Date: Jul 2011
Old 12-28-2012 , 20:12   Convert const to aray and load data from .ini file
Reply With Quote #1

First code works great, it is easy to replace RGB values and to don't show them in message.

PHP Code:
#include < amxmodx >
#include < amxmisc >

new g_iMessagesCountg_iVariableg_iAdvertisementsSync;

enum _BLEAHHHRED], GREEN], BLUE], MESSAGE512 ] }

static const 
szMessages[ ][ BLEAHHH ] =
{
    { 
255000000"1 = Hello, it Worked!" },
    { 
000255000"2 = Hello, it Worked!" },
    { 
000000200"3 = Hello, it Worked!" },
    { 
000200000"4 = Hello, it Worked!" },
    { 
200000000"5 = Hello, it Worked!" }
}

public 
plugin_init( )
{
    
register_plugin"Messages Shower""1.0b""[dvL]aditza" );

    
g_iAdvertisementsSync CreateHudSyncObj( );
    
g_iMessagesCount sizeofszMessages ) -1;

    
set_task5.0"Task_HudMessages", .flags"b" );
}

public 
Task_HudMessages( )
{
    if( 
g_iVariable g_iMessagesCount )
        
g_iVariable 0;
    
    
set_hudmessageszMessagesg_iVariable ][ RED  ], szMessagesg_iVariable ][ GREEN ], szMessagesg_iVariable ][ BLUE ], -1.00.2000.512.02.02.0, -);
    
ShowSyncHudMsg0g_iAdvertisementsSync"%s"szMessagesg_iVariable ][ MESSAGE] );

    
g_iVariable++;

Below i tryed to "convert" the plugin, but i did a big and useless
I think szRight must be divided into four parts R, G, B and the message. I realy need help to do that.


PHP Code:

#include < amxmodx >
#include < amxmisc >

enum _BLEAHHHRED], GREEN], BLUE], MESSAGE512 ] }

static Array: 
g_iMessagesg_iMessagesCountcLoadedDATA[ ][ BLEAHHH ], g_iAdvertisementsSyncg_iVariable;

public 
plugin_init( )
{
    
register_plugin"Messages Shower""1.0b""[dvL]aditza" );

    
g_iMessages ArrayCreate32 );
    
g_iAdvertisementsSync CreateHudSyncObj( );

    new 
iFile fopen"addons/amxmodx/configs/Messages.ini""rt" );
    static 
szData64 ], szLeft16 ], szRight256 ];
    
    while( !
feofiFile ) )
    {
        
fgetsiFileszData63 );
        
        
strtokszDataszLeft15szRight255'@' );
        
        
trimszLeft );
        
trimszRight );
        
        if( 
equaliszLeft"HudMsg" ) )
        {
            
ArrayPushStringg_iMessagesszRight );

            
replace_allszRight256"#""^n" );

            
g_iMessagesCount ArraySizeg_iMessages ) -1;

            
formatexcLoadedDATAg_iMessagesCount ][ MESSAGE ], 255"%s"szRight );
        }
    }
    
    
fcloseiFile );

    
set_task2.0"Task_SendMessages", .flags "b" );
}

public 
Task_SendMessages( )
{
    if( 
g_iVariable g_iMessagesCount )
        
g_iVariable 0;

    
set_hudmessagecLoadedDATAg_iVariable ][ RED ], cLoadedDATAg_iVariable ][ GREEN ], cLoadedDATAg_iVariable][ BLUE ], -1.00.2000.512.02.02.0, -);
    
ShowSyncHudMsg0g_iAdvertisementsSync"%s, NR: %d"cLoadedDATAg_iVariable ][ MESSAGE ], g_iVariable )

    
g_iVariable++;
}


Messages.ini:

HudMsg 250 010 200 Helloit Worked!
HudMsg 020 010 050 Helloit Worked!
HudMsg 250 010 200 Helloit Worked!
HudMsg 020 010 050 Helloit Worked!
HudMsg 250 010 200 Helloit Worked!
HudMsg 020 010 050 Helloit Worked

Last edited by twix_p; 12-28-2012 at 20:22.
twix_p 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 13:29.


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