搜索
查看: 1666|回复: 0

关于限制和惩罚[No C-D] [Old C-D]玩家的CDPunisher插件!

[复制链接]
发表于 2007-8-10 12:48:50 | 显示全部楼层 |阅读模式 来自 中国–四川–巴中
我想改成!CD4.32.0没有限制,特定CD版本或特定名字如CD4.33.4和[No C-D] [Old C-D]一样受到惩罚和限制武器,[Old C-D]玩家提示后踢出服务器!
老大们快来帮忙啊!谢谢!!
/* AMX Mod X script.
(c) Copyright 2004, 奔驰 (wzf828@163.com)
This file is provided as is and with no warranties or guarentee of usability.
*/
#include <amxmodx>
#include <fun>
#include <cstrike>
/*
This plug-in allows you to restrict weapons and limit the money of players who do not have C-D or
have a old version of C-D. The plug-ins behavior can be modified to ignore Old C-D and
trigger only on No C-D or trigger on both. Weapons can have separate restriction settings
for No C-D and Old C-D. Weapons that are restricted can not be picked up or purchased.
C-D detection is NOT done by string matching the players name. This plugin uses a direct
link to C-D through it's cvars and server commands to speed up detection time and lower
overhead a little. In addition to configurable weapon restrictions, this plugin can
affect the money that No C-D and Old C-D make. While No C-Ds make 20% of the normal amount,
C-D users make 110% of the normal amount. The percentages are configurable so they could be
anything from 1 to 64000+ %. Later versions will support a damage manager that will be able
to increase damage done to No C-D'ers while reducing damage done by No C-D'ers.
Requirements:
<amxmodx>
<fun>
<cstrike>
Cheating-Death hl server plugin
Installation:
Put CDpunisher.amx in your amx plugins directory and add CDpunisher.amx to your plugins.ini file.
Remove cdvalidatecmd, cdnovalidatecmd, cdoldvalidatecmd and set cdrequired to 0 in server cfg files.
Then add these cvars to your server.cfg

// Begin cfg
// These values are the recomended values. Please feel free to change them.

cdpunish_disarm   2 // 0=off 1=no cd only 2=old cd and no cd
cdpunish_requireauth  1 // 0=trusted 1=treat as No C-D 2=Treat as Old C-D
cdpunish_moneymanager  1 // 1=on 0=off
cdpunish_cdauthmoney  110 // If C-D gives +10%
cdpunish_cdnoauthmoney  20 // if No C-D subtracts 80%
cdpunish_cdoldauthmoney  50 // if Old C-D subtracts 50%
// The following are the weapon restriction rules.
// 0 = unrestricted
// 1 = No C-D restricted
// 2 = No C-D and Old C-D restricted
// By default all restrictions are off
cdpunish_p228   1
cdpunish_shield   1
cdpunish_scout   1
cdpunish_xm1014   1
cdpunish_mac10   1
cdpunish_aug   1
cdpunish_elite   1
cdpunish_fiveseven  1
cdpunish_ump45   1
cdpunish_sg550   1
cdpunish_galil   1
cdpunish_famas   1
cdpunish_usp   1
cdpunish_glock18  1
cdpunish_awp    1
cdpunish_mp5navy  1
cdpunish_m249   1
cdpunish_m3                 1
cdpunish_m4a1   1
cdpunish_tmp   1
cdpunish_g3sg1   1
cdpunish_deagle   1
cdpunish_sg552   1
cdpunish_ak47   1
cdpunish_p90   1
cdpunish_awp   1
cdpunish_hegrenade  1
cdpunish_flashbang  1
cdpunish_smokegrenade         1
cdpunish_nvgs   1
cdpunish_defuser  1
cdpunish_vest   1
cdpunish_vesthelm  1
cdpunish_primammo  1
cdpunish_secammo  1
// End cfg

*note - if you have cdvalidatecmd, cdnovalidatecmd, cdoldvalidatecmd or cdrequired cvar set in configuration be
aware that this plugin will ignore those settings. This plugin uses them to interact with CD.
todo:
-Add a damage increase dealt to No C-D clients and damage reduction dealt by No C-D clients.

Changelog:
0.1.3 -Added money management and restricted weapons from the purchase menus.
0.1.2 -Corrected version number and added weapon restrictions.
1.1 -ported my old stuff from CD Disarm to CD Punish.
*/
new cdauthrecords[33] // [index][authrecords]
new pname[33][64] // [index][name]
new weap[33][32] // [index][weaponidlist]
new userids[33] // [index][userid]
new nplayers //int # of players
new pmoney[33] //[index][money]
new restricted_weapons[32] //[weapon_index][code]
public cdauth(id)
{
new arg1s[32], arg2s[4], arg2
read_argv(0,arg1s,31)
read_argv(1,arg2s,3)
arg2 = str_to_num(arg2s)
id = getidfromuserid(arg2)
if(contain(arg1s, "register_as_cdauth") != -1)
{
  cdauthrecords[id] = 0
  cdauthnotify(id,0)
}
else if(contain(arg1s, "register_as_cdnoauth") != -1)
{
  cdauthrecords[id] = 1
  cdauthnotify(id,1)
  weapon_trigger(id)
}
else if(contain(arg1s, "register_as_cdoldauth") != -1)
{
  cdauthrecords[id] = 2
  cdauthnotify(id,2)
  weapon_trigger(id)
}
else
{
  return 1
}
return PLUGIN_HANDLED
}
getidfromuserid(userid)
{
loadplayers()
for(new i=0;i<sizeof(userids);++i)
{
  if(userids == userid)
  {
   return i
  }
}
return 1
}
loadplayers()
{
new id, players[32] // !!!!!!!!!!!!!! i want this to be [33] but the compiler wants [32]
get_players(players,nplayers)
for(new i=0;i<nplayers;++i)
{
  id = players
  get_user_name(id,pname[id],63)
  userids[id] = get_user_userid(id)
}
}
loadrestrictedweapons()
{
restricted_weapons[1] = get_cvar_num("cdpunish_p228")
restricted_weapons[2] = get_cvar_num("cdpunish_shield")
restricted_weapons[3] = get_cvar_num("cdpunish_scout")
restricted_weapons[4] = get_cvar_num("cdpunish_hegrenade")
restricted_weapons[5] = get_cvar_num("cdpunish_xm1014")
restricted_weapons[6] = 0 // c4
restricted_weapons[7] = get_cvar_num("cdpunish_mac10")
restricted_weapons[8] = get_cvar_num("cdpunish_aug")
restricted_weapons[9] = get_cvar_num("cdpunish_smokegrenade")
restricted_weapons[10] = get_cvar_num("cdpunish_elite")
restricted_weapons[11] = get_cvar_num("cdpunish_fiveseven")
restricted_weapons[12] = get_cvar_num("cdpunish_ump45")
restricted_weapons[13] = get_cvar_num("cdpunish_sg550")
restricted_weapons[14] = get_cvar_num("cdpunish_galil")
restricted_weapons[15] = get_cvar_num("cdpunish_famas")
restricted_weapons[16] = get_cvar_num("cdpunish_usp")
restricted_weapons[17] = get_cvar_num("cdpunish_glock18")
restricted_weapons[18] = get_cvar_num("cdpunish_awp")
restricted_weapons[19] = get_cvar_num("cdpunish_mp5navy")
restricted_weapons[20] = get_cvar_num("cdpunish_m249")
restricted_weapons[21] = get_cvar_num("cdpunish_m3")
restricted_weapons[22] = get_cvar_num("cdpunish_m4a1")
restricted_weapons[23] = get_cvar_num("cdpunish_tmp")
restricted_weapons[24] = get_cvar_num("cdpunish_g3sg1")
restricted_weapons[25] = get_cvar_num("cdpunish_flashbang")
restricted_weapons[26] = get_cvar_num("cdpunish_deagle")
restricted_weapons[27] = get_cvar_num("cdpunish_sg552")
restricted_weapons[28] = get_cvar_num("cdpunish_ak47")
restricted_weapons[29] = 0 // knife
restricted_weapons[30] = get_cvar_num("cdpunish_p90")
restricted_weapons[31] = 0 // Unused
}
disarm_player(id)
{
new wname[32], num, origin[3]
get_user_weapons(id,weap[id],num)
for(new a=0;a<num;++a)
{
  new weaponid
  new restricted = false
  get_weaponname(weap[id][a],wname,31)
  weaponid = weap[id][a]
  if(restricted_weapons[weaponid] == 2)
  {
   restricted = true
  }
  if(restricted_weapons[weaponid] == 1 && cdauthrecords[id] == 1)
  {
   restricted = true
  }
  if(restricted)
  {
   get_user_origin(id,origin,0)
   origin[2] -= 3000
   set_user_origin(id,origin)
   engclient_cmd(id,"drop",wname)
   engclient_cmd(id,"weapon_knife")
   origin[2] += 3003
   set_user_origin(id,origin)
  }
}
}
public weapon_trigger(id)
{
if(cdauthrecords[id] == 1 && get_cvar_num("cdpunish_disarm") != 0)
{
  disarm_player(id)
}
else if(cdauthrecords[id] == 2 && get_cvar_num("cdpunish_disarm") == 2)
{
  disarm_player(id)
}
else if(cdauthrecords[id] == 255 && get_cvar_num("cdpunish_disarm") != 0)
{
  return 1
}
return PLUGIN_HANDLED
}
cdauthnotify(id,code)
{
if(code == 0)
{
  client_print(id,print_chat,"[服务器 C-D 检测结果]: 通过检测欢迎你 我的朋友 :D")
  //client_cmd(id,"speak ^"C D 通过检测. 你可以购买全部的武器.^"")
}
else if(code == 1 && get_cvar_num("cdpunish_disarm") != 0)
{
  client_print(id,print_chat,"[服务器 C-D 检测结果]: 没有运行[C-D v4.32.0]很多枪买不了的 :(")
  //client_cmd(id,"speak ^"C D 未通过检测. 你不能购买武器. 请安装 C-D v4.32.0^"")
}
else if(code == 2 && get_cvar_num("cdpunish_disarm") == 2)
{
  client_print(id,print_chat,"[服务器 C-D 检测结果]: 好像你的C-D有作弊嫌疑 :[")
  client_cmd(id,"speak ^"C D 无法检测. 你不能购买武器. 请安装 C-D v4.32.0^"")
  print_cd_message(id)
                server_cmd("kick #%i 请正确打开C-D v4.32.0,不要作弊!!!", get_user_userid(id))
}
else if(code == 3 && get_cvar_num("cdpunish_requireauth") == 1)
{
  client_print(id,print_chat,"[服务器 提示]: 没有运行 C-D v4.32.0 游戏不能完美进行,请打开 C-D v4.32.0 重新进入.")
  //client_cmd(id,"speak ^"你可以购买武器. 但是你机器的C-D不被认可.^"")
}
else if(code == 255)
{
  return 1
}
return PLUGIN_CONTINUE
}
public checkcdstatus(id)
{
new arg0s[32], arg1s[4], arg2s[4], arg1, arg2, code
read_argv(0,arg0s,31)
read_argv(1,arg1s,3)
read_argv(2,arg2s,3)
arg1 = str_to_num(arg1s)
arg2 = str_to_num(arg2s)
id = getidfromuserid(arg1)
code = arg2
if(code == 0)
{
  cdauthrecords[id] = 0
  cdauthnotify(id,0)
}
else if(code == 1)
{
  cdauthrecords[id] = 1
  cdauthnotify(id,1)
}
else if(code == 2)
{
  cdauthrecords[id] = 2
  cdauthnotify(id,2)
}
else if(code == 3)
{
  if(get_cvar_num("cdpunish_requireauth") == 0)
  {
   cdauthrecords[id] = 0
  }
  else if(get_cvar_num("cdpunish_requireauth") == 1)
  {
   cdauthrecords[id] = 1
  }
  else if(get_cvar_num("cdpunish_requireauth") == 2)
  {
   cdauthrecords[id] = 2
  }  
  cdauthnotify(id,3)
}
else
{
  return 1
}
weapon_trigger(id)
return PLUGIN_HANDLED
}
public money_manager(id)
{
if(get_cvar_num("cdpunish_moneymanager") != 1)
{
  return PLUGIN_HANDLED
}
new cdauthmoney = get_cvar_num("cdpunish_cdauthmoney")
new cdnoauthmoney = get_cvar_num("cdpunish_cdnoauthmoney")
new cdoldauthmoney = get_cvar_num("cdpunish_cdoldauthmoney")
new cash, oldcash, newcash
oldcash = pmoney[id]
newcash = cs_get_user_money(id)
if(oldcash < newcash)
{
  cash = newcash - oldcash
  if (cdauthmoney > 0 && cdauthrecords[id] == 0)
  {
   cash = get_percentage(cdauthmoney,cash)
  }
  if (cdnoauthmoney > 0 && cdauthrecords[id] == 1)
  {
   cash = get_percentage(cdnoauthmoney,cash)
  }
  if (cdoldauthmoney > 0 && cdauthrecords[id] == 2)
  {
   cash = get_percentage(cdoldauthmoney,cash)
  }
  cash += oldcash
  if (cash > 16000)
  {
   cash = 16000
  }
  else if (cash < 0)
  {
   cash = 0
  }
  cs_set_user_money(id,oldcash,0)
  cs_set_user_money(id,cash,1)
}
pmoney[id] = cs_get_user_money(id)
return PLUGIN_HANDLED
}
get_percentage(percentile,intvalue)
{
new num
num = intvalue / 100
intvalue = num * percentile
return intvalue
}
public client_disconnect(id)
{
loadplayers()
}
public client_connect(id)
{
loadplayers()
set_cvar_string("cdvalidatecmd","register_as_cdauth %d")
set_cvar_string("cdnovalidatecmd","register_as_cdnoauth %d")
set_cvar_string("cdoldvalidatecmd","register_as_cdoldauth %d")
set_cvar_num("cdrequired",0)
loadrestrictedweapons()
}
public client_command(id)
{
new arg[32]
read_argv(0,arg,31)
if(contain(arg, "joinclass") != -1)
{
  server_cmd("cdstatus reportcdstatus ^"%d^"",get_user_userid(id))
  weapon_trigger(id)
  return PLUGIN_CONTINUE
}
for(new i=0;i<37;++i)
{
  new wname[32]
  switch (i)
  {
   case 1: wname = "p228"
   case 2: wname = "shield"
   case 3: wname = "scout"
   case 4: wname = "hegren"
   case 5: wname = "xm1014"
   case 6: wname = "" // c4
   case 7: wname = "mac10"
   case 8: wname = "aug"
   case 9: wname = "sgren"
   case 10: wname = "elites"
   case 11: wname = "fn57"
   case 12: wname = "ump45"
   case 13: wname = "sg550"
   case 14: wname = "galil"
   case 15: wname = "famas"
   case 16: wname = "usp"
   case 17: wname = "glock"
   case 18: wname = "awp"
   case 19: wname = "mp5"
   case 20: wname = "m249"
   case 21: wname = "m3"
   case 22: wname = "m4a1"
   case 23: wname = "tmp"
   case 24: wname = "g3sg1"
   case 25: wname = "flash"
   case 26: wname = "deagle"
   case 27: wname = "sg552"
   case 28: wname = "ak47"
   case 29: wname = "" // knife
   case 30: wname = "p90"
   case 31: wname = "nvgs"
   case 32: wname = "defuser"
   case 33: wname = "vest"
   case 34: wname = "vesthelm"
   case 35: wname = "primammo"
   case 36: wname = "secammo"
   default: wname = ""
  }
  if(equal(wname, arg) && restricted_weapons != 0 && cdauthrecords[id] != 0)
  {
   if(cdauthrecords[id] == 1)
   {
    client_print(id,print_center,"**这种武器是受限制的 未打开C-D v4.32.0禁止购买**")
    return PLUGIN_HANDLED
   }
   else if(cdauthrecords[id] == 2 && restricted_weapons == 2)
   {
    client_print(id,print_center,"**这种武器是受限制的 未打开C-D v4.32.0禁止购买**")
    return PLUGIN_HANDLED
   }
  }
}
return PLUGIN_CONTINUE
}
public roundstart()
{
new players[32] //!!!!!!!!!! i want [33] compiler wants [32]
get_players(players,nplayers)
for(new i=0;i<nplayers;++i)
{
  server_cmd("cdstatus reportcdstatus ^"%d^"",userids[players])
  weapon_trigger(players)
}
if(get_cvar_num("cdpunish_disarm") != 0)
{
  set_hudmessage(150,150,150,0.50,0.55,0,8.0,8.0,1.0,4.0,2)
  show_hudmessage(0, "[服务器 通知]: 玩家必须打开C-D v4.32.0才能正常享受游戏中的快乐.")
}
if(get_cvar_num("cdpunish_moneymanager") != 0)
{
  set_hudmessage(0,255,0,0.50,0.65,0,8.0,8.0,1.0,4.0,3)
  show_hudmessage(0, "开了C-D v4.32.0的玩家会得到 ^"%d^" % 的金钱奖励。",get_cvar_num("cdpunish_cdauthmoney"))
  set_hudmessage(0,255,0,0.50,0.68,0,8.0,8.0,1.0,4.0,4)
  show_hudmessage(0, "开了C-D v4.33.4的玩家只能得到 ^"%d^" % 的金钱奖励。",get_cvar_num("cdpunish_cdnoauthmoney"))
}
}
public plugin_init()
{
register_plugin("C-D Punisher","0.1.2","Josh Oshiro")
register_cvar("cdpunish_disarm","2")
register_cvar("cdvalidatecmd","register_as_cdauth %d")
register_cvar("cdnovalidatecmd","register_as_cdnoauth %d")
register_cvar("cdoldvalidatecmd","register_as_cdoldauth %d")
register_cvar("cdrequired","0")
register_cvar("cdpunish_cdauthmoney","110")
register_cvar("cdpunish_cdnoauthmoney","20")
register_cvar("cdpunish_cdoldauthmoney","50")
register_cvar("cdpunish_requireauth","1")
register_cvar("cdpunish_moneymanager","1")
register_cvar("cdpunish_p228","0")
register_cvar("cdpunish_shield","0")
register_cvar("cdpunish_scout","0")
register_cvar("cdpunish_xm1014","0")
register_cvar("cdpunish_mac10","0")
register_cvar("cdpunish_aug","0")
register_cvar("cdpunish_elite","0")
register_cvar("cdpunish_fiveseven","0")
register_cvar("cdpunish_ump45","0")
register_cvar("cdpunish_sg550","0")
register_cvar("cdpunish_galil","0")
register_cvar("cdpunish_famas","0")
register_cvar("cdpunish_usp","0")
register_cvar("cdpunish_glock18","0")
register_cvar("cdpunish_awp ","0")
register_cvar("cdpunish_mp5navy","0")
register_cvar("cdpunish_m249","0")
register_cvar("cdpunish_m3","0")
register_cvar("cdpunish_m4a1","0")
register_cvar("cdpunish_tmp","0")
register_cvar("cdpunish_g3sg1","0")
register_cvar("cdpunish_deagle","0")
register_cvar("cdpunish_sg552","0")
register_cvar("cdpunish_ak47","0")
register_cvar("cdpunish_p90","0")
register_cvar("cdpunish_awp","0")
register_cvar("cdpunish_hegrenade","0")
register_cvar("cdpunish_smokegrenade","0")
register_cvar("cdpunish_flashbang","0")
register_cvar("cdpunish_defuser","0")
register_cvar("cdpunish_vest","0")
register_cvar("cdpunish_vesthelm","0")
register_cvar("cdpunish_primammo","0")
register_cvar("cdpunish_secammo","0")
register_srvcmd("register_as_cdauth","cdauth")
register_srvcmd("register_as_cdnoauth","cdauth")
register_srvcmd("register_as_cdoldauth","cdauth")
register_srvcmd("reportcdstatus","checkcdstatus")
register_event("CurWeapon","weapon_trigger","b")
register_event("Money","money_manager","b")
register_logevent("roundstart",2,"1=Round_Start")
}
游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表