Raised This Month: $ Target: $400
 0% 

Map Tiers Length problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Elit59
Member
Join Date: Feb 2016
Old 05-05-2023 , 22:59   Map Tiers Length problem
Reply With Quote #1

Hello. I would like to add Length. but for some reason it's not good. What could be the problem?

Code:
#include <amxmodx>
#include <amxmisc>
#include <regex>

new const g_szPluginName[] = "Map Tiers";
new const g_szPluginVersion[] = "v1.0.0";
new const g_szPluginAuthor[] = "Cram";

new const g_szINIFileName[] = "maptiers.ini";

new g_szCurrentMap[32];
new g_szTier[16];
new g_szLength[16];

public plugin_init()
{   
    register_plugin(g_szPluginName, g_szPluginVersion, g_szPluginAuthor);
    
    register_clcmd("say /maptier", "cmdShowCurrentMapTier");
    register_clcmd("say /tier", "cmdShowCurrentMapTier");
    
    get_mapname(g_szCurrentMap, charsmax(g_szCurrentMap));

    getCurrentMapTier();
}

public cmdShowCurrentMapTier(id)
{   
    client_print(id, print_chat, "[KZ TIERS] Current: %s, Tier: %s, Length: %s", g_szCurrentMap, g_szTier, g_szLength);
    return PLUGIN_CONTINUE;
}

stock getCurrentMapTier()
{
    new szINIFilePath[256];
    get_configsdir(szINIFilePath, charsmax(szINIFilePath));
    format(szINIFilePath, charsmax(szINIFilePath),"%s/%s", szINIFilePath, g_szINIFileName);
    
    // Make sure each line in the INI is written properly "<anything><whitespace><anything>"
    // Otherwise, the line will be ignored and will be logged
    new const szPattern[] = "(.+)(\w)(.+)$";

    new pFile = fopen(szINIFilePath, "r");
    new szFileLine[64];
    new iFaultyLines = 0;
    
    copy(g_szTier, charsmax(g_szTier), "Not Specified");
    copy(g_szLength, charsmax(g_szLength), "Not Specified");
    
    while(fgets(pFile, szFileLine, charsmax(szFileLine)))
    {   
        if(regex_match(szFileLine, szPattern))
        {   
            new szLeft[32], szRight[16];
            split(szFileLine, szLeft, charsmax(szLeft), szRight, charsmax(szRight), " ");
            
            if(equal(szLeft, g_szCurrentMap))
            {   
                copy(g_szTier, charsmax(g_szTier), szRight);
                copy(g_szLength, charsmax(g_szLength), g_szLength);
                break;
            }
        }
        else
            iFaultyLines++;
    }
    fclose(pFile);
    
    if(iFaultyLines > 0)
    {   
        // Log all of the imporperly formatted lines in your INI file to fix rather than cause an error
        new szLog[256];
        format(szLog, charsmax(szLog), "[MAP TIERS] In: %s, number of improperly formatted lines: (%d)", g_szINIFileName, iFaultyLines);
        
        server_print(szLog);
        log_amx(szLog);
    }
}
Code:
maptiers.ini
hb_dropzone Easy Short
Attached Thumbnails
Click image for larger version

Name:	20230418101822_1.jpg
Views:	48
Size:	73.8 KB
ID:	200515  
Elit59 is offline
 



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 23:53.


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