#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
// Настройки //
// Имя модели
new const MODEL[] = "model";
// Права
const ADMIN = ADMIN_BAN;
const VIP = ADMIN_LEVEL_H;
// Настройки //
#define Bit_Set(%0,%1) ((%0) |= (1 << (%1)))
#define Bit_Clear(%0,%1) ((%0) &= ~(1 << (%1)))
#define Bit_Toggle(%0,%1) ((%0) ^= (1 << (%1)))
#define IsSetBit(%0,%1) ((%0) & (1 << (%1)))
new g_szPlayerModel[33][sizeof MODEL];
new g_bitVIPaccess,
g_bitADMINaccess,
g_bitModelInstalled;
public plugin_precache()
{
new szBuffer[256];
formatex(szBuffer, charsmax(szBuffer), "models/player/%s/%s.mdl", MODEL, MODEL);
if(file_exists(szBuffer))
{
precache_model(szBuffer);
}
else
{
set_fail_state("ERROR! File '%s' not found!", szBuffer);
}
}
public plugin_init()
{
register_plugin("ADMIN&VIP Sub-Models", "0.0.1", "wopox1337");
RegisterHam(Ham_Spawn, "player", "CBasePlayer_Spawn", .Post = true);
register_forward(FM_SetClientKeyValue, "FM_SetClientKeyValue_Pre", ._post=false);
}
public client_putinserver(iPlayerId)
{
static szFlags;
szFlags = get_user_flags(iPlayerId);
if(szFlags & ADMIN)
{
Bit_Set(g_bitADMINaccess,iPlayerId);
Bit_Set(g_bitModelInstalled,iPlayerId);
}
if(szFlags & VIP)
{
Bit_Set(g_bitVIPaccess,iPlayerId);
Bit_Set(g_bitModelInstalled,iPlayerId);
}
}
public client_disconnected(iPlayerId)
{
Bit_Clear(g_bitADMINaccess,iPlayerId);
Bit_Clear(g_bitVIPaccess,iPlayerId);
Bit_Clear(g_bitModelInstalled,iPlayerId);
}
public CBasePlayer_Spawn(iPlayerId)
{
if(IsSetBit(g_bitModelInstalled,iPlayerId))
{
fm_set_user_model(iPlayerId, MODEL);
}
}
enum TEAMSBODY
{
TEAM_CT,
TEAM_T
}
enum SKINS
{
SKIN_ADMIN,
SKIN_VIP
}
stock fm_set_user_model(iPlayerId, const szModelName[])
{
if(IsSetBit(g_bitModelInstalled,iPlayerId))
{
engfunc(EngFunc_SetClientKeyValue, iPlayerId, engfunc(EngFunc_GetInfoKeyBuffer, iPlayerId), "model", szModelName);
copy(g_szPlayerModel[iPlayerId], charsmax(g_szPlayerModel[]), szModelName);
static szTeamName[2];
get_user_team(iPlayerId, szTeamName, charsmax(szTeamName));
static bool:bTeam_T, bool:bVIP;
switch(szTeamName[0])
{
case 'T': bTeam_T = true;
case 'C': bTeam_T = false;
case 'U', 'S': return;
}
if(IsSetBit(g_bitADMINaccess,iPlayerId))
{
bVIP = false;
}
else /*if(IsSetBit(g_bitVIPaccess,iPlayerId))*/
{
bVIP = true;
}
/*
log_amx("id: %d,Team: %s, VIP: %s",
iPlayerId,
bTeam_T ? "T" : "CT",
bVIP ? "Yes" : "No"
);
*/
SetModels_BodyAndSkin(
iPlayerId,
.bTeam = bTeam_T,
.bAccess = bVIP
);
}
}
SetModels_BodyAndSkin(iPlayerId, bTeam, bAccess)
{
set_pev(iPlayerId, pev_body, bTeam);
set_pev(iPlayerId, pev_skin, bAccess);
}
stock fm_get_user_model(id, szModel[], szLen)
{
engfunc(EngFunc_InfoKeyValue, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", szModel, szLen);
}
public FM_SetClientKeyValue_Pre(id, const szInfobuffer[], const szKey[])
{
if(IsSetBit(g_bitModelInstalled,id) && equal(szKey, "model"))
{
static szCurrentModel[sizeof MODEL];
fm_get_user_model(id, szCurrentModel, charsmax(szCurrentModel));
if(!equal(szCurrentModel, g_szPlayerModel[id]))
{
fm_set_user_model(id, g_szPlayerModel[id]);
}
fm_set_user_model(id, MODEL);
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}