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 ret, err[32];
public plugin_init() {
register_plugin(g_szPluginName, g_szPluginVersion, g_szPluginAuthor);
register_clcmd("say /maptier", "cmdShowCurrentMapTier");
get_mapname(g_szCurrentMap, charsmax(g_szCurrentMap));
getCurrentMapTier();
}
public cmdShowCurrentMapTier(id) {
client_print(id, print_chat, "[MAP TIERS] Current: %s, Tier: %s", g_szCurrentMap, g_szTier);
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 const Regex:rPattern = regex_compile(szPattern, ret, err, charsmax(err));
// new ret, err[32];
new pFile = fopen(szINIFilePath, "r");
new szFileLine[64];
new iFaultyLines = 0;
copy(g_szTier, charsmax(g_szTier), "Not Specified");
while(fgets(pFile, szFileLine, charsmax(szFileLine))) {
if(regex_match(szFileLine, rPattern)) {
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);
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);
}
}
now i get this
PHP Code:
maptier.sma(42) : error 027: invalid character constant
maptier.sma(42) : error 027: invalid character constant
maptier.sma(54) : error 035: argument type mismatch (argument 2)
maptier.sma(79) : warning 204: symbol is assigned a value that is never used: "rPattern"
@JocAnis i've tried on 1.9.0 too