Raised This Month: $ Target: $400
 0% 

[ SOLVED ] Make .ini or .cfg file to plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-15-2015 , 20:44   Re: [ HELP ] Make .ini or .cfg file to plugin?
Reply With Quote #1

File needs to be in below format (supports exclusion by using ';' or '//'):
Code:
weapon_ak47
;weapon_glock
//weapon_awp
weapon_fiveseven
weapon_deagle
PHP Code:
#include <amxmodx>
#include <amxmisc>

new g_szWeaponList30 ][ 20 ] , g_WeaponsLoaded;

public 
plugin_init()
{
    
LoadWeapons();
    
    
server_print"Random weapon = [%s]" g_szWeaponListrandomg_WeaponsLoaded ) ] );
}

public 
LoadWeapons()
{
    new 
iFile szFile64 ];
    
formatexszFileget_configsdirszFile charsmaxszFile ) ) ] , charsmaxszFile ) , "/weapons.ini" );
    
    
g_WeaponsLoaded 0;
    
    if ( ( 
iFile fopenszFile "rt" ) ) )
    {
        while ( 
g_WeaponsLoaded sizeofg_szWeaponList ) && fgetsiFile g_szWeaponListg_WeaponsLoaded ] , charsmaxg_szWeaponList[] ) ) )
        {
            
trimg_szWeaponListg_WeaponsLoaded ] );
            
            if ( !
g_szWeaponListg_WeaponsLoaded ][ ] || g_szWeaponListg_WeaponsLoaded ][ ] == ';' || ( g_szWeaponListg_WeaponsLoaded ][ ] == '/' && g_szWeaponListg_WeaponsLoaded ][ ] == '/' ) )
            {
                continue;
            }
            else
            {
                
g_WeaponsLoaded++;
            }
        }
        
fcloseiFile );
    }

__________________
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-15-2015 , 20:45   Re: [ HELP ] Make .ini or .cfg file to plugin?
Reply With Quote #2

And how is he supposed to learn anything if you do it all for him?
__________________
fysiks is offline
Reply



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 18:15.


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