I had twistedeuphoria port this plugin to AMXX 0.16 now I am trying to fix the rest here is what I got so far:
Code:
/* AMXMOD script.
*
*
* Parts (c) Copyright 2000-2002, Made by Rich - This file is provided as is (no warranties).
* Major changes to support steam id's, reading and writing of files, and removing dead code
* by Hobo and Freecoder Port to AMXX 0.16 twistedeuphoria and M4573R
*
* CHEATING DEATH MEDIATOR EXTENDED V3.0
*
*
This is a revamping of CD Mediator Extended 2.0.
This has been ported to work with AMXX 0.16
It allows you to set a ratio of deaths to frags and will inform players who
exceed that ratio that they cannot play on your server until they download and
install Cheating Death.
----------------
3 cvars are registered:
1: amx_cd_saved = the number of Steam ID's the plugin remembers.
2: amx_cd_ratio = the ratio of kills to deaths before plugin kicks a player
3: amx_cd_limit = the number of kills before this plugin starts checking a player
3 console commands have been registered:
1: amx_cd_add <player name> = manually add a person to the list
2: amx_cd_clear = clears the list of remembered people
3: amx_cd_list = shows you the list of remembered steam id's
IMPORTANT: When the plugin decides to kick somebody, it will display an MOTD
explaining what is going on. This MOTD MUST be called cd.txt and be placed in
the amxx/configs/cdmed/ directory. A copy of an appropriate MOTD is in this package.
You may, of course, modify it as you like.
This plugin assumes that you have CD Server Plugin installed and running.
If you don't, you can get it from <a href="http://www.unitedadmins.com" target="_blank" rel="nofollow noopener">www.unitedadmins.com</a>
Contributors to this plugin are:
Rich: Original author
Freecoder and Hobo: Extensions and changes to work with Steam ID's and to
save the list properly.
Twistedeuphoria and M4573R: Port to AMXX 0.16 and Fixed file paths and client text.
*/
#include <amxmodx>
#include <amxmisc>
new klimit, kdratio, no_cd[33], no_cd_authid[33]
new filepath[33] = "/addons/amxx/configs/cdmed/mediator.ini", holdfilepath[33] = "/addons/amxx/configs/cdmed/holdfile.ini"
public plugin_init()
{
register_plugin("C-D Mediator Extended", "3.0", "Rich")
register_cvar("amx_cd_saved","999999999")
register_cvar("amx_cd_ratio", "2")
register_cvar("amx_cd_limit", "14")
register_concmd("amx_cd_add","add_player",ADMIN_KICK,"< Part of Name >")
register_concmd("amx_cd_clear","clear_player",ADMIN_BAN,"- Remove all stored Steam ID's")
register_concmd("amx_cd_list","list_stored",ADMIN_KICK,"- Lists stored Steam ID's")
register_cvar("amx_cd_mediator", "2.0",FCVAR_SERVER)
register_logevent("check_players", 2, "1=Round_Start")
}
public client_connect(id)
{
no_cd[id] = false
}
public client_disconnect(id)
{
no_cd[id] = false
}
public check_players()
{
new b, r
klimit = get_cvar_num("amx_cd_limit")
kdratio = get_cvar_num("amx_cd_ratio")
new authid[32],fileauthid[32]
for(new a = 1; a <= get_maxplayers(); ++a)
{
no_cd[a] = false
if (get_user_time(a) > 120)
{
new name[9]
get_user_name(a,name,8)
if ( (equali(name,"[No C-D]")) || (equali(name,"[Old C-D")) )
{
no_cd[a] = true
}
}
if (no_cd[a])
{
text_warn(a)
get_user_authid(a,authid,31)
if (file_exists(filepath))
{
b = read_file(filepath,b,fileauthid,32,r)
while (b > 0)
{
if (equali(authid,fileauthid))
{
kick_warn(a)
}
b = read_file(filepath,b,fileauthid,32,r)
}
}
if (get_user_frags(a) >= klimit)
{
if (float(get_user_deaths(a)) <= (float(get_user_frags(a)) / float(kdratio)) )
{
save_file(a)
kick_warn(a)
}
}
}
}
}
public text_warn(id)
{
client_print(id,print_chat,"[AMXX-CD] Cheating death is required if your score gets high enough")
client_print(id,print_chat,"[AMXX-CD] Download it from www.unitedadmins.com/cdeath.php")
}
public kick_warn(id)
{
new filename[192]
format(filename,191,"addons/amxx/configs/cdmed/cd.txt")
show_motd(id,filename,"Cheating Death Required")
new ids[1]
ids[0] = id
set_task(30.0,"kick_player",123,ids,1)
}
public kick_player(ids[])
{
new id
id = str_to_num(ids)
new uname[33]
get_user_name(id,uname,32)
server_cmd("kick #%i",get_user_userid(ids[0]))
}
public save_file(id)
{
new auth[32], b, l, other[32]
new num
num = get_cvar_num("amx_cd_saved")
if (file_exists(holdfilepath))
{
delete_file(holdfilepath)
}
if (file_exists(filepath))
{
b = 0
for(new a = 0; a < num; ++a)
{
b = read_file(filepath,b,auth,32,l)
format(other,32,"%i",b)
if (b)
{
write_file(holdfilepath,auth)
}
if (!b)
{
a = num
}
}
}
get_user_authid(id,auth,31)
write_file(holdfilepath,auth)
if (file_exists(filepath))
{
delete_file(filepath)
}
b = 0
do
{
b = read_file(holdfilepath,b,auth,32,l)
format(other,32,"%i",b)
if (b)
{
write_file(filepath,auth)
}
} while(b)
delete_file(holdfilepath)
}
public add_player(id,level,cid)
{
if (!cmd_access(id,level,cid,2))
{
return PLUGIN_CONTINUE
}
new arg[32],authidI[32]
read_argv(1,arg,31)
new playeridn = cmd_target(id,arg,1)
if (!playeridn)
{
return PLUGIN_HANDLED
}
for(new a = 0; a <= 32; ++a)
{
if ( no_cd_authid[a] == get_user_authid(playeridn,authidI,31) )
{
// console_print(id,"[AMXX-CD]Player is already in the list.")
// return PLUGIN_HANDLED
}
}
save_file(playeridn)
if (no_cd[playeridn])
{
kick_warn(playeridn)
}
console_print(id,"[AMXX-CD]Player now required to use C-D.")
return PLUGIN_HANDLED
}
public set_frags(id,level,cid)
{
new frags[3], frg
read_argv(1,frags,3)
frg = str_to_num(frags)
set_user_frags(id,frg)
return PLUGIN_HANDLED
}
public list_stored(id,level,cid)
{
new other[50], b, auth[32],l
if (!cmd_access(id,level,cid,0))
{ return PLUGIN_CONTINUE
}
if (file_exists(filepath))
{
console_print(id,"[AMXX-CD] STORED CD REQUIRED STEAM ID's")
b = 0
do
{
b = read_file(filepath,b,auth,32,l)
format(other,32,"[AMXX-CD] %s",auth)
if (b)
{
console_print(id,other)
}
} while(b)
}
if (!file_exists(filepath))
{
console_print(id,"[AMXX-CD] The list is empty.")
}
return PLUGIN_HANDLED
}
public clear_player(id,level,cid)
{
if (!cmd_access(id,level,cid,0))
{
return PLUGIN_CONTINUE
}
if (file_exists(filepath))
{
delete_file(filepath)
}
for(new a = 0; a <= 32; ++a)
{
no_cd_authid[a] = 0
}
console_print(id,"[AMXX-CD]All stored WonID removed.")
return PLUGIN_HANDLED
}
public sendit(text[32])
{
client_print(0,print_chat,text)
}