Author
|
Message
|
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
|
09-03-2018
, 22:21
Map Time
|
#1
|
I've done this code for a friend and I thought that it can be useful for other people.
This code adds different mp_timelimit for each map, which is good for public servers.
Code:
Spoiler
PHP Code:
#include <amxmodx> #include <amxmisc>
#define PLUGIN "Map Time" #define VERSION "1.0" #define AUTHOR "EFFx"
#define LOG_FILE "mt_log.log"
new g_iValue
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) readIniFile() }
readIniFile() { new szConfig[32], szIniFile[115], szMapName[32] get_configsdir(szConfig, charsmax(szConfig)) get_mapname(szMapName, charsmax(szMapName)) formatex(szIniFile, charsmax(szIniFile), "%s/maps_time.ini", szConfig) if(!file_exists(szIniFile)) { log_to_file(LOG_FILE, "[EFFx S]: Archive '%s' not found.", szIniFile) return }
new iFile = fopen(szIniFile, "rt"), bool:bFound = false while(!feof(iFile)) { new szBuffer[512], szKey[50], szValue[554] fgets(iFile, szBuffer, charsmax(szBuffer)) trim(szBuffer) if(!szBuffer[0] || (szBuffer[0] == ';') || (szBuffer[0] == '/' && szBuffer[1] == '/')) continue
strtok(szBuffer, szKey, charsmax(szKey), szValue, charsmax(szValue), '=')
trim(szKey) trim(szValue) if(equal(szMapName, szKey)) { if(!szValue[0]) { log_to_file(LOG_FILE, "[EFFx S]: %s's time value not found. The map will use the default value.", szKey) } else { bFound = true g_iValue = str_to_num(szValue) break } } } fclose(iFile)
if(!bFound) { log_to_file(LOG_FILE, "[EFFx S]: The current map is not in the maps_time.ini. The map will use the default value.") } else { if(g_iValue) { set_task(2.0, "setCvarValue") } }
}
public setCvarValue() { server_cmd("mp_timelimit %d", g_iValue) }
maps_time.ini
__________________
Last edited by EFFx; 09-04-2018 at 16:40.
|
|
|
|