|
发表于 2005-7-19 21:39:18
|
显示全部楼层
|阅读模式
来自 中国–广东–深圳–罗湖区
我是试着改一个插件,原名叫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如下:
[php]//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, [No C-D] 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[32]
//These two functions pretty much give each player index a
//"Clean slate" when there is a connection\disconnection.
public client_connect(id)
{
no_cd[id] = 0
return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
no_cd[id] = 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[chk] = 0
//Get the users name based on their player ID.
new name[9]
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,"[No C-D]") || 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[chk]=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[32]
// new authid[32]
new name[32]
//If the user does not have C-D
if ( no_cd[chk2] == 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 [www.unitedadmins.com/cdeath.php]" )
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[9],oldname[9],address[32]
new buffer[2], oldnamefull[32]
//new customdir[128]
//new rulesfile[128]
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,"[No C-D]") || equali(newname,"[Old C-D") )
{
get_vaultdata(address, buffer, 1)
if( equal(buffer,"1") )
{
//motdshown[id] = 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 [www.unitedadmins.com/cdeath.php]" )
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[9],address[32]
new buffer[2], oldnamefull[32]
get_user_info(id, "name", newname,8)
get_user_name(id,oldnamefull,31)
get_user_ip(id,address,31)
if ( equali(newname,"[No C-D]") || 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 [www.unitedadmins.com/cdeath.php]" )
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
}
[/php]
请高手们指点。我是刚学的。。。菜鸟一只。 |
|