|
楼主 |
发表于 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
} |
|