Raised This Month: $ Target: $400
 0% 

Solved Map tier


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Point
Junior Member
Join Date: Oct 2014
Old 05-18-2019 , 19:57   Re: Map tier
Reply With Quote #5

PHP 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 
reterr[32];

public 
plugin_init() {
    
    
register_plugin(g_szPluginNameg_szPluginVersiong_szPluginAuthor);
    
    
register_clcmd("say /maptier""cmdShowCurrentMapTier");
    
    
get_mapname(g_szCurrentMapcharsmax(g_szCurrentMap));

    
getCurrentMapTier();
}

public 
cmdShowCurrentMapTier(id) {
    
    
client_print(idprint_chat"[MAP TIERS] Current: %s, Tier: %s"g_szCurrentMapg_szTier);
    return 
PLUGIN_CONTINUE;
}

stock getCurrentMapTier() {

    new 
szINIFilePath[256];

    
get_configsdir(szINIFilePathcharsmax(szINIFilePath));
    
format(szINIFilePathcharsmax(szINIFilePath),"%s/%s"szINIFilePathg_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 const 
Regex:rPattern regex_compile(szPatternreterrcharsmax(err));
 
//   new ret, err[32];

    
new pFile fopen(szINIFilePath"r");
    new 
szFileLine[64];
    new 
iFaultyLines 0;
    
    
copy(g_szTiercharsmax(g_szTier), "Not Specified");
    
    while(
fgets(pFileszFileLinecharsmax(szFileLine))) {
        
        if(
regex_match(szFileLinerPattern)) {
            
            new 
szLeft[32], szRight[16];
            
split(szFileLineszLeftcharsmax(szLeft), szRightcharsmax(szRight), " ");
            
            if(
equal(szLeftg_szCurrentMap)) {
                
                
copy(g_szTiercharsmax(g_szTier), szRight);
                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(szLogcharsmax(szLog), "[MAP TIERS] In: %s, number of improperly formatted lines: (%d)"g_szINIFileNameiFaultyLines);
        
        
server_print(szLog);
        
log_amx(szLog);
    }

now i get this
PHP Code:
maptier.sma(42) : error 027invalid character constant
maptier
.sma(42) : error 027invalid character constant
maptier
.sma(54) : error 035argument type mismatch (argument 2)
maptier.sma(79) : warning 204symbol is assigned a value that is never used"rPattern" 
@JocAnis i've tried on 1.9.0 too
Point 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 07:59.


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