Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-15-2015 , 10:10   [ SOLVED ] Make .ini or .cfg file to plugin?
Reply With Quote #1

How to make basic .ini or .cfg to configure the weapons?
This is the code:
Code:
#include < amxmodx > #include < fun > #include < cstrike > #include < hamsandwich > #include < zombieplague > /*===============================================     "weapon_xm1014"     // XM1014     "weapon_mac10"      // MAC10     "weapon_aug"        // AUG     "weapon_ump45"      // UMP45     "weapon_sg550"      // SG550     "weapon_gali"       // GALIL     "weapon_famas"      // FAMAS     "weapon_mp5navy"    // MP5     "weapon_m249"       // M249     "weapon_m3"     // M3     "weapon_m4a1"       // M4A1     "weapon_tmp"        // TMP     "weapon_g3sg1"      // G3SG1     "weapon_sg552"      // SG552     "weapon_ak47"       // AK47     "weapon_p90"        // P90 ===============================================*/ new cvar_botquota, g_hamczbots; new bot_weapons[][] = {     "weapon_m4a1",     "weapon_sg552",     "weapon_ak47" } public plugin_init() {     register_plugin("[ZP] CS/CZ Bot Weapons", "1.0", "CrazY");     cvar_botquota = get_cvar_pointer("bot_quota"); } public client_putinserver(id) {     if (is_user_bot(id) && !g_hamczbots && cvar_botquota)         set_task(0.1, "register_ham_czbots", id); } public register_ham_czbots(id) {     if (g_hamczbots || !is_user_bot(id) || !get_pcvar_num(cvar_botquota))         return;     RegisterHamFromEntity(Ham_Spawn, id, "fw_HamBotSpawn_Post", 1);     g_hamczbots = true; } public fw_HamBotSpawn_Post(id) {     new size_bot_weapons = random(sizeof bot_weapons);     give_item(id, bot_weapons[size_bot_weapons]);     cs_set_user_bpammo(id, get_weaponid(bot_weapons[size_bot_weapons]), 90); } public zp_user_humanized_post(id) {     if(is_user_bot(id) && !zp_get_user_survivor(id) && !zp_get_user_sniper(id))     {         new size_bot_weapons = random(sizeof bot_weapons);         give_item(id, bot_weapons[size_bot_weapons]);         cs_set_user_bpammo(id, get_weaponid(bot_weapons[size_bot_weapons]), 90);     } }
__________________









Last edited by CrazY.; 11-17-2015 at 07:09.
CrazY. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-15-2015 , 12:32   Re: [ HELP ] Make .ini or .cfg file to plugin?
Reply With Quote #2

Simply learn how to read a file and then use that strings that you get from the file to insert into the bot_weapons array.
__________________
fysiks is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-15-2015 , 12:35   Re: [ HELP ] Make .ini or .cfg file to plugin?
Reply With Quote #3

Tutorials about it?
__________________








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

About what? Have you tried searching? Also, one simple example of reading a file can be found in my "Bot Apology for TK" in my signature.
__________________
fysiks is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-15-2015 , 16:36   Re: [ HELP ] Make .ini or .cfg file to plugin?
Reply With Quote #5

Tutorials about how to make config file
I will take a look.
__________________








CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-15-2015 , 17:09   Re: [ HELP ] Make .ini or .cfg file to plugin?
Reply With Quote #6

Is the goal of this to replace what the bot_weapons[] array holds? Is this just a list of weapon names that will be used?
__________________
Bugsy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-15-2015 , 20:18   Re: [ HELP ] Make .ini or .cfg file to plugin?
Reply With Quote #7

Yes.
__________________








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

If you want a tutorial, search for it. You don't really need a tutorial because the code I told you to look at does everything that you need already. You just need to convert it for your purpose.

P.S. A "config" file is just a text file.
P.P.S. The file that you are describing wouldn't really be a cfg file, IMO. In the context of HLDS, a .cfg file contains commands/cvars and can be executed fully standalone with the exec command.
P.P.P.S Note that this was early in my plugin scripting experience so you would want to update this:

Code:
new g_sorry_phrases[SORRYS_MAX][SORRYS_LEN+1]
to

Code:
new g_sorry_phrases[10][65]
And then SORRYS_LEN should be replaced by charsmax(g_sorry_phrases[]) and SORRYS_MAX should be replaced by sizeof(g_sorry_phrases).
__________________

Last edited by fysiks; 11-15-2015 at 20:43.
fysiks is offline
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 #9

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 #10

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


Thread Tools
Display Modes

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