[已解决]点通的高手前辈们,我写的插件错在哪里,谢谢
本帖最后由 epic 于 2010-2-3 10:43 编辑在baili1258的帮助下,我解决了这个问题,问题就在于我对于CAVR值的调用没有用到正确的方法,把代码中的
public CheckPing(id)
{
new p, l
get_user_ping(id, p, l)
if (p > High_ping)
{
new frags
frags = get_user_frags(id)
set_user_frags(id, frags+Extra_frags)
}
return PLUGIN_CONTINUE
}
改为:
public CheckPing(killerId)
{
new p, l
get_user_ping(killerId, p, l)
if (p > get_pcvar_num(High_ping))
{
new frags
frags = get_user_frags(killerId)
set_user_frags(killerId, frags + get_pcvar_num(Extra_frags))
}
return PLUGIN_CONTINUE
}
即可
当然把CVAR改为定义全局变量,即#define也是可以的
以上彩字部分,为epic于2010.2.3写
点通的各位朋友。大家好!
我想做一个将PING值折算成战绩的插件,即:当一位玩家的PING值高于一定数值时(比如高于100),那么这时他杀一个人将得到2个战绩(也就是frags),这个插件的好处是,对一些高PING的CS玩家会公平一些,因为那些高PING却坚持玩CS的人都是爱CS的,所以想做这样的一个插件献给那些高PING的CS玩家
插件源码我写好了,可以compile,而且在CS插件列表中显示正在运行,可是却没有产生我希望发生的效果,所以请点通里的高手前辈们,帮我指点一下,具体我哪里写错了?谢谢了#include <amxmodx>
#include <fun>
#define PLUGIN"Convert ping to frags"
#define VERSION "0.1"
#define AUTHOR"epic"
new High_ping
new Extra_frags
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "DeathEvent", "a")
High_ping = register_cvar( "Convertpingtofrags_Highping", "100" )
Extra_frags = register_cvar( "Convertpingtofrags_Extrafrags", "2" )
}
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
CheckPing(killerId)
return PLUGIN_CONTINUE
}
public CheckPing(id)
{
new p, l
get_user_ping(id, p, l)
if (p > High_ping)
{
new frags
frags = get_user_frags(id)
set_user_frags(id, frags+Extra_frags)
}
return PLUGIN_CONTINUE
} 本帖最后由 baili1258 于 2010-1-12 14:04 编辑
#include <amxmodx>
#include <fun>
#define PLUGIN"Convert ping to frags"
#define VERSION "0.1"
#define AUTHOR"epic"
new High_ping
new Extra_frags
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "DeathEvent", "a")
High_ping = register_cvar( "Convertpingtofrags_Highping", "100" )
Extra_frags = register_cvar( "Convertpingtofrags_Extrafrags", "2" )
}
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
CheckPing(killerId)
return PLUGIN_CONTINUE
}
public CheckPing(id)
{
new ping, loss
get_user_ping(id, ping, loss)
if (ping >= High_ping)
{
set_user_frags(id, get_user_frags(id)+Extra_frags)
}else{
console_print(0, "ping:%d",ping) //测试下看能正确获得用户ping值不!
}
}你这样试下,看看能不能这确获得ping值 好的,我晚上组织朋友一起测试一下,谢谢
我感觉也是最后一个return PLUGIN_CONTINUE有点问题 我刚测试了,为了方便测试我先把High_ping 的值改为2了,也就是说只要我的ping大于2 就应该有效果
可是,战绩还是没有额外的效果出现...console里倒是有ping值反应,如图:
那我再看下 #include <amxmodx>
#include <fakemeta>
#define PLUGIN"Convert ping to frags"
#define VERSION "0.1"
#define AUTHOR"epic"
new High_ping
new Extra_frags
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "DeathEvent", "a")
High_ping = register_cvar( "Convertpingtofrags_Highping", "10" )
Extra_frags = register_cvar( "Convertpingtofrags_Extrafrags", "2" )
}
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
CheckPing(killerId)
return PLUGIN_CONTINUE
}
public CheckPing(id)
{
new ping, loss
get_user_ping(id, ping, loss)
if (ping >= High_ping)
{
set_pev(id, pev_frags, float(pev(id, pev_frags) + Extra_frags))
}else{
console_print(0, "ping:%d",ping)
}
} 好的,晚上用fakemeta再测试一下
我昨天晚上是自己建的服,然后用服务器一样的IP进的服,会不会影响测试呢?是不是应该找一个与服务器IP不同的人来帮我测试。。。昨天没找到帮我测试的人- -
而且是不是我设置成ping大于2就加战绩,这里的2ping是不是过底也会造成影响呢?
今天晚上再测试一下,先谢谢baili1258 了 #include <amxmodx>
#include <fakemeta>
#define PLUGIN"Convert ping to frags"
#define VERSION "0.1"
#define AUTHOR"epic"
new High_ping
new Extra_frags
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg", "DeathEvent", "a")
High_ping = register_cvar( "Convertpingtofrags_Highping", "10" )
Extra_frags = register_cvar( "Convertpingtofrags_Extrafrags", "2" )
}
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
CheckPing(killerId)
return PLUGIN_CONTINUE
}
public CheckPing(id)
{
new ping, loss
get_user_ping(id, ping, loss)
if (ping >= High_ping)
{
set_pev(id, pev_frags, float(pev(id, pev_frags) + Extra_frags))
client_print ( id, print_chat,"frags:%d",pev(id, pev_frags))
}else{
console_print(0, "ping:%d",ping)
}
}
如果上面的还不行的话,这样试下,看下获得杀人数,是否和得分版的一样!
不行的话,估计要更新一下得分版 好的,昨天晚上想这个问题,想得我都睡不觉了,哈哈
想不明白的就是,既然ping已经大于2了,为什么不set_pev(id, pev_frags, float(pev(id, pev_frags) + Extra_frags)),反而去执行console_print(0, "ping:%d",ping),吼吼,现在仍然没想明白 #include <amxmodx>
#include <fakemeta>
#define PLUGIN"Convert ping to frags"
#define VERSION "0.1"
#define AUTHOR"epic"
new High_ping
new Extra_frags
// 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")
High_ping = register_cvar( "Convertpingtofrags_Highping", "10" )
Extra_frags = register_cvar( "Convertpingtofrags_Extrafrags", "2" )
}
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
CheckPing(killerId)
return PLUGIN_CONTINUE
}
public CheckPing(id)
{
new ping, loss
get_user_ping(id, ping, loss)
if (ping >= High_ping)
{
set_pev(id, pev_frags, float(pev(id, pev_frags) + Extra_frags))
//client_print ( id, print_chat,"frags:%d",pev(id, pev_frags))
// update scoreboard
message_begin(MSG_BROADCAST,get_user_msgid("ScoreInfo"));
write_byte(id);
write_short(pev(id, pev_frags));
write_short(fm_get_user_deaths(id));
write_short(0);
write_short(fm_get_user_team(id));
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);
}
试试这个吧
应该行的