baili1258
发表于 2010-1-13 12:02:53
其实我觉得这样写好像是错误的...
被你弄混了
我等下重新写个吧
epic
发表于 2010-1-13 12:11:39
那太感谢了
baili1258
发表于 2010-1-13 15:07:38
#include <amxmodx>
#include <fakemeta>
#define PLUGIN"Convert ping to frags"
#define VERSION "0.1"
#define AUTHOR"epic"
new High_ping
new Extra_frags
new ActionTimes
new sZpingNum
new bool:HighPlayer
// CS Teams
enum
{
CS_TEAM_UNASSIGNED = 0,
CS_TEAM_T,
CS_TEAM_CT,
CS_TEAM_SPECTATOR
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "DeathEvent", "a")
register_logevent("EventJoinedTeam",3,"1=joined team")
High_ping = register_cvar( "Convertpingtofrags_Highping", "10" )
Extra_frags = register_cvar( "Convertpingtofrags_Extrafrags", "2" )
ActionTimes = register_cvar( "sZ_ActionTimes", "3" )
}
public DeathEvent()
{
new victimId = read_data(2)
new killerId = read_data(1)
if (!killerId || killerId==victimId)
return PLUGIN_CONTINUE
if (get_user_team(killerId)==get_user_team(victimId))
return PLUGIN_CONTINUE
if(!HighPlayer)
return PLUGIN_CONTINUE
UpdateFrags(killerId)
return PLUGIN_CONTINUE
}
public EventJoinedTeam(){
new log,username,userid,authid,oldteam,id
read_logargv(0,log,63)
parse_loguser(log,username,31,userid,authid,31,oldteam,31)
if(equali(oldteam,"CT")||equali(oldteam,"TERRORIST")||equali(oldteam,"spectator"))
return PLUGIN_CONTINUE;
HighPlayer = false
sZpingNum=0
id=get_user_index(username)
new param
param = id
set_task(10.0, "CheckPing", 123+id,param, _, "a", 6)//每10秒检查一次!只检查6次!来确认玩家的ping是否是高于所定义的ping
return PLUGIN_CONTINUE;
}
public CheckPing(param[]){
new id = param
if(is_user_connected(id)){
new ping, loss
get_user_ping(id, ping, loss)
if (ping >= High_ping)
sZpingNum++
else if(ping < High_ping)
sZpingNum--
if(sZpingNum > ActionTimes)
HighPlayer = true
}
}
public client_disconnect(id){
HighPlayer = false
sZpingNum=0
}
UpdateFrags(killerId)
{
set_pev(killerId, pev_frags, float(pev(killerId, pev_frags) + Extra_frags))
// Update scoreboard
message_begin(MSG_BROADCAST,get_user_msgid("ScoreInfo"));
write_byte(killerId)
write_short(pev(killerId, pev_frags))
write_short(fm_get_user_deaths(killerId))
write_short(0)
write_short(fm_get_user_team(killerId))
message_end()
}
// Get User Deaths
stock fm_get_user_deaths(id)
{
return get_pdata_int(id, 444, 5);
}
// Get User Team
stock fm_get_user_team(id)
{
return get_pdata_int(id, 114, 5);
}
这样再试下,我这里没条件测试
epic
发表于 2010-1-13 17:37:53
好的,我晚上到家马上测试:handshake
epic
发表于 2010-1-13 23:39:40
可以compile,但是在服务器里测试还是和以前一样,没变化
epic
发表于 2010-2-2 10:35:18
过了这些天,我又看了一下我之前写的代码
我将
High_ping = register_cvar( "Convertpingtofrags_Highping", "100" )
Extra_frags = register_cvar( "Convertpingtofrags_Extrafrags", "2" )
改为全局变量
#define High_ping 100
#define Extra_frags 2
就成功了
哈哈
插件发出来,如我上面所说献给所有高PING却热爱CS的玩家
riee
发表于 2010-2-2 11:00:38
学习中。。。
LittleKu
发表于 2010-2-3 17:19:48
简单看了一下,应该是cvar的用法不熟悉,用手机看,不怎么清楚,还是说一下我的认识,new cvar;
//代码
cvar = register_cvar("amx_cvar", "1")
//然后在代码中这样使用
get_pcvar_num(cvar)
说得不对的地方请指正!
LittleKu
发表于 2010-2-3 17:22:32
用#define是可以,但没有cvar方便!
baili1258
发表于 2010-2-3 17:55:51
嗯
我也忽略这个问题了,看来还是长时间没有碰
又要多学了