Здравствуйте, сорри что поднимаю древние темы, гугл сюда приводит.
Дайте пожалуйста пример смены модели игрока через fakemeta
Это так как описано в статье
Вы должны зарегистрироваться, чтобы видеть ссылки. первый вариант.
Через cs_set_user_model и через энтити я попробовал, это не подходит.
1. cs_set_user_model - если менять так, то не работает hltv hud (программа для просмотра демок с отображением хэлсбаров игроков)
2. "Способ №2 отдельные энтити" - если скрывать модель и делать отдельные энтити, клиенты жалуются на низкий фпс.
Дайте плиз полноценный пример (который можно сразу откомпилить и он будет работать) смены модели игрока через fakemeta, можно по команде в чате например, не важно.
У меня самостоятельно не получается написать по тому что есть в статье (и потому что я нуб).
ps.
#include <amxmodx>
#include <fakemeta>
#define PLUGIN "Give Model"
#define VERSION "1.0"
#define AUTHOR "Stimul"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say /model", "CmdGiveModel");
}
public CmdGiveModel(id)
{
fm_set_user_model(id, "my_model");
}
stock fm_set_user_model(index, const model[])
{
engfunc(EngFunc_SetClientKeyValue, index, engfunc(EngFunc_GetInfoKeyBuffer, index), "model", model);
}
этот код не работает, (рехлдс 3.10.0.759-dev амх 1.9.0.5294), так же не понимаю где тут прикэш и почему все идет по id, а в стоке index
Добавлено спустя 1 час 5 минут 11 секунд:Вот примеры, которыми я пользовался:
1) cs_set_user_model - за пример взят код из lady_admin.sma
#include <amxmisc>
#include <cstrike>
public plugin_init()
{
register_plugin("CW_Model", "1.0", "null")
register_event("ResetHUD", "player_spawn_model", "b")
return PLUGIN_CONTINUE
}
public plugin_precache()
{
precache_model("models/player/model_te/model_te.mdl")
precache_model("models/player/model_ct/model_ct.mdl")
return PLUGIN_CONTINUE
}
public player_spawn_model(id)
{
set_task(0.1, "resetModel", id)
}
public resetModel(id)
{
new CsTeams:userTeam = cs_get_user_team(id)
if (userTeam == CS_TEAM_T)
{
cs_set_user_model(id, "model_te")
}
else
if(userTeam == CS_TEAM_CT)
{
cs_set_user_model(id, "model_ct")
}
else
{
cs_reset_user_model(id)
}
return PLUGIN_CONTINUE
}
2) отдельные энтити - за пример взят код из статьи
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
new const MODEL_te[] = "model_te"
new const MODEL_ct[] = "model_ct"
new const PLAYERMODEL_CLASSNAME[] = "ent_playermodel"
new const WEAPONMODEL_CLASSNAME[] = "ent_weaponmodel"
new g_player_model[33][32]
new g_ent_playermodel[33]
new g_ent_weaponmodel[33]
new g_player_te[33]
public plugin_precache()
{
new modelpath_te[100]
formatex( modelpath_te, charsmax( modelpath_te ), "models/player/%s/%s.mdl", MODEL_te, MODEL_te )
engfunc( EngFunc_PrecacheModel, modelpath_te )
new modelpath_ct[100]
formatex( modelpath_ct, charsmax( modelpath_ct ), "models/player/%s/%s.mdl", MODEL_ct, MODEL_ct )
engfunc( EngFunc_PrecacheModel, modelpath_ct )
}
public plugin_init()
{
register_plugin( "cwmodel", "1.0", "null" )
RegisterHam( Ham_Spawn, "player", "fw_PlayerSpawn", 1 )
register_event( "CurWeapon", "event_curweapon", "be", "1=1" )
}
public fw_PlayerSpawn( id )
{
// Not alive or didn't join a team yet
if ( !is_user_alive( id ) || !cs_get_user_team( id ) )
return;
// Set to zombie if on Terrorist team
g_player_te[id] = cs_get_user_team( id ) == CS_TEAM_T ? true : false;
// Check if the player is a zombie
if ( g_player_te[id] )
{
// Store our custom model in g_player_model[id]
copy( g_player_model[id], charsmax( g_player_model[] ), MODEL_te )
// Set the model on our playermodel entity
fm_set_playermodel_ent_te( id, g_player_model[id] )
}
else
{
// Store our custom model in g_player_model[id]
copy( g_player_model[id], charsmax( g_player_model[] ), MODEL_ct )
// Set the model on our playermodel entity
fm_set_playermodel_ent_ct( id, g_player_model[id] )
}
}
public event_curweapon( id )
{
// Check if the player is using a custom player model
if ( fm_has_custom_model( id ) )
{
// Update weapon model on entity
fm_set_weaponmodel_ent( id )
}
}
public client_disconnected( id )
{
// Check if the player was using a custom player model
if ( fm_has_custom_model( id ) )
{
// Remove custom entities
fm_remove_model_ents( id )
}
}
stock fm_set_playermodel_ent_te( id, const modelname[] )
{
// Make original player entity invisible
set_pev( id, pev_rendermode, kRenderTransTexture )
// This is not 0 because it would hide the shadow and some effects when firing weapons
set_pev( id, pev_renderamt, 0.0 )
// Since we're passing the short model name to the function
// we need to make the full path out of it
static modelpath_te[100]
formatex( modelpath_te, charsmax( modelpath_te ), "models/player/model_te/model_te.mdl", modelname )
// Check if the entity assigned to this player exists
if ( !pev_valid( g_ent_playermodel[id] ) )
{
// If it doesn't, proceed to create a new one
g_ent_playermodel[id] = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) )
// If it failed to create for some reason, at least this will prevent further "Invalid entity" errors...
if ( !pev_valid( g_ent_playermodel[id] ) ) return;
// Set its classname
set_pev( g_ent_playermodel[id], pev_classname, PLAYERMODEL_CLASSNAME )
// Make it follow the player
set_pev( g_ent_playermodel[id], pev_movetype, MOVETYPE_FOLLOW )
set_pev( g_ent_playermodel[id], pev_aiment, id )
set_pev( g_ent_playermodel[id], pev_owner, id )
}
// Entity exists now, set its model
engfunc( EngFunc_SetModel, g_ent_playermodel[id], modelpath_te )
}
stock fm_set_playermodel_ent_ct( id, const modelname[] )
{
// Make original player entity invisible
set_pev( id, pev_rendermode, kRenderTransTexture )
// This is not 0 because it would hide the shadow and some effects when firing weapons
set_pev( id, pev_renderamt, 0.0 )
// Since we're passing the short model name to the function
// we need to make the full path out of it
static modelpath_ct[100]
formatex( modelpath_ct, charsmax( modelpath_ct ), "models/player/model_ct/model_ct.mdl", modelname )
// Check if the entity assigned to this player exists
if ( !pev_valid( g_ent_playermodel[id] ) )
{
// If it doesn't, proceed to create a new one
g_ent_playermodel[id] = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) )
// If it failed to create for some reason, at least this will prevent further "Invalid entity" errors...
if ( !pev_valid( g_ent_playermodel[id] ) ) return;
// Set its classname
set_pev( g_ent_playermodel[id], pev_classname, PLAYERMODEL_CLASSNAME )
// Make it follow the player
set_pev( g_ent_playermodel[id], pev_movetype, MOVETYPE_FOLLOW )
set_pev( g_ent_playermodel[id], pev_aiment, id )
set_pev( g_ent_playermodel[id], pev_owner, id )
}
// Entity exists now, set its model
engfunc( EngFunc_SetModel, g_ent_playermodel[id], modelpath_ct )
}
stock fm_has_custom_model( id )
{
return pev_valid( g_ent_playermodel[id] ) ? true : false;
}
stock fm_set_weaponmodel_ent( id )
{
// Get the player's p_ weapon model
static model[100]
pev( id, pev_weaponmodel2, model, charsmax( model ) )
// Check if the entity assigned to this player exists
if ( !pev_valid(g_ent_weaponmodel[id]) )
{
// If it doesn't, proceed to create a new one
g_ent_weaponmodel[id] = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) )
// If it failed to create for some reason, at least this will prevent further "Invalid entity" errors...
if ( !pev_valid( g_ent_weaponmodel[id] ) ) return;
// Set its classname
set_pev( g_ent_weaponmodel[id], pev_classname, WEAPONMODEL_CLASSNAME )
// Make it follow the player
set_pev( g_ent_weaponmodel[id], pev_movetype, MOVETYPE_FOLLOW )
set_pev( g_ent_weaponmodel[id], pev_aiment, id )
set_pev( g_ent_weaponmodel[id], pev_owner, id )
}
// Entity exists now, set its model
engfunc( EngFunc_SetModel, g_ent_weaponmodel[id], model )
}
stock fm_remove_model_ents( id )
{
// Make the player visible again
set_pev( id, pev_rendermode, kRenderNormal )
// Remove "playermodel" ent if present
if ( pev_valid( g_ent_playermodel[id] ) )
{
engfunc( EngFunc_RemoveEntity, g_ent_playermodel[id] )
g_ent_playermodel[id] = 0
}
// Remove "weaponmodel" ent if present
if ( pev_valid( g_ent_weaponmodel[id] ) )
{
engfunc( EngFunc_RemoveEntity, g_ent_weaponmodel[id] )
g_ent_weaponmodel[id] = 0
}
}
Не знаю на сколько тут все грамотно и адекватно, но работает.