Raised This Month: $51 Target: $400
 12% 

Solved No entries inside an array


Post New Thread Reply   
 
Thread Tools Display Modes
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-13-2018 , 10:17   Re: No entries inside an array
Reply With Quote #11

Its might be reading error, if the array was nt empty.

if( ! iArraySize )
return -1;


Put it inside brackets

if( ! iArraySize )
{
return -1;
}
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 09-13-2018 at 10:20.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-13-2018 , 12:56   Re: No entries inside an array
Reply With Quote #12

Quote:
Originally Posted by KliPPy View Post
That's not nearly enough code for someone to tell, obviously your g_aZoneOrigins is empty.
Correct, but there's something fishy, remove_quotes isn't removing the quotes.

After debugging I found out this:
Quote:
FileName: addons/amxmodx/configs/CSBR_Mod/CSBR_Points/de_mon/"ZoneOrigins.ini"
But here you see that I'm using remove_quotes
PHP Code:
ReadConfig( )
{
    new 
szFilename256 ];
    
formatexszFilenamecharsmaxszFilename ), "%s/%s/%s"g_szConfigsDirPATH_MANAGMENTCSBR_Config_File );
    
    new 
iFile fopenszFilename"rt" );
    
    if( 
iFile )
    {
        new 
szData128 ], szValue32 ], szKey32 ];
        
        while( 
fgetsiFileszDatacharsmaxszData ) ) )
        {
            
trimszData );
            
            switch( 
szData] )
            {
            case 
EOS'#'';''/'
                continue;
                
            default:
                {
                    
strtokszDataszKeycharsmaxszKey ), szValuecharsmaxszValue ), '=' );
                    
                    
trimszKey ); 
                    
trimszValue );
                    
                    
remove_quotesszKey );
                    
remove_quotesszValue );
                                        
                    if( ! 
szValue] )
                    continue;
                    
                    if( 
equalszKey"ZONE_ORIGINS_FILE" ) )
                    {
                        
g_iConfigZONE_ORIGINS_FILE ] = szValue;
                    }
                }
            }
        }
        
fcloseiFile );
    }

__________________
edon1337 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-13-2018 , 13:06   Re: No entries inside an array
Reply With Quote #13

I don't see you removing the quotes in the filename. Show the CSBR_Config_File code.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-13-2018 , 13:09   Re: No entries inside an array
Reply With Quote #14

Quote:
Originally Posted by OciXCrom View Post
I don't see you removing the quotes in the filename. Show the CSBR_Config_File code.
We're not talking about ReadConfig, it only reads this line from the main configuration file
PHP Code:
ZONE_ORIGINS_FILE "ZoneOrigins.ini" 
The problem is, this "ZoneOrigins.ini" keeps the quotation marks even after using remove_quotes on it.
CSBR_Config_File is simply a file name described in the .inc file for easy access. It successfully reads the info, so the problem isn't there.
__________________

Last edited by edon1337; 09-13-2018 at 13:10.
edon1337 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-13-2018 , 13:13   Re: No entries inside an array
Reply With Quote #15

Here's a more detailed code:
PHP Code:
ReadConfig( )
{
    new 
szFilename256 ];
    
formatexszFilenamecharsmaxszFilename ), "%s/%s/%s"g_szConfigsDirPATH_MANAGMENTCSBR_Config_File );
    
    new 
iFile fopenszFilename"rt" );
    
    if( 
iFile )
    {
        new 
szData128 ], szValue32 ], szKey32 ];
        
        while( 
fgetsiFileszDatacharsmaxszData ) ) )
        {
            
trimszData );
            
            switch( 
szData] )
            {
            case 
EOS'#'';''/'
                continue;
                
            default:
                {
                    
strtokszDataszKeycharsmaxszKey ), szValuecharsmaxszValue ), '=' );
                    
                    
remove_quotesszKey );
                    
remove_quotesszValue ); // This here isn't doing the job
                    
                    
trimszKey ); 
                    
trimszValue );            
                    
                    if( 
equalszKey"ZONE_ORIGINS_FILE" ) )
                    {
                        
g_iConfigZONE_ORIGINS_FILE ] = szValue;
                    }
                }
            }
        }
        
fcloseiFile );
    }
}


ReadZoneOrigins( )
{
    new 
szFilename256 ], szData32 ], szOrigin110 ], szOrigin210 ], szOrigin310 ], eDataZoneData ];
    
formatexszFilenamecharsmaxszFilename ), "%s/%s/%s/%s"g_szConfigsDirPATH_POINTSg_szMapNameg_iConfigZONE_ORIGINS_FILE ] );
    
    
log_to_file"Debug.txt""FileName: %s"szFilename ); // g_iConfig[ ZONE_ORIGINS_FILE ] returns string in ""
    
    // code

Debug log:
Quote:
FileName: addons/amxmodx/configs/CSBR_Mod/CSBR_Points/de_mon/"ZoneOrigins.ini"
__________________

Last edited by edon1337; 09-13-2018 at 13:14.
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-13-2018 , 14:02   Re: No entries inside an array
Reply With Quote #16

First trim then remove_quotes.
__________________
klippy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-13-2018 , 14:10   Re: No entries inside an array
Reply With Quote #17

Quote:
Originally Posted by KliPPy View Post
First trim then remove_quotes.
I already thought of that myself an hour ago, so I tried, and it made no difference, and now it worked, I probably uploaded the wrong file. Thanks.

So why does trim() add quotation marks?
__________________
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-13-2018 , 14:12   Re: No entries inside an array
Reply With Quote #18

Quote:
Originally Posted by edon1337 View Post
So why does trim() add quotation marks?
It doesn't.
__________________
klippy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 09-13-2018 , 15:12   Re: No entries inside an array
Reply With Quote #19

Quote:
Originally Posted by KliPPy View Post
It doesn't.
So remove_quotes doesn't remove the quotes from a string that isn't trimmed? The reason being it only searches first and last characters? Or am I wrong?
__________________

Last edited by edon1337; 09-13-2018 at 15:13.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-13-2018 , 15:23   Re: No entries inside an array
Reply With Quote #20

Quote:
Originally Posted by edon1337 View Post
So remove_quotes doesn't remove the quotes from a string that isn't trimmed? The reason being it only searches first and last characters? Or am I wrong?
yes, only first and last characters (Code if you understand C++)
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted 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 08:13.


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