AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] Ini Read (https://forums.alliedmods.net/showthread.php?t=297847)

DarthMan 05-25-2017 11:09

[ H3LP ] Ini Read
 
Hello. So I made a say command with more arguments using strtok. My question is, when reading the ini file, how can I make it to look for only the maps that are containing the argument? So, for example, if I look for lambda and it contains more maps with lambda, it must only list all the maps containing the lambda word. I ahve tried using both contain and equal with strlen, but in both cases it listed all maps that were valid in the maps folder from the ini file. Thanks !

KiLLeR. 05-25-2017 19:57

Re: [ H3LP ] Ini Read
 
Post your code, probably something is wrong with it cuz it must work with contain.

DarthMan 05-26-2017 04:38

Re: [ H3LP ] Ini Read
 
Quote:

Originally Posted by KiLLeR. (Post 2523498)
Post your code, probably something is wrong with it cuz it must work with contain.

Here's the reading part.

PHP Code:

new szFile[256]
get_configsdir(szFilecharsmax(szFile))
add(szFilecharsmax(szFile), "/maps.ini")
        
new 
iFile fopen(szFile"r")
        
while (!
feof(iFile))
{
    
fgets(iFileszMapNamecharsmax(szMapName))
            
    
trim(szMapName)
            
    if (
szMapName[0] == EOS || szMapName[0] == '/' || szMapName[0] == '[' || szMapName[0] == ']' || szMapName[0] == ';')
        continue;
            
    if (
equal(sMapszMapName), strlen(sMap) && is_map_valid(szMapName))
    {
        
i++;
        
client_print(idprint_console"%i. %s"iszMapName);
    }
}
client_print(idprint_chat"* A complete list of %d matching maps will be displayed in your console."i)
fclose(iFile); 


HamletEagle 05-26-2017 04:47

Re: [ H3LP ] Ini Read
 
Closing ) too soon in the if.

DarthMan 05-26-2017 06:20

Re: [ H3LP ] Ini Read
 
Quote:

Originally Posted by HamletEagle (Post 2523551)
Closing ) too soon in the if.

I fixed it, thanks to my one of my steam friends :)


All times are GMT -4. The time now is 03:50.

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