- 听众
- 收听
- 积分
- 2462
- 主题
- 回帖
- 0
- 精华
注册时间2006-9-30
最后登录1970-1-1
该用户从未签到
|
发表于 2009-5-26 17:18:44
|
显示全部楼层
/*
Player Model Changer
req: amxx 1.8.0 or later
thx to MeRcyLeZZ for the great tutorial!
*/
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
enum
{
OTHERS,
DEF_T,//普通玩家 T
DEF_CT,//普通玩家 CT
VIP_T,
VIP_CT,
OP_T,
OP_CT,
BOSS_T,
BOSS_CT
}
#define TID 5354
#define TID2 5999
new model[9][32]
new usertype[33]
new bool:has_custom_model[33]
new Float: interval_counter
public plugin_init()
{
register_plugin("playermdl", "1.22", "nooby")
RegisterHam(Ham_Spawn, "player", "fwdPlayerSpawn", 1)
register_forward(FM_SetClientKeyValue,"fwdSetClientKeyValue")
register_forward(FM_ClientUserInfoChanged,"fwdClientUserInfoChanged")
register_logevent("eventRound_End", 2, "1=Round_End")
return PLUGIN_CONTINUE
}
public eventRound_End()
{
interval_counter = 0.0
}
public client_putinserver(id)
{
client_cmd(id, "cl_minmodels 0")
return PLUGIN_CONTINUE
}
public plugin_precache()
{
model[DEF_T] = "t1"
model[DEF_CT] = "ct1"
model[VIP_T] = "t2"
model[VIP_CT] = "ct2"
model[OP_T] = "t3"
model[OP_CT] = "ct3"
model[BOSS_T] = "t4"
model[BOSS_CT] = "ct4"
precache_model("models/player/crazy/t1.mdl")
precache_model("models/player/crazy/ct1.mdl")
precache_model("models/player/crazy/t2.mdl")
precache_model("models/player/crazy/ct2.mdl")
precache_model("models/player/crazy/t3.mdl")
precache_model("models/player/crazy/ct3.mdl")
precache_model("models/player/crazy/t4.mdl")
precache_model("models/player/crazy/ct4.mdl")
return PLUGIN_CONTINUE
}
stock get_usertype(id)
{
new is_ct
if (cs_get_user_team(id) == CS_TEAM_CT)
{
is_ct = 1
}
new uflag = get_user_flags(id)
if (uflag & ADMIN_LEVEL_C)
{
return BOSS_T + is_ct
}
else if (uflag & ADMIN_RCON)
{
return OP_T + is_ct
}
static name[32]
get_user_info(id, "name", name, 31)
if (contain(name, "-=CrAzY=-") != -1)
{
return VIP_T + is_ct
}
else if (uflag & ADMIN_USER)
{
return DEF_T + is_ct
}
return OTHERS
}
public fwdPlayerSpawn(id, level, cid)
{
if (task_exists(id + TID))
{
remove_task(id + TID)
}
if (is_user_bot(id) || is_user_hltv(id) || !is_user_connected(id))
return
new utype
usertype[id] = utype = get_usertype(id)
if (utype == OTHERS)
fm_reset_user_model(id)
else
{
new currentmodel[32]
fm_get_user_model(id, currentmodel, sizeof currentmodel - 1)
if(!equal(currentmodel, model[utype]))
{
set_task(1.0 + interval_counter, "task_set_model", id + TID)
interval_counter += 0.2
}
}
return
}
public client_disconnect(id)
{
if (task_exists(id + TID))
{
remove_task(id + TID)
}
if (task_exists(id + TID2))
{
remove_task(id + TID2)
}
has_custom_model[id] = false
}
public fwdClientUserInfoChanged(id, infobuffer)
{
if (!has_custom_model[id] || is_user_bot(id) || is_user_hltv(id))
return FMRES_IGNORED
new currentmodel[32]
fm_get_user_model(id, currentmodel, sizeof currentmodel - 1)
if (!equal(currentmodel, model[usertype[id]]))
fm_set_user_model(id, model[usertype[id]])
return FMRES_IGNORED
}
public fwdSetClientKeyValue(id, infobuffer, key[], value[])
{
if (has_custom_model[id] && equal(key, "model"))
{
return FMRES_SUPERCEDE
}
if (id && equal(key, "name") && is_user_connected(id))
{
if (task_exists(id + TID2))
{
remove_task(id + TID2)
}
set_task(0.2, "task_check_model", id + TID2)
}
return FMRES_IGNORED
}
public task_check_model(taskid)
{
new id = taskid - TID2
if (!is_user_connected(id) || !is_user_alive(id))
{
return
}
new utype
usertype[id] = utype = get_usertype(id)
new currentmodel[32]
fm_get_user_model(id, currentmodel, sizeof currentmodel - 1)
if(!equal(currentmodel, model[utype]))
{
if (task_exists(id + TID))
{
remove_task(id + TID)
}
set_task(1.0 + interval_counter, "task_set_model", id + TID)
interval_counter += 0.3
}
}
public task_set_model(taskid)
{
if (interval_counter > 3.0)
{
interval_counter = 0.0
}
new id = taskid - TID
fm_set_user_model(id, model[usertype[id]])
}
stock fm_set_user_model(player, modelname[])
{
engfunc(EngFunc_SetClientKeyValue, player, engfunc(EngFunc_GetInfoKeyBuffer, player), "model", modelname)
has_custom_model[player] = true
}
stock fm_get_user_model(player, model[], len)
{
engfunc(EngFunc_InfoKeyValue, engfunc(EngFunc_GetInfoKeyBuffer, player), "model", model, len)
}
stock fm_reset_user_model(player)
{
dllfunc(DLLFunc_ClientUserInfoChanged, player, engfunc(EngFunc_GetInfoKeyBuffer, player))
has_custom_model[player] = false
} |
评分
-
查看全部评分
|