Code: Select all
#include <zombie_escape>
#define PLUGIN "[ZE] Nemesis Model & Knife"
#define VERSION "1.0"
#define AUTHOR "Kaya Gaming"
// Set Model
#define OFFSET_MODELINDEX 491
new g_model_locked[33]
#define CONFIG_FILE "nemesis_models.ini"
native ze_is_nemesis_round(id)
new Array:nemesis_zombie_model,Array:nemesis_zombie_modelindex,Array:nemesis_zombie_claw
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue")
register_event("CurWeapon", "event_CurWeapon", "be", "1=1")
}
public fw_SetClientKeyValue(id, const infobuffer[], const key[])
{
if(g_model_locked[id] && equal(key, "model"))
return FMRES_SUPERCEDE
return FMRES_HANDLED
}
public plugin_precache()
{
nemesis_zombie_model = ArrayCreate(64, 1)
nemesis_zombie_modelindex = ArrayCreate(1, 1)
nemesis_zombie_claw = ArrayCreate(64, 1)
new i, buffer[128], temp_string[256]
for(i = 0; i < ArraySize(nemesis_zombie_model); i++)
{
ArrayGetString(nemesis_zombie_model, i, temp_string, sizeof(temp_string))
formatex(buffer, sizeof(buffer), "models/player/%s/%s.mdl", temp_string, temp_string)
ArrayPushCell(nemesis_zombie_modelindex, precache_model(buffer))
}
for(i = 0; i < ArraySize(nemesis_zombie_claw); i++)
{
ArrayGetString(nemesis_zombie_claw, i, temp_string, sizeof(temp_string))
precache_model(temp_string)
}
models_config()
}
public models_config()
{
// Build customization file path
new path[64]
get_configsdir(path, charsmax(path))
format(path, charsmax(path), "%s/%s", path, CONFIG_FILE)
// File not present
if (!file_exists(path))
{
new error[100]
formatex(error, charsmax(error), "[ZE] Can't Load Config File: %s!", path)
set_fail_state(error)
return;
}
// Set up some vars to hold parsing info
new linedata[1024], key[64], value[960], section
// 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 1: // Model
{
if(equal(key, "NEMESIS_ZOMBIE_MODEL"))
{
// Parse sounds
while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
{
// Trim spaces
trim(key)
trim(value)
// Add to sounds array
ArrayPushString(nemesis_zombie_model, key)
}
}
else if(equal(key, "NEMESIS_ZOMBIE_CLAW"))
{
// Parse sounds
while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
{
// Trim spaces
trim(key)
trim(value)
// Add to sounds array
ArrayPushString(nemesis_zombie_claw, key)
}
}
}
}
}
if (file) fclose(file)
}
public ze_user_infected(iVictim,iInfector)
{
if(ze_is_nemesis_round(iVictim))
{
set_user_nemesis(iVictim)
}
}
public set_user_nemesis(id)
{
if(!is_user_alive(id) || !ze_is_user_zombie(id))
return
static temp_string[128], random1
if(ze_is_nemesis_round(id))
{
random1 = random_num(0, ArraySize(nemesis_zombie_model) - 1)
ArrayGetString(nemesis_zombie_model, random1, temp_string, sizeof(temp_string))
fm_cs_set_user_model(id, temp_string)
#if defined SET_MODELINDEX_OFFSET
static modelindex
modelindex = ArrayGetCell(nemesis_zombie_modelindex, random1)
fm_cs_set_user_model_index(id, modelindex)
#endif
}
}
public event_CurWeapon(id)
{
if(!is_user_alive(id) || !ze_is_user_zombie(id))
return
if(ze_is_nemesis_round(id) && ze_is_user_zombie(id) && get_user_weapon(id) == CSW_KNIFE)
{
static temp_string[128]
ArrayGetString(nemesis_zombie_claw, random_num(0, ArraySize(nemesis_zombie_claw) - 1), temp_string, sizeof(temp_string))
set_pev(id, pev_viewmodel2, temp_string)
set_pev(id, pev_weaponmodel2, "")
}
}
stock fm_cs_set_user_model(id, const model[])
{
g_model_locked[id] = 0
engfunc(EngFunc_SetClientKeyValue, id, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", model)
g_model_locked[id] = 1
}
stock fm_cs_set_user_model_index(id, model_index)
{
if (pev_valid(id) != PDATA_SAFE)
return;
set_pdata_int(id, OFFSET_MODELINDEX, model_index)
}