register_native("zp_override_user_model", "native_override_user_model", 1);
...
// Native: zp_override_user_model
public native_override_user_model(id, const newmodel[], modelindex)
{
// ZP disabled
if (!g_pluginenabled)
return false;
if (!is_user_valid_connected(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}
// Strings passed byref
param_convert(2)
// Remove previous tasks
remove_task(id+TASK_MODEL)
// Custom models stuff
static currentmodel[32]
if (g_handle_models_on_separate_ent)
{
// Set the right model
copy(g_playermodel[id], charsmax(g_playermodel[]), newmodel)
if (g_set_modelindex_offset && modelindex) fm_cs_set_user_model_index(id, modelindex)
// Set model on player model entity
fm_set_playermodel_ent(id)
}
else
{
// Get current model for comparing it with the current one
fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
// Set the right model, after checking that we don't already have it
if (!equal(currentmodel, newmodel))
{
copy(g_playermodel[id], charsmax(g_playermodel[]), newmodel)
if (g_set_modelindex_offset && modelindex) fm_cs_set_user_model_index(id, modelindex)
// An additional delay is offset at round start
// since SVC_BAD is more likely to be triggered there
if (g_newround)
set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
else
fm_user_model_update(id+TASK_MODEL)
}
}
return true;
}