【求助】cdmoderator 代码问题。
我是试着改一个插件,原名叫cdmoderator,原来是验证STEAMID的,我改为IP后编译是通过了不过有下面的错误提示,请各位帮我看看:/home/groups/amxmodx/tmp/phpJbxMMg.sma(61) : warning 217: loose indentation
/home/groups/amxmodx/tmp/phpJbxMMg.sma(64) : warning 217: loose indentation
/home/groups/amxmodx/tmp/phpJbxMMg.sma(106) : warning 202: number of arguments does not match definition
/home/groups/amxmodx/tmp/phpJbxMMg.sma(106) : warning 202: number of arguments does not match definition
修改后的SMA如下:
//C-D Moderator by Bugsy
//This plugin will kick a Non-CD or Old-CD player if their score reaches the starting
//point ("plugin watches them", amx_kdmax) and surpasses an admin-defined kill\death
//ratio (amx_kdratio), which is defined as (deaths < (score / ratio)). By default
//the ratio is 2 so if the player scores a 20/10 or better, they get kicked at the
//beginning of the following round. It will not start looking at a player until the
//player reaches amx_kdmax kills. At each round start, players receive a
//warning about being kicked based on their kill ratio and at what kill-number the
//plugin starts to watch them. If they key kicked, their SteamID gets written to the
//vault so if they reconnect they will be kicked again and again until they come back
//with C-D loaded. It pretty much turns CD Required "on" for players that come
//to the server without C-D and get kicked for doing good. I felt that having
//my server on CD Required killed the traffic that I was getting while on optional
//so this plugin gives you the best of both worlds. Enjoy
#include <amxmodx>
#include <amxmisc>
new no_cd
//These two functions pretty much give each player index a
//"Clean slate" when there is a connection\disconnection.
public client_connect(id)
{
no_cd = 0
return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
no_cd = 0
return PLUGIN_CONTINUE
}
//In this function we check each players kill\death ratio and
//if they exceed the current ratio then they get added to the
//list of required C-D players.
public restart_event()
{
new cdenabled = get_cvar_num("amx_cdmoderator")
//Check if the plugin is enabled via the cvar.
if(cdenabled==0)return PLUGIN_HANDLED
//Get player count for server
new getmaxp = get_maxplayers()
//Loop through the players and see who has and who doesn't have
//cheating death loaded.
for(new chk=1; chk<=getmaxp; chk++)
{
//Set it to false to give the user a fresh start.
no_cd = 0
//Get the users name based on their player ID.
new name
get_user_info(chk, "name", name,8)
//Check if they have no c-d at all or an old ver. of c-d.
if ( equali(name,"") || equali(name,"[Old C-D") )
{
//Set user no_cd array index for this user to true, meaning they
//don't have c-d.
no_cd=1
}
}
//Loop through each player and cheat their kill count and
//kill\death ratio. Kick if they fulfill the cvar minimums.
for( new chk2=1; chk2<=getmaxp; chk2++)
{
new deaths = get_user_deaths ( chk2 )
new kills = get_user_frags( chk2 )
new kdstart = get_cvar_num("amx_kdmax")
new kdratio = get_cvar_num("amx_kdratio")
new address
// new authid
new name
//If the user does not have C-D
if ( no_cd == 1 )
{
//===New code===
scanplayer(chk2)
//==============
//If their kills are equal to or higher than the kdmax cvar
if(kills >= kdstart)
{
//This checks the ratio of kills vs. deaths
if ( (float(deaths)) <= (float(kills) / float(kdratio)) )
{
//This will kick the player and write to the vault so
//if they come back to the server without C-D again after
//being kicked then the plugin will kick them again if they dont have C-D.
//It pretty much turns cdrequired on for players after getting
//kicked once for high ratio+no c-d.
get_user_name(chk2,name,31)
get_user_ip(chk2,address,31)
set_vaultdata (address, "1")
server_cmd( "kick #%i %s",get_user_ip(chk2),"Kicked for not having Cheating-Death " )
client_print(0,print_chat,"%s kicked for not having Cheating-Death and having a %d/1 score ratio.",name,kdratio)
}
}
else
{
//This will send players without C-D a warning at the beginning of
//each round.
client_print(chk2,print_chat,"Cheating-Death Not Found. C-D Moderator will watch you when you reach %d kills.",kdstart)
client_print(chk2,print_chat,"You will be kicked if your kill/death count surpasses a %d/1 ratio.",kdratio)
client_print(chk2,print_chat,"If kicked, you will not be able to play here again until you have C-D loaded.")
client_print(chk2,print_chat,"Go get Cheating-Death at www.unitedadmins.com/cdeath.php")
}
}
}
return PLUGIN_CONTINUE
}
//========================================================================
//The following was commented out due to the update on C-D where
//it no longer runs via metamod. I am keeping the code in the plugin
//just incase it changes back how it was.
/*public client_infochanged(id)
{
new newname,oldname,address
new buffer, oldnamefull
//new customdir
//new rulesfile
get_user_info(id, "name", newname,8)
get_user_name(id,oldname,8)
get_user_name(id,oldnamefull,31)
get_user_ip(id,address,31)
client_print(id,print_chat,"%s - %s",oldname,newname)
//get_customdir(customdir, sizeof(customdir))
//format(rulesfile, sizeof(rulesfile), "%s/motd2.txt", customdir)
//When C-D changes a players name for not having C-D
//this will check the vault to see if the player was kicked before
//by the plugin. If so then they get kicked again and again until they have it.
if (!equali(newname,oldname))
{
if ( equali(newname,"") || equali(newname,"[Old C-D") )
{
get_vaultdata(address, buffer, 1)
if( equal(buffer,"1") )
{
//motdshown = 1
//show_motd ( id , rulesfile , "Cheating-Death Required" )
server_cmd( "kick #%i %s" , get_user_userid(id) ,"You will be kicked until you have Cheating-Death " )
client_print(0,print_chat,"%s kicked for returning to server without C-D after being kicked.",oldnamefull)
}
}
}
}*/
//========================================================================
//==============================
//This is the new code to handle the change in C-D/CS
public scanplayer(id)
{
new newname,address
new buffer, oldnamefull
get_user_info(id, "name", newname,8)
get_user_name(id,oldnamefull,31)
get_user_ip(id,address,31)
if ( equali(newname,"") || equali(newname,"[Old C-D") )
{
get_vaultdata(address, buffer, 1)
if( equal(buffer,"1") )
{
server_cmd( "kick #%i %s" , get_user_userid(id) ,"You will be kicked until you have Cheating-Death " )
client_print(0,print_chat,"%s kicked for returning to server without C-D after being kicked.",oldnamefull)
}
}
}
//================================================
public plugin_init()
{
register_plugin("C-D Moderator", "1.25", "Bugsy")
register_logevent("restart_event", 2, "1=Round_Start")
register_cvar("amx_kdmax", "12")
register_cvar("amx_kdratio", "2" )
register_cvar("amx_cdmoderator", "1" )
return PLUGIN_CONTINUE
}
请高手们指点。我是刚学的。。。菜鸟一只。 目的是什么?想通过ip干什么? 由于是记录不带CD的STEAMID,并且在以后都是都是参考STEAMID来判断玩家ID,可我的服务端是免STEAMID的,如是所有的STEAMID都是一样,就是说大家如果都不带CD这样的话,大家都有可能被KICK和BAN的可能。。我也试了原来的插件是验证STEAMID结果也一样。
此插件是因为限制不带CD玩家的杀人数,并提示其要挂CD或更新cd,可原插件是记录玩家STEAMID的,这样我服务器所有的人都是同一个STEAMID,这不就成了大家都不能进入了。。所有改成了记录IP了。。 看看,也学学。。。。 没有人有建议吗?
页:
[1]