[已解决]这个是玩家选择的角色记录到日志
本帖最后由 BliaNe 于 2009-4-10 11:13 编辑插件源码:#include <amxmodx>
#include <cstrike>
new g_inGame
public plugin_init ()
{
register_plugin ("User Role Logging","1.0","MaysWind");
}
public client_disconnect(id)
{
if (!g_inGame)
return
g_inGame = 0
remove_task(id)
}
public client_connect(id)
{
g_inGame = 0
}
public client_putinserver(id)
{
g_inGame = 1
}
public client_infochanged(id)
{
new szTeam, szName, szAuthid, szShortTeam, szRole
new iUserid = get_user_userid(id)
get_user_team(id, szTeam, 15)
get_user_name(id, szName, 31)
get_user_authid(id, szAuthid, 31)
cs_get_user_model(id, szRole, 15)
if (equali(szTeam,"TERRORIST"))
{
copy(szShortTeam,2,"t")
}
else if (equali(szTeam,"CT"))
{
copy(szShortTeam,3,"ct")
}
else
{
copy(szShortTeam,2,"s")
}
if (!equali(szRole,"vip") && !equali(szShortTeam,"s"))
{
log_message("^"%s<%d><%s><%s>^" changed role to ^"#class_%s_%s^"", szName, iUserid, szAuthid, szTeam, szShortTeam, szRole)
}
}DEBUG信息:L 04/10/2009 - 09:41:09: Invalid player 1
L 04/10/2009 - 09:41:09: Displaying debug trace (plugin "User_Role_Logging.amxx")
L 04/10/2009 - 09:41:09: Run time error 10: native error (native "cs_get_user_model")
L 04/10/2009 - 09:41:09: User_Role_Logging.sma::client_infochanged (line 39) native cs_get_user_model(index, model[], len);
cs_get_user_model 的用法没错啊!! 加一个is_user_connected(id) 判断,client_infochanged(id)在玩家未完全进入服务器之前也会触发的。 本帖最后由 BliaNe 于 2009-4-10 11:21 编辑
加一个is_user_connected(id) 判断,client_infochanged(id)在玩家未完全进入服务器之前也会触发的。
zwfgdlc 发表于 2009-4-10 11:07 http://www.dt-club.net/forum/images/common/back.gif
谢谢 zwfgdlc 和 逍遥游
就是这个问题。。 问题解决!!#include <amxmodx>
#include <cstrike>
public plugin_init ()
{
register_plugin ("User Role Logging","1.0","BliaNe");
}
public client_infochanged(id)
{
if (is_user_connected(id))
{
new szTeam, szName, szAuthid, szShortTeam, szRole
new iUserid = get_user_userid(id)
get_user_team(id, szTeam, 15)
get_user_name(id, szName, 31)
get_user_authid(id, szAuthid, 31)
cs_get_user_model(id, szRole, 15)
if (equali(szTeam,"TERRORIST"))
{
copy(szShortTeam,2,"t")
}
else if (equali(szTeam,"CT"))
{
copy(szShortTeam,3,"ct")
}
else
{
copy(szShortTeam,2,"s")
}
if (!equali(szRole,"vip") && !equali(szShortTeam,"s"))
{
log_message("^"%s<%d><%s><%s>^" changed role to ^"#class_%s_%s^"", szName, iUserid, szAuthid, szTeam, szShortTeam, szRole)
}
}
}
页:
[1]