|
发表于 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[33]
- new bool:HighPlayer[33]
- // 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[killerId])
- return PLUGIN_CONTINUE
-
- UpdateFrags(killerId)
-
- return PLUGIN_CONTINUE
- }
- public EventJoinedTeam(){
-
- new log[64],username[32],userid,authid[32],oldteam[32],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[id] = false
- sZpingNum[id]=0
- id=get_user_index(username)
- new param[1]
- param[0] = id
- set_task(10.0, "CheckPing", 123+id,param, _, "a", 6)//每10秒检查一次!只检查6次!来确认玩家的ping是否是高于所定义的ping
- return PLUGIN_CONTINUE;
- }
- public CheckPing(param[]){
-
- new id = param[0]
- if(is_user_connected(id)){
-
- new ping, loss
- get_user_ping(id, ping, loss)
- if (ping >= High_ping)
- sZpingNum[id]++
- else if(ping < High_ping)
- sZpingNum[id]--
- if(sZpingNum[id] > ActionTimes)
- HighPlayer[id] = true
- }
- }
- public client_disconnect(id){
- HighPlayer[id] = false
- sZpingNum[id]=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);
- }
复制代码 这样再试下,我这里没条件测试 |
|