想增加一下普通记分牌插件(team_score.amxx)的功能
本帖最后由 Osker Lee 于 2010-12-25 17:29 编辑这是一个普通的记分牌插件(team_score.amxx),功能是显示CT和T的比分,插件的源代码如下:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Team Score"
#define VERSION "1.0"
#define AUTHOR "k1nader"
#define LOADING "^n^t%s v%s, Copyright (C) 2010 by %s^n"
new ct_score, terrorist_score;
new g_connected;
new CT_HUD;
new TR_HUD;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
server_print(LOADING,PLUGIN,VERSION,AUTHOR);
register_event("TeamScore", "team_score", "a");
CT_HUD = CreateHudSyncObj();
TR_HUD = CreateHudSyncObj();
}
public client_putinserver(id)
{
g_connected = true;
new param;
param = id;
set_task(1.0,"iTeamScore",35848+id,param,1,"b");
}
public client_disconnect(id)
g_connected = false;
public iTeamScore(param[])
{
new id = param;
if(!g_connected)
{
remove_task(35848+id);
return PLUGIN_CONTINUE;
}
set_hudmessage(255, 255, 255, -1.0, 0.0, 0, 0.5, 10.0, 0.08, 2.0, -1);
ShowSyncHudMsg(id,CT_HUD,"-= CT [%d] ", ct_score);
set_hudmessage(255, 255, 255, -1.0, 0.0, 0, 0.5, 10.0, 0.08, 2.0, -1);
ShowSyncHudMsg(id,TR_HUD," [%d] TS =-", terrorist_score);
return PLUGIN_CONTINUE;
}
public team_score()
{
new team;
read_data(1,team,31);
if (equal(team,"CT"))
ct_score = read_data(2);
else if (equal(team,"TERRORIST"))
terrorist_score = read_data(2);
}
我想再增加两个功能,一是增加局数显示的功能,二是增加显示双方未阵亡玩家人数的功能,效果如图示。对于第一个功能,貌似增加这句代码就可以了:
ShowSyncHudMsg(id,"%d", terrorist_score+ct_score)
但第二个功能,对于获取双方未阵亡玩家人数的代码就不是很懂了,麻烦高手帮忙修改一下。 // Get Alive CTs -returns number of CTs alive-
fnGetAliveCTs()
{
static iCTs, id
iCTs = 0
for (id = 1; id <= g_maxplayers; id++)
{
if (g_isalive)
{
if (fm_cs_get_user_team(id) == FM_CS_TEAM_CT)
iCTs++
}
}
return iCTs;
}
// Get Alive Ts -returns number of Ts alive-
fnGetAliveTs()
{
static iTs, id
iTs = 0
for (id = 1; id <= g_maxplayers; id++)
{
if (g_isalive)
{
if (fm_cs_get_user_team(id) == FM_CS_TEAM_T)
iTs++
}
}
return iTs;
}
根据僵尸插件
(g_isalive)可以换成get_user_alive(id)
g_maxplayers = get_maxplayers(),或者直接=33的话加多一个判断连接,不过这样可能会卡,建议还是参考一下僵尸插件 本帖最后由 kk阿朗 于 2010-12-25 21:55 编辑
get_ct_or_te(const team)
{
if ( team >2 || team <1 )
return 0;
static iPlayers[ 32 ], iNum;
switch ( team ) {
case 1:get_players( iPlayers, iNum, "ae", "TERRORIST" );
case 2:get_players( iPlayers, iNum, "ae", "CT" );
}
return iNum;
}试试这个
页:
[1]