Raised This Month: $2 Target: $400
 0% 

equali() problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ceribik
SourceMod Donor
Join Date: Dec 2007
Old 08-13-2008 , 08:16   equali() problem
Reply With Quote #1

Hello. I've got the following code below; which in summary, reads a file and sees if the current map is listed in the file. For an unknown reason, the comparation of the two strings (mapname and data) isn't working and makes function output false

Code:
new mapname[33];

...

public plugin_init()
{
      get_mapname(mapname, 31);
}

...

stock checkLevelMap()
{
    new listFilename[256];
    
    new confFolder[32];
    get_configsdir(confFolder, 31);
    format(listFilename, 255, "%s/levelmaps.ini", confFolder);
    
    if( file_exists(listFilename) )
    {
        new file = fopen(listFilename, "rt");
        
        new data[64]; 
        while( !feof(file) )
        {
            fgets(file, data, 63); 
            
            server_cmd("echo data == %s", data);
            
            if( equali(mapname, data) )
            {
                fclose(file);
                
                return true;
            }
            
        }
        
        fclose(file);
        
        return false;
    }
    else
    {
        log_amx("[SurfLife] Could not load levelmaps.ini");
    }

    
    return false;
}
Any help would be appreciated
ceribik is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-13-2008 , 08:21   Re: equali() problem
Reply With Quote #2

Try to insert 'trim( data )' just after 'fget()'.
__________________
Arkshine is offline
ceribik
SourceMod Donor
Join Date: Dec 2007
Old 08-14-2008 , 03:16   Re: equali() problem
Reply With Quote #3

That appears to have done the trick. Thanks again
ceribik is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-14-2008 , 03:21   Re: equali() problem
Reply With Quote #4

Because some spaces are presents, probably.
__________________
Arkshine is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 08-14-2008 , 11:40   Re: equali() problem
Reply With Quote #5

not spaces
line feed ;)
fgets doesn't remove '\n' at the end of the string
__________________
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
ceribik
SourceMod Donor
Join Date: Dec 2007
Old 08-15-2008 , 10:06   Re: equali() problem
Reply With Quote #6

Quote:
Originally Posted by Greenberet View Post
not spaces
line feed ;)
fgets doesn't remove '\n' at the end of the string
That's what i was thinking too
ceribik 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 10:18.


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