AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   Fix ZP4.3 Vip Models (https://forums.alliedmods.net/showthread.php?t=341385)

mohmemes.dz 01-19-2023 13:51

Fix ZP4.3 Vip Models
 
I Need Help To Fix Problem Please 🙏

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <fun>
#include <xs>
#include <zombieplague>

#define PLUGIN "ViP Models"
#define VERSION "1.0"
#define AUTHOR "Not-By-Me"

// Customization file sections
enum
{
SECTION_NONE = 0,
SECTION_PLAYER_MODELS

cvar_vipmodelshuman = register_cvar("zp_vip_models_human", "1")

// Zombie Classes vars
new Array:g_zclass_modelindex // model indices array

// Customization vars
new Array:model_vip_human, Array:g_modelindex_human,
Array:g_modelindex_vip_human

// Initialize a few dynamically sized arrays (alright, maybe more than just a few...)
model_vip_human = ArrayCreate(32, 1)
g_modelindex_human = ArrayCreate(1, 1)
g_modelindex_vip_human = ArrayCreate(1, 1)
g_zclass_modelindex = ArrayCreate(1, 1)

// Custom player models
for (i = 0; i < ArraySize(model_vip_human); i++)
{
ArrayGetString(model_vip_human, i, buffer, charsmax(buffer))
format(buffer, charsmax(buffer), "models/player/%s/%s.mdl", buffer, buffer)
ArrayPushCell(g_modelindex_vip_human, engfunc(EngFunc_PrecacheModel, buffer))
if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, buffer)
if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, buffer)
// Precache modelT.mdl files too
copy(buffer[strlen(buffer)-4], charsmax(buffer) - (strlen(buffer)-4), "T.mdl")
if (file_exists(buffer)) engfunc(EngFunc_PrecacheModel, buffer)
}

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

// Switch to CT if spawning mid-round
if (!g_newround && fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
{
remove_task(id+TASK_TEAM)
fm_cs_set_user_team(id, FM_CS_TEAM_CT)
fm_user_team_update(id)
}

// Custom models stuff
static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
already_has_model = false

if (g_handle_models_on_separate_ent)
{
// Set the right model
if (get_pcvar_num(cvar_vipmodelshuman) && (get_user_flags(id) & ADMIN_KICK))
{
iRand = random_num(0, ArraySize(model_vip_human) - 1)
ArrayGetString(model_vip_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_vip_human, iRand))
}
else
{
iRand = random_num(0, ArraySize(model_human) - 1)
ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
}

// Set model on player model entity
fm_set_playermodel_ent(id)

// Remove glow on player model entity
fm_set_rendering(g_ent_playermodel[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 (get_pcvar_num(cvar_vipmodelshuman) && (get_user_flags(id) & ADMIN_KICK))
{
size = ArraySize(model_vip_human)
for (i = 0; i < size; i++)
{
ArrayGetString(model_vip_human, i, tempmodel, charsmax(tempmodel))
if (equal(currentmodel, tempmodel)) already_has_model = true
}

if (!already_has_model)
{
iRand = random_num(0, size - 1)
ArrayGetString(model_vip_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
ArrayGetString(model_vip_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_vip_human, iRand))
}
}
else
{
size = ArraySize(model_human)
for (i = 0; i < size; i++)
{
ArrayGetString(model_human, i, tempmodel, charsmax(tempmodel))
if (equal(currentmodel, tempmodel)) already_has_model = true
}

if (!already_has_model)
{
iRand = random_num(0, size - 1)
ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
}
}

// Need to change the model?
if (!already_has_model)
{
// 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)
}

// Remove glow
fm_set_rendering(id)
}

case SECTION_PLAYER_MODELS:
{
if (equal(key, "VIP HUMAN"))
{
// Parse models
while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
{
// Trim spaces
trim(key)
trim(value)

// Add to models array
ArrayPushString(model_admin_human, key)
}
}
else if (equal(key, "FORCE CONSISTENCY"))
g_force_consistency = str_to_num(value)
else if (equal(key, "SAME MODELS FOR ALL"))
g_same_models_for_all = str_to_num(value)
else if (g_same_models_for_all && equal(key, "ZOMBIE"))
{
// Parse models
while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
{
// Trim spaces
trim(key)
trim(value)

// Add to models array
ArrayPushString(g_zclass_playermodel, key)

// Precache model and retrieve its modelindex
formatex(linedata, charsmax(linedata), "models/player/%s/%s.mdl", key, key)
ArrayPushCell(g_zclass_modelindex, engfunc(EngFunc_PrecacheModel, linedata))
if (g_force_consistency == 1) force_unmodified(force_model_samebounds, {0,0,0}, {0,0,0}, linedata)
if (g_force_consistency == 2) force_unmodified(force_exactfile, {0,0,0}, {0,0,0}, linedata)
// Precache modelT.mdl files too
copy(linedata[strlen(linedata)-4], charsmax(linedata) - (strlen(linedata)-4), "T.mdl")
if (file_exists(linedata)) engfunc(EngFunc_PrecacheModel, linedata)
}
}
}


All times are GMT -4. The time now is 10:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.