PHP Code:
new const BB_CUSTOMIZATION_FILE[] = "ZombieBasebuilder.ini"
// Customization file sections
enum
{
SECTION_NONE = 0,
SECTION_ACCESS_FLAGS,
SECTION_MOD_CVARS
}
// Access flags
enum
{
ACCESS_ENABLE_MOD = 0,
ACCESS_GIVEAP,
ACCESS_TAKEAP,
ACCESS_SWAP,
ACCESS_REVIVE,
ACCESS_GUNS,
ACCESS_RELEASE,
ACCESS_BUILD,
ACCESS_OVERRIDE,
ACCESS_LOCKAFTER,
ACCESS_LOCK,
ACCESS_BUILDBAN,
MAX_ACCESS_FLAGS
}
load_customization_from_files()
{
// Build customization file path
new path[64]
get_configsdir(path, charsmax(path))
format(path, charsmax(path), "%s/%s", path, BB_CUSTOMIZATION_FILE)
// File not present
if (!file_exists(path))
{
new error[100]
formatex(error, charsmax(error), "Cannot load customization file %s!", path)
set_fail_state(error)
return;
}
// Set up some vars to hold parsing info
new linedata[1024], key[64], value[960], section, teams
// Open customization file for reading
new file = fopen(path, "rt")
while (file && !feof(file))
{
// Read one line at a time
fgets(file, linedata, charsmax(linedata))
// Replace newlines with a null character to prevent headaches
replace(linedata, charsmax(linedata), "^n", "")
// Blank line or comment
if (!linedata[0] || linedata[0] == ';') continue;
// New section starting
if (linedata[0] == '[')
{
section++
continue;
}
// Get key and value(s)
strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
// Trim spaces
trim(key)
trim(value)
switch (section)
{
case SECTION_ACCESS_FLAGS:
{
if (equal(key, "ENABLE/DISABLE MOD"))
g_access_flag[ACCESS_ENABLE_MOD] = read_flags(value)
else if (equal(key, "GIVE AMMO"))
g_access_flag[ACCESS_GIVEAP] = read_flags(value)
else if (equal(key, "TAKE AMMO"))
g_access_flag[ACCESS_TAKEAP] = read_flags(value)
else if (equal(key, "SWAP A PLAYERS TEAM"))
g_access_flag[ACCESS_SWAP] = read_flags(value)
else if (equal(key, "RESPAWN A PLAYER"))
g_access_flag[ACCESS_REVIVE] = read_flags(value)
else if (equal(key, "REOPEN GUNS MENU FOR PLAYER"))
g_access_flag[ACCESS_GUNS] = read_flags(value)
else if (equal(key, "RELEASE ZOMBIE'S MANUALLY"))
g_access_flag[ACCESS_RELEASE] = read_flags(value)
else if (equal(key, "BUILD AFTER BUILD TIME"))
g_access_flag[ACCESS_BUILD] = read_flags(value)
else if (equal(key, "FOR ADMIN OF ADMINS"))
g_access_flag[ACCESS_OVERRIDE] = read_flags(value)
else if (equal(key, "LOCK/UNLOCK BLOCKS AFTER BUILD TIME"))
g_access_flag[ACCESS_LOCKAFTER] = read_flags(value)
else if (equal(key, "LOCK/UNLOCK BLOCKS"))
g_access_flag[ACCESS_LOCK] = read_flags(value)
else if (equal(key, "BAN PLAYERS FROM BUILDING"))
g_access_flag[ACCESS_BUILDBAN] = read_flags(value)
}
case SECTION_MOD_CVARS:
{
if (equal(key, "MOD ENABLE/DISABLE"))
g_pcvar_enabled = str_to_num(value)
if (equal(key, "BUILD TIME"))
g_pcvar_buildtime = str_to_num(value)
if (equal(key, "PREP TIME"))
g_pcvar_preptime = str_to_num(value)
if (equal(key, "ZOMBIE RESPAWN DELAY"))
g_pcvar_zombietime = str_to_num(value)
if (equal(key, "SURVIVOR RESPAWN INFECTION DELAY"))
g_pcvar_infecttime = str_to_num(value)
if (equal(key, "SHOW MOVERS"))
g_pcvar_showmovers = str_to_num(value)
if (equal(key, "LOCK BLOCKS"))
g_pcvar_lockblocks = str_to_num(value)
if (equal(key, "LOCK MAX"))
g_pcvar_lockmax = str_to_num(value)
if (equal(key, "COLOR MOD <0/1/2>"))
g_pcvar_colormode = str_to_num(value)
if (equal(key, "PUSH CEILING"))
g_pcvar_entmaxdist = str_to_num(value)
if (equal(key, "PULL FLOOR"))
g_pcvar_entmindist = str_to_num(value)
if (equal(key, "GRAB SET"))
g_pcvar_entsetdist = str_to_num(value)
if (equal(key, "RESET BLOCKS ON NEW ROUND"))
g_pcvar_resetent = str_to_num(value)
if (equal(key, "ONE HIT KILL FOR ZOMBIES"))
g_pcvar_supercut = str_to_num(value)
if (equal(key, "GUNS MENU"))
g_pcvar_gunsmenu = str_to_num(value)
if (equal(key, "GRENADES"))
g_pcvar_givenades = str_to_num(value)
if (equal(key, "ALLOWED WEAPONS"))
g_pcvar_allowedweps = str_to_num(value)
}
}
}
if (file) fclose(file)