#include <amxmodx>
#include <amx_settings_api>
#include <cs_player_models_api>
#include <cs_weap_models_api>
#include <zp50_core>
#define LIBRARY_SURVIVOR "zp50_class_survivor"
#include <zp50_class_survivor>
// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
// Default Priveleges models
new const models_creator_human_player[][] = { "vip" }
new const models_creator_human_knife[][] = { "models/v_knife.mdl" }
new const models_owner_human_player[][] = { "owner" }
new const models_owner_human_knife[][] = { "models/v_knife.mdl" }
#define PLAYERMODEL_MAX_LENGTH 32
#define MODEL_MAX_LENGTH 64
#define ACCESSFLAG_MAX_LENGTH 2
// Access flags
new g_access_creator_models[ACCESSFLAG_MAX_LENGTH] = "u"
new g_access_owner_models[ACCESSFLAG_MAX_LENGTH] = "s"
// Custom models
new Array:g_models_creator_human_player
new Array:g_models_creator_human_knife
new Array:g_models_owner_human_player
new Array:g_models_owner_human_knife
new cvar_creator_models_human_player, cvar_creator_models_human_knife, cvar_owner_models_human_player, cvar_owner_models_human_knife
public plugin_init()
{
register_plugin("[ZP] Admin Models", ZP_VERSION_STRING, "ZP Dev Team")
cvar_creator_models_human_player = register_cvar("zp_creator_models_human_player", "1")
cvar_creator_models_human_knife = register_cvar("zp_creator_models_human_knife", "1")
cvar_owner_models_human_player = register_cvar("zp_owner_models_human_player", "1")
cvar_owner_models_human_knife = register_cvar("zp_owner_models_human_knife", "1")
}
public plugin_precache()
{
// Initialize arrays
g_models_creator_human_player = ArrayCreate(PLAYERMODEL_MAX_LENGTH, 1)
g_models_creator_human_knife = ArrayCreate(MODEL_MAX_LENGTH, 1)
g_models_owner_human_player = ArrayCreate(PLAYERMODEL_MAX_LENGTH, 1)
g_models_owner_human_knife = ArrayCreate(MODEL_MAX_LENGTH, 1)
// Load from external file
amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "CREATOR HUMAN", g_models_creator_human_player)
amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE CREATOR HUMAN", g_models_creator_human_knife)
amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "OWNER HUMAN", g_models_owner_human_player)
amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE OWNER HUMAN", g_models_owner_human_knife)
// If we couldn't load from file, use and save default ones
new index
if (ArraySize(g_models_creator_human_player) == 0)
{
for (index = 0; index < sizeof models_creator_human_player; index++)
ArrayPushString(g_models_creator_human_player, models_creator_human_player[index])
// Save to external file
amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "CREATOR HUMAN", g_models_creator_human_player)
}
if (ArraySize(g_models_owner_human_player) == 0)
{
for (index = 0; index < sizeof models_owner_human_player; index++)
ArrayPushString(g_models_owner_human_player, models_owner_human_player[index])
// Save to external file
amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Player Models", "OWNER HUMAN", g_models_owner_human_player)
}
if (ArraySize(g_models_creator_human_knife) == 0)
{
for (index = 0; index < sizeof models_creator_human_knife; index++)
ArrayPushString(g_models_creator_human_knife, models_creator_human_knife[index])
// Save to external file
amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE CREATOR HUMAN", g_models_creator_human_knife)
}
if (ArraySize(g_models_owner_human_knife) == 0)
{
for (index = 0; index < sizeof models_owner_human_knife; index++)
ArrayPushString(g_models_owner_human_knife, models_owner_human_knife[index])
// Save to external file
amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Weapon Models", "V_KNIFE OWNER HUMAN", g_models_owner_human_knife)
}
// Load from external file, save if not found
if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Access Flags", "CREATOR MODELS", g_access_creator_models, charsmax(g_access_creator_models)))
amx_save_setting_string(ZP_SETTINGS_FILE, "Access Flags", "CREATOR MODELS", g_access_creator_models)
if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Access Flags", "OWNER MODELS", g_access_owner_models, charsmax(g_access_owner_models)))
amx_save_setting_string(ZP_SETTINGS_FILE, "Access Flags", "OWNER MODELS", g_access_owner_models)
// Precache models
new player_model[PLAYERMODEL_MAX_LENGTH], model[MODEL_MAX_LENGTH], model_path[128]
for (index = 0; index < ArraySize(g_models_creator_human_player); index++)
{
ArrayGetString(g_models_creator_human_player, index, player_model, charsmax(player_model))
formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
precache_model(model_path)
// Support modelT.mdl files
formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
if (file_exists(model_path)) precache_model(model_path)
}
for (index = 0; index < ArraySize(g_models_creator_human_knife); index++)
{
ArrayGetString(g_models_creator_human_knife, index, model, charsmax(model))
precache_model(model)
}
for (index = 0; index < ArraySize(g_models_owner_human_player); index++)
{
ArrayGetString(g_models_owner_human_player, index, player_model, charsmax(player_model))
formatex(model_path, charsmax(model_path), "models/player/%s/%s.mdl", player_model, player_model)
precache_model(model_path)
// Support modelT.mdl files
formatex(model_path, charsmax(model_path), "models/player/%s/%sT.mdl", player_model, player_model)
if (file_exists(model_path)) precache_model(model_path)
}
for (index = 0; index < ArraySize(g_models_owner_human_knife); index++)
{
ArrayGetString(g_models_owner_human_knife, index, model, charsmax(model))
precache_model(model)
}
}
public plugin_natives()
{
set_module_filter("module_filter")
set_native_filter("native_filter")
}
public module_filter(const module[])
{
if (equal(module, LIBRARY_SURVIVOR))
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public native_filter(const name[], index, trap)
{
if (!trap)
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public zp_fw_core_cure_post(id, attacker)
{
// Skip if player doesn't have required creator flags
if (!(get_user_flags(id) & read_flags(g_access_creator_models)))
return;
if (!(get_user_flags(id) & read_flags(g_access_owner_models)))
return;
// Skip for Survivor
if (LibraryExists(LIBRARY_SURVIVOR, LibType_Library) && zp_class_survivor_get(id))
return;
// Apply creator human player model?
if (get_pcvar_num(cvar_creator_models_human_player) && (get_user_flags(id) & read_flags(g_access_creator_models)))
{
new player_model[PLAYERMODEL_MAX_LENGTH]
ArrayGetString(g_models_creator_human_player, random_num(0, ArraySize(g_models_creator_human_player) - 1), player_model, charsmax(player_model))
cs_set_player_model(id, player_model)
}
// Apply owner human player model?
if (get_pcvar_num(cvar_owner_models_human_player) && (get_user_flags(id) & read_flags(g_access_owner_models)))
{
new player_model[PLAYERMODEL_MAX_LENGTH]
ArrayGetString(g_models_owner_human_player, random_num(0, ArraySize(g_models_owner_human_player) - 1), player_model, charsmax(player_model))
cs_set_player_model(id, player_model)
}
// Apply creator human knife model?
if (get_pcvar_num(cvar_creator_models_human_knife) && (get_user_flags(id) & read_flags(g_access_creator_models)))
{
new model[MODEL_MAX_LENGTH]
ArrayGetString(g_models_creator_human_knife, random_num(0, ArraySize(g_models_creator_human_knife) - 1), model, charsmax(model))
cs_set_player_view_model(id, CSW_KNIFE, model)
}
// Apply owner human knife model?
if (get_pcvar_num(cvar_owner_models_human_knife) && (get_user_flags(id) & read_flags(g_access_owner_models)))
{
new model[MODEL_MAX_LENGTH]
ArrayGetString(g_models_owner_human_knife, random_num(0, ArraySize(g_models_owner_human_knife) - 1), model, charsmax(model))
cs_set_player_view_model(id, CSW_KNIFE, model)
}
}