normen 发表于 2006-11-16 10:40:41

脚本高手来看看,为什么编译不过去

AMXX 1.60编译时出现:

slots.sma(1) : error 010: invalid function or declaration
1 Error.
Could not locate output file slots.amx (compile failed).


/* AMX Mod X script.
*
* (c) 2006, OLO
* This file is provided as is (no warranties).
*
* Set you server max_players to 1 above the desirered value (ie. 21 or 33).
* Query programs will see max_players -1 as max. Admins with reservation
* can connect when there is 20/20 and player with worst ping or least play time
* will be kicked.
*
* 如果OP通道插件未启用,本插件奖自动设置amx_reservation为 1 ,即保留一个通道。
*
* 使用方法:
*
* 在amxx.cfg里加入
* amx_kickmode <参数>
* 参数为 <1> 或者 <2> 。
*
* 1 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个在线时间最短的玩家。
* 2 表示 - 当服务器人满时,有OP或者VIP登陆时则踢掉一个ping值最高的玩家。
*
* 内网IP地址设置方法:
* amx_netbarip "IP地址的前面7位"
* 例: amx_netbarip "192.168"
*
* IP联盟地址设置方法:
* amx_netbarip1 "IP地址"
* amx_netbarip2 "IP地址"
* amx_netbarip3 "IP地址"
* amx_netbarip4 "IP地址"
* amx_netbarip5 "IP地址"
* 例:
* amx_netbarip1 "192.168.0.1"
* amx_netbarip2 "222.218.124.96"
* amx_netbarip3 "125.83.0.45"
* amx_netbarip4 "221.127.245.22"
* amx_netbarip5 "222.83.176.68"
*
*
*/
#include <amxmodx>
#include <amxmisc>
public plugin_init()
{
register_plugin("Slots Reservation","1.0","KuaiLn")
register_cvar("amx_kickmode","2")
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
new ips
new ips2
new name
new g_amx_netbarip
new g_amx_netbarip1
new g_amx_netbarip2
new g_amx_netbarip3
new g_amx_netbarip4
new g_amx_netbarip5
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
get_user_name( who, name , 31 )
client_cmd(id,"echo ^"* %s 被踢出以空出ViP预留通道^"" ,name )
}
return PLUGIN_CONTINUE

}
if ( is_user_bot(id) )
server_cmd("kick #%d ^"您无权进入ViP通道.购买请联系QQ^"", get_user_userid(id) )
else
server_cmd("kick #%d ^"您无权进入ViP通道.购买请联系QQ^"", get_user_userid(id) )

return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
kickFresh()
{
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 ^"ViP会员进入预留通道,服务器自动踢出在线时间最短者!请稍后再进入^"", get_user_userid(who) )
else
server_cmd("kick #%d ^"ViP会员进入预留通道,服务器自动踢出在线时间最短者!请稍后再进入^"", 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 ^"ViP会员进入预留通道,服务器自动踢出高ping者!请稍后再进入^"" , get_user_userid(who) )
else
server_cmd("kick #%d ^"ViP会员进入预留通道,服务器自动踢出高ping者!请稍后再进入^"" , get_user_userid(who) )
return who
}

jim_yang 发表于 2006-11-16 12:13:25

回复: 脚本高手来看看,为什么编译不过去

缩进代码!(如果你真想让人家看的话)

Rulzy 发表于 2006-11-16 12:57:37

回复: 脚本高手来看看,为什么编译不过去

在我的版本上编辑通过,没有发生错误。你看一下出错的是哪一行吧。推荐使用 AMXX Studio 进行代码编写,它可是一个很好的编程环境,就像 很多高级语言的编程一样,编译时在哪一行出错,都会指出来。唯一遗憾的是,它现在不支持utf-8,utf-8格式的文件它会将其当成ansi来打开,不过也只是上面的中文变成乱码,不影响编译。不知道什么版本会开始支持。

normen 发表于 2006-11-16 13:55:51

回复: 脚本高手来看看,为什么编译不过去

恩,还真是,没看3楼的回复之前,尝试用了一下amxx studio 1.3,一下就完成了,赶紧来回复帖子,看来这个办法是对的,谢谢3楼的

cskk 发表于 2006-11-21 13:19:18

回复: 脚本高手来看看,为什么编译不过去

呵呵 我自己也解决了 感觉真好
页: [1]
查看完整版本: 脚本高手来看看,为什么编译不过去