public native_class_human_register(plugin_id, num_params)
{
new name[32]
get_string(1, name, charsmax(name))
if (strlen(name) < 1)
{
log_error(AMX_ERR_NATIVE, "[ZP] Can't register human class with an empty name")
return ZP_INVALID_HUMAN_CLASS;
}
new index, humanclass_name[32]
for (index = 0; index < g_HumanClassCount; index++)
{
ArrayGetString(g_HumanClassRealName, index, humanclass_name, charsmax(humanclass_name))
if (equali(name, humanclass_name))
{
log_error(AMX_ERR_NATIVE, "[ZP] Human class already registered (%s)", name)
return ZP_INVALID_HUMAN_CLASS;
}
}
new description[201]
get_string(2, description, charsmax(description))
new health = get_param(3)
new armor = get_param(6)
new Float:speed = get_param_f(4)
new Float:gravity = get_param_f(5)
// Load settings from human classes file
new real_name[32]
copy(real_name, charsmax(real_name), name)
ArrayPushString(g_HumanClassRealName, real_name)
// Name
if (!amx_load_setting_string(ZP_HUMANCLASSES_FILE, real_name, "NAME", name, charsmax(name)))
amx_save_setting_string(ZP_HUMANCLASSES_FILE, real_name, "NAME", name)
ArrayPushString(g_HumanClassName, name)
// Description
if (!amx_load_setting_string(ZP_HUMANCLASSES_FILE, real_name, "INFO", description, charsmax(description)))
amx_save_setting_string(ZP_HUMANCLASSES_FILE, real_name, "INFO", description)
ArrayPushString(g_HumanClassDesc, description)
// Models
new Array:class_models = ArrayCreate(32, 1)
amx_load_setting_string_arr(ZP_HUMANCLASSES_FILE, real_name, "MODELS", class_models)
if (ArraySize(class_models) > 0)
{
ArrayPushCell(g_HumanClassModelsFile, true)
// Precache player models
new index, player_model[32], model_path[128]
for (index = 0; index < ArraySize(class_models); index++)
{
ArrayGetString(class_models, 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) // line 432
// 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)
}
}
else
{
ArrayPushCell(g_HumanClassModelsFile, false)
ArrayDestroy(class_models)
amx_save_setting_string(ZP_HUMANCLASSES_FILE, real_name, "MODELS", "")
}
ArrayPushCell(g_HumanClassModelsHandle, class_models)
// Health
if (!amx_load_setting_int(ZP_HUMANCLASSES_FILE, real_name, "HEALTH", health))
amx_save_setting_int(ZP_HUMANCLASSES_FILE, real_name, "HEALTH", health)
ArrayPushCell(g_HumanClassHealth, health)
// Speed
if (!amx_load_setting_float(ZP_HUMANCLASSES_FILE, real_name, "SPEED", speed))
amx_save_setting_float(ZP_HUMANCLASSES_FILE, real_name, "SPEED", speed)
ArrayPushCell(g_HumanClassSpeed, speed)
// Gravity
if (!amx_load_setting_float(ZP_HUMANCLASSES_FILE, real_name, "GRAVITY", gravity))
amx_save_setting_float(ZP_HUMANCLASSES_FILE, real_name, "GRAVITY", gravity)
ArrayPushCell(g_HumanClassGravity, gravity)
// Armor
if (!amx_load_setting_int(ZP_HUMANCLASSES_FILE, real_name, "ARMOR", armor))
amx_save_setting_int(ZP_HUMANCLASSES_FILE, real_name, "ARMOR", armor)
ArrayPushCell(g_HumanClassArmor, armor)
g_HumanClassCount++
return g_HumanClassCount - 1;
}