AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   .ini File (https://forums.alliedmods.net/showthread.php?t=295307)

EFFx 03-21-2017 21:42

.ini File
 
I'm trying to copy every single models for a weapon, there're 11 models.

Thats the code i'm using:

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

enum WeapSett
{
    
V_KNIFE,
    
V_M4A1,
    
V_AK47,
    
V_AWP
}

new 
WeaponSkins[WeapSett]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
}

public 
plugin_precache()
{
    new 
szFile[256]
    
get_configsdir(szFilecharsmax(szFile))
    
add(szFilecharsmax(szFile), "/furien_models.ini")

    new 
iFile fopen(szFile"r")

    while (!
feof(iFile))
    {
        new 
szBuffer[512], Key[64], Value[256]

        
fgets(iFileszBuffercharsmax(szBuffer))
        
trim(szBuffer)
        
        if (
szBuffer[0] == EOS || szBuffer[0] == ';' || (szBuffer[0] == '/' && szBuffer[1] == '/'))
            continue

        
strtok(szBufferKeycharsmax(Key), Valuecharsmax(Value), '=')

        
trim(Key)
        
trim(Value)
        
        if(
equal(Key"V_KNIFE"))
        {
            
copy(WeaponSkins[V_KNIFE], charsmax(WeaponSkins[]), Value)
        }
        else if(
equal(Key"V_M4A1"))
        {
            
copy(WeaponSkins[V_M4A1], charsmax(WeaponSkins[]), Value)
        }
        else if(
equal(Key"V_AK47"))
        {
            
copy(WeaponSkins[V_AK47], charsmax(WeaponSkins[]), Value)
        }
        else if(
equal(Key"V_AWP"))
        {
            
copy(WeaponSkins[V_AWP], charsmax(WeaponSkins[]), Value)
        }
        
        for(new 
i;sizeof WeaponSkins;i++)
        {
            
precache_model(WeaponSkins[WeapSett:i])
        }
    }
    
fclose(iFile)


The question is: Is there any format for use instead of 'else if'?

fysiks 03-22-2017 00:09

Re: .ini File
 
It depends on what you are trying to achieve. What's wrong with the if else if?

EFFx 03-22-2017 03:58

Re: .ini File
 
Nothing, I'm just searching any another formats.

klippy 03-22-2017 04:35

Re: .ini File
 
Tries possibly.

EFFx 03-22-2017 15:07

Re: .ini File
 
But It will require one trie for every single models of them, right?

OciXCrom 03-22-2017 20:38

Re: .ini File
 
It will require one KEY in the trie for each model.


All times are GMT -4. The time now is 18:00.

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