搜索
查看: 1982|回复: 4

Rulzy老大,又有问题请教,请进,谢谢。

[复制链接]
发表于 2007-6-5 01:16:21 | 显示全部楼层 |阅读模式 来自 中国–广西–柳州–柳北区
就是关于服自动踢人的问题,不知服务器自动踢人算不算玩家client_disconnect,如果算的话
#include <amxmodx>
public plugin_init(){
register_plugin( "restart", "1.0", "yyy");
}
public client_disconnect(){
new count=0;
new maxplayers=get_maxplayers();
for(new i=1;i<=maxplayers;i++)
{
if(is_user_disconnect(i)) count++;
}
if(count>=8)
{
set_hudmessage(0, 200, 0, -1.0, 0.40, 0, 6.0, 6.0, 0.1, 0.1, 1)
show_hudmessage(0,"restart")
set_task(5.0, "rround")
}
}
public rround()
{
server_cmd("sv_restartround 1")
}
这段应该是成立吗?如果成立的话就避免有些玩家被自动踢出以后没进,而又对再进的玩家公平,麻烦了,谢谢。
发表于 2007-6-5 01:22:48 | 显示全部楼层 来自 中国–福建–漳州

回复: Rulzy老大,又有问题请教,请进,谢谢。

这样也是可以的,但要注意一个,你这样,可能会连续执行很多次刷新,加个判断,使用task时,加上taskid,然后在每次判断时先判断此task是否已经存在,如果已经存在,就不用再往下执行了。
回复

使用道具 举报

 楼主| 发表于 2007-6-5 01:57:11 | 显示全部楼层 来自 中国–广西–柳州–柳北区

回复: Rulzy老大,又有问题请教,请进,谢谢。

Post by Rulzy
加个判断,使用task时,加上taskid,然后在每次判断时先判断此task是否已经存在,如果已经存在,就不用再往下执行了。
这不是很清楚,请问可以举例说明一下吗?还有这个插件我想修改一下可没搞好,就是普通玩家进入自动踢出一个没开SXE的玩家,还请帮忙一下,谢谢。
#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
register_plugin("Slots Reservation","1.0","KuaiLn")
register_cvar("amx_kickmode","1")
register_cvar("amx_reservation","1")
register_cvar("amx_netbarip","192.168")
register_cvar("amx_netbarip1","192.168.0.1")
register_cvar("amx_netbarip2","192.168.0.2")
register_cvar("amx_netbarip3","192.168.0.3")
register_cvar("amx_netbarip4","192.168.0.4")
register_cvar("amx_netbarip5","192.168.0.5")

}
public client_authorized(id) {
new userip[17]
new ips[8]
new ips2[16]
new name[33]
new g_amx_netbarip[8]
new g_amx_netbarip1[16]
new g_amx_netbarip2[16]
new g_amx_netbarip3[16]
new g_amx_netbarip4[16]
new g_amx_netbarip5[16]
get_user_ip(id,userip,16,1)
copy(ips,7,userip)
copy(ips2,16,userip)
get_cvar_string("amx_netbarip",g_amx_netbarip,7)
get_cvar_string("amx_netbarip1",g_amx_netbarip1,16)
get_cvar_string("amx_netbarip2",g_amx_netbarip2,16)
get_cvar_string("amx_netbarip3",g_amx_netbarip3,16)
get_cvar_string("amx_netbarip4",g_amx_netbarip4,16)
get_cvar_string("amx_netbarip5",g_amx_netbarip5,16)
get_user_name(id,name,32)

new maxplayers = get_maxplayers()
new players = get_playersnum( 1 )
new limit = maxplayers - get_cvar_num("amx_reservation")
new resType = get_cvar_num( "amx_kickmode" )
new who

if ( players > limit ) //21/20
{
  if ( get_user_flags(id) & ADMIN_RESERVATION || (equali(ips,g_amx_netbarip)) || (equali(ips2,g_amx_netbarip1)) || (equali(ips2,g_amx_netbarip2)) || (equali(ips2,g_amx_netbarip3)) || (equali(ips2,g_amx_netbarip4)) || (equali(ips2,g_amx_netbarip5)))
  {
   set_user_flags(id,read_flags("b"))
   switch(resType) {     
    case 1:
     who = kickFresh()
    case 2:
     who = kickLag()
   }
   if(who)  {
    //new name[32]
       get_user_name( who, name , 31 )
       client_cmd(id,"echo ^"* %s was kicked to free this slot^"" ,name )
      }
   return PLUGIN_CONTINUE
   
  }
   if ( is_user_bot(id) )
   server_cmd("kick #%d 鏈嶅姟鍣ㄤ汉婊?銆€璇风◢鍚庡啀杩涘叆銆?, get_user_userid(id)  )
  else
   server_cmd("kick #%d 鏈嶅姟鍣ㄤ汉婊?銆€璇风◢鍚庡啀杩涘叆銆?, get_user_userid(id)  )
   
  return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
kickLag() {
new who = 0, ping, loss, worst = -1
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; ++i) {
  if ( !is_user_connected(i) && !is_user_connecting(i) )
   continue // not used slot  
  if (get_user_flags(i)&ADMIN_RESERVATION)
   continue // has reservation, skip him
  get_user_ping(i,ping,loss) // get ping
  if ( ping > worst ) {
   worst = ping
   who = i
  }
}
if(who)
  if ( is_user_bot(who) )
   server_cmd("kick #%d銆€[OP閫氶亾] 鏈嶅姟鍣ㄨ涪楂榩ing!銆€璇风◢鍚庡啀杩涘叆銆? , get_user_userid(who)  )
  else
   server_cmd("kick #%d銆€[OP閫氶亾] 鏈嶅姟鍣ㄨ涪楂榩ing!銆€璇风◢鍚庡啀杩涘叆銆? , get_user_userid(who)  )
return who  
}
kickLag() {
new who = 0, ping, loss, worst = -1
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; ++i) {
  if ( !is_user_connected(i) && !is_user_connecting(i) )
   continue // not used slot  
  if (get_user_flags(i)&ADMIN_RESERVATION)
   continue // has reservation, skip him
  get_user_ping(i,ping,loss) // get ping
  if ( ping > worst ) {
   worst = ping
   who = i
  }
}
if(who)
  if ( is_user_bot(who) )
   server_cmd("kick #%d銆€[OP閫氶亾] 鏈嶅姟鍣ㄨ涪楂榩ing!銆€璇风◢鍚庡啀杩涘叆銆? , get_user_userid(who)  )
  else
   server_cmd("kick #%d銆€[OP閫氶亾] 鏈嶅姟鍣ㄨ涪楂榩ing!銆€璇风◢鍚庡啀杩涘叆銆? , get_user_userid(who)  )
return who  
}
kickFresh(param[]) {
new who = 0, itime, shortest = 0x7fffffff
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; ++i){
  if ( !is_user_connected(i) && !is_user_connecting(i) )
   continue // not used slot
  if (get_user_flags(i)&ADMIN_RESERVATION)
   continue // has reservation, skip him
  itime = get_user_time(i) // get user playing time with connection duration  
  if ( shortest > itime ) {
   shortest = itime
   who = i
  }
}
if(who)
  if ( is_user_bot(who) )
   server_cmd("kick #%d [OP閫氶亾] 鏈嶅姟鍣ㄩ鐣橭P閫氶亾!銆€璇风◢鍚庡啀杩涘叆銆?, get_user_userid(who)  )
  else
  {
  new str[11] = "[NO-sXe-I]"
  new dest[11]
  new id = param[0]
  new name[32]
  get_user_name(id, name, 31);
  copy(dest, 10, name)
  if (compare_arrays(dest, str, 10))
  {
   server_cmd("kick #%d [OP閫氶亾] 鏈嶅姟鍣ㄩ鐣橭P閫氶亾!銆€璇风◢鍚庡啀杩涘叆銆?, get_user_userid(who)  )
  }
}
return who
}
bool:compare_arrays(array1[], array2[], size)
{
  new i
  while (i++ < size)
  {
    if (array1 != array2)
    {
      return false
    }
  }
  return true
}
回复

使用道具 举报

 楼主| 发表于 2007-6-6 11:21:53 | 显示全部楼层 来自 中国–广西–柳州–柳江区

回复: Rulzy老大,又有问题请教,请进,谢谢。

郁闷,fc64541161这鸟毛没事做学我。:mad:
回复

使用道具 举报

 楼主| 发表于 2007-6-15 08:24:57 | 显示全部楼层 来自 中国–广西–柳州–城中区

回复: Rulzy老大,又有问题请教,请进,谢谢。

顶一下,不另外发贴了。希望Rulzy老大能看到。
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表