搜索
查看: 1658|回复: 0

【求助】AMXX中文钒-插件问}

[复制链接]
发表于 2005-2-23 00:20:23 | 显示全部楼层 |阅读模式 来自 中国–香港
L 02/22/2005 - 21:41:34: [AMXX] Debug Trace =>
L 02/22/2005 - 21:41:34: [AMXX]       [0] Line 120, File "anticamping_x.sma"
L 02/22/2005 - 21:41:34: [AMXX]       [1] Line 278, File "anticamping_x.sma"
L 02/22/2005 - 21:41:34: [AMXX] Run time error 25 (parameter error) on line 120 (plugin "anticamping_x.amxx").
L 02/22/2005 - 21:41:34: String formatted incorrectly - parameter 3 (total 2)

  1. /* AMX Mod script
  2. *
  3. *        AntiCamping Advanced
  4. *        by Homicide, original code by SpaceDude
  5. *
  6. *        This script is a modification to SpaceDude's anti-camping plugin.
  7. *        I used Spacedudes method for determine camping then added some nice features to the plugin.
  8. *
  9. *                The main feature I added was the heartbeat method of discouraging camping.
  10. *
  11. *        The features include the ability to set punishment, camping time, healthpunish, and toggle 'the campmeter'.
  12. *
  13. *   Cvars:
  14. *        anticamping 0|1                        蹲坑检测 0=关闭, 1=开启 | 默认: 1
  15. *        anticamping_time n                允许蹲坑的时间上限 | 默认: 20
  16. *        anticamping_punish_mode abcde        蹲坑惩罚的方式, a=扇耳光, b=减少生命值, c=举牌子, d=呼吸声, e=亮人, 可复选 | 默认:bc
  17. *        anticamping_healthpunish n         每次减少生命值的数量(如果选择了减少生命的惩罚方式) | 默认: 10
  18. *        anticamping_meter 0|1                向客户端显示检测的信息, 0=关闭, 1=开启 | 默认: 1
  19. *        anticamping_camp_limit n        每个玩家的蹲坑限次 | 默认: 3
  20. *        anticamping_kick 0|1                是否自动踢出超过蹲坑限次的玩家, 1=开启, 0=关闭 | 默认: 1
  21. *
  22. *        note: this plugin is best used without any other anti-camp plugins
  23. *        origin auth:Homicide-       original code by SpaceDude
  24. *        edit by nwb13
  25. */

  26. #include <amxmodx>
  27. #include <fun>

  28. #define SND_STOP (1<<5)
  29. #define TASK_CAMP 6666667
  30. #define DETECT_RANGE 30.0        // 检测范围
  31. #define ROW_NUM 5        // 进度条的数量

  32. new playercoord0[33][3]
  33. new playercoord1[33][3]
  34. new playercoord2[33][3]
  35. new playercoord3[33][3]
  36. new playercoord4[33][3]
  37. new campmeter[33]
  38. new g_pl_camptimes[33]        // 玩家的蹲坑次数
  39. new bool:pausecounter[33]
  40. new bool:bombplanted
  41. new bool:de_map
  42. new camptolerancedefending = 180
  43. new camptoleranceattacking = 200
  44. new bool:g_pl_spr[33]        // 玩家的牌子状态
  45. new bool:g_pl_lim[33]        // 玩家蹲坑到100%的状态
  46. new camper_sprite
  47. new cvarflags[8]        // 惩罚方式
  48. new bool:g_pl_dtp[33]        // 检测玩家死亡时是否是正在蹲坑
  49. new bool:g_pl_glow[33]        // 检测玩家是否被亮人

  50. public plugin_init() {
  51.         register_plugin("AntiCamping Advanced X","0.1","nwb13")
  52.         register_event("Damage", "damage_event", "b", "2!0")
  53.         register_event("BarTime","bartime_event","b")
  54.         register_event("ResetHUD", "new_round", "b")
  55.         register_event("SendAudio", "bomb_planted", "a", "2&%!MRAD_BOMBPL")
  56.         register_event("SendAudio", "round_end", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
  57.         register_event("StatusIcon", "got_bomb", "be", "1=1", "1=2", "2=c4")
  58.         register_event("CS_DeathMsg", "on_death", "a")
  59.         register_cvar("anticamping","1")  // 蹲坑检测 0=关闭, 1=开启
  60.         register_cvar("anticamping_camptime","20")  // 允许蹲坑的时间上限
  61.         register_cvar("anticamping_punish_mode","bc") // 对蹲坑玩家的惩罚方式, a=扇耳光, b=减少生命值, c=举牌子, d=呼吸声, e=亮人
  62.         register_cvar("anticamping_healthpunish","10")  // 每次减少生命值的数量
  63.         register_cvar("anticamping_meter","1") // 向客户端显示检测的信息, 0=关闭, 1=开启
  64.         register_cvar("anticamping_camp_limit","3") // 每个玩家的蹲坑限次
  65.         register_cvar("anticamping_kick","1") // 是否自动踢出超过蹲坑限次的玩家, 1=开启, 0=关闭(但是立即杀死玩家并减上限数1)
  66.         register_cvar("anticamping_de_map_allow","1") //de_地图上是否允许防守方蹲坑

  67.         set_task(1.0,"checkcamping",1)
  68.         return PLUGIN_CONTINUE
  69. }

  70. public sqrt(num) {
  71.         new div = num;
  72.         new result = 1;
  73.         while (div > result) {        // end when div == result, or just below
  74.                 div = (div + result) / 2        // take mean value as new divisor
  75.                 result = num / div
  76.         }
  77.         return div;
  78. }

  79. public unpausecounter(parm[]) {
  80.         new id = parm[0]
  81.         pausecounter[id] = false
  82.         return PLUGIN_CONTINUE
  83. }

  84. public displaymeter(id) {
  85.         if (get_cvar_num("anticamping_meter") != 0) {
  86.                 new buffer[128],temp,pos
  87.                 if ((get_user_team(id) == 1) && bombplanted && de_map && get_cvar_num("anticamping_de_map_allow"))
  88.                         pos += format(buffer[pos],127-pos,"允许蹲坑以防止警察拆解炸弹")
  89.                 else if ((get_user_team(id) == 2) && (!bombplanted) && de_map && get_cvar_num("anticamping_de_map_allow"))
  90.                         pos += format(buffer[pos],127-pos,"允许蹲坑以防止匪徒布置炸弹")
  91.                 else {
  92.                         temp = campmeter[id]/ROW_NUM
  93.                         for (new x=0; x<temp; x++)
  94.                                 pos += format(buffer[pos],127-pos,"|")
  95.                         for (new y=0; y<(100/ROW_NUM-temp); y++)
  96.                                 pos += format(buffer[pos],127-pos,"_")
  97.                         pos += format(buffer[pos],127-pos,"^n蹲坑状态: %i%%  蹲坑次数: %d/%d",campmeter[id],g_pl_camptimes[id],get_cvar_num("anticamping_camp_limit"))
  98.                 }
  99.                 if (campmeter[id] > 100) {
  100.                         set_hudmessage(255, 0, 0, 0.02, 0.87, 0, 1.0, 2.0, 0.1, 0.1, 4)
  101.                 } else if (campmeter[id] > 90) {
  102.                         set_hudmessage(255, 0, 0, 0.02, 0.87, 0, 1.0, 2.0, 0.1, 0.1, 4)
  103.                 } else if (campmeter[id] > 80){
  104.                         set_hudmessage(255, 100, 0, 0.02, 0.87, 0, 1.0, 2.0, 0.1, 0.1, 4)
  105.                 } else if (campmeter[id] > 50 ) {
  106.                         set_hudmessage(255, 255, 0, 0.02, 0.87, 0, 1.0, 2.0, 0.1, 0.1, 4)
  107.                 } else if (campmeter[id] > 20 ) {
  108.                         set_hudmessage(0, 255, 0, 0.02, 0.87, 0, 1.0, 2.0, 0.1, 0.1, 4)
  109.                 } else {
  110.                         set_hudmessage(255, 255, 255, 0.02, 0.87, 0, 1.0, 2.0, 0.1, 0.1, 4)
  111.                 }
  112.                 show_hudmessage(id,buffer)
  113.         }
  114.         return PLUGIN_HANDLED
  115. }

  116. public checkcamping(){
  117.         if (!get_cvar_num("anticamping")){
  118.                 set_task(1.0,"checkcamping",1)
  119.                 return PLUGIN_CONTINUE
  120.         }
  121.         new players[32],variance[3],average[3]
  122.         new numberofplayers, variancetotal, standarddeviation, id, i, j, team

  123.         get_cvar_string("anticamping_punish_mode", cvarflags, 8)
  124.         get_players(players, numberofplayers, "a")
  125.         for (i = 0; i < numberofplayers; ++i) {
  126.                 while (i < numberofplayers && pausecounter[players[i]]) {
  127.                         ++i
  128.                 }
  129.                 if (i >= numberofplayers){
  130.                         set_task(1.0,"checkcamping",1)
  131.                         return PLUGIN_CONTINUE
  132.                 }
  133.                 id = players[i]
  134.                 for (j = 0; j < 3; ++j) {
  135.                         playercoord4[id][j] = playercoord3[id][j]
  136.                         playercoord3[id][j] = playercoord2[id][j]
  137.                         playercoord2[id][j] = playercoord1[id][j]
  138.                         playercoord1[id][j] = playercoord0[id][j]
  139.                 }
  140.                 get_user_origin(id, playercoord0[id], 0)
  141.                 for (j = 0; j < 3; ++j) {
  142.                         average[j] = (playercoord0[id][j] +
  143.                                                         playercoord1[id][j] +
  144.                                                         playercoord2[id][j] +
  145.                                                         playercoord3[id][j] +
  146.                                                         playercoord4[id][j]) / 5
  147.                         variance[j] = (((playercoord0[id][j] - average[j]) * (playercoord0[id][j] - average[j]) +
  148.                                                           (playercoord1[id][j] - average[j]) * (playercoord1[id][j] - average[j]) +
  149.                                                           (playercoord2[id][j] - average[j]) * (playercoord2[id][j] - average[j]) +
  150.                                                           (playercoord3[id][j] - average[j]) * (playercoord3[id][j] - average[j]) +
  151.                                                           (playercoord4[id][j] - average[j]) * (playercoord4[id][j] - average[j])) / 4)
  152.                 }
  153.                 variancetotal=variance[0]+variance[1]+variance[2]
  154.                 standarddeviation=sqrt(variancetotal)
  155.                 team = get_user_team(id)
  156.                 if (!de_map){
  157.                         if (team == 2)        // Team 1 = Terro, Team 2 = CT
  158.                                 campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
  159.                         else
  160.                                 campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
  161.                 }
  162.                 else if (bombplanted){
  163.                         if (team == 1)        // Team 1 = Terro, Team 2 = CT
  164.                                 if (get_cvar_num("anticamping_de_map_allow"))
  165.                                         campmeter[id] = 0
  166.                                 else
  167.                                         campmeter[id] += (camptolerancedefending - standarddeviation) / get_cvar_num("anticamping_camptime")
  168.                         else
  169.                                 campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
  170.                 }
  171.                 else{
  172.                         if (team == 2)        // Team 1 = Terro, Team 2 = CT
  173.                                 if (get_cvar_num("anticamping_de_map_allow"))
  174.                                         campmeter[id] = 0
  175.                                 else
  176.                                         campmeter[id] += (camptolerancedefending - standarddeviation) / get_cvar_num("anticamping_camptime")
  177.                         else
  178.                                 campmeter[id] += (camptoleranceattacking - standarddeviation) / get_cvar_num("anticamping_camptime")
  179.                 }
  180.                 if (g_pl_camptimes[id] >= get_cvar_num("anticamping_camp_limit")) {
  181.                         switch (get_cvar_num("anticamping_kick")){
  182.                                 case 0:{
  183.                                         client_print(id,print_chat,"* 你蹲坑的次数达到了上限, 所以立即处死你以示警告!")
  184.                                         user_slap(id,get_user_health(id))
  185.                                         g_pl_camptimes[id]--
  186.                                 }
  187.                                 case 1:{
  188.                                         client_cmd(id,"echo ^"该服务器讨厌爱蹲坑的玩家^"")
  189.                                         server_cmd("kick #%d ^"你达到了蹲坑限次, 被踢出服务器^"", get_user_userid(id))
  190.                                 }
  191.                         }
  192.                 }
  193.                 if ((campmeter[id] < 80 ) && is_user_connected(id)) {
  194.                         if (g_pl_lim[id] == true){
  195.                                 g_pl_lim[id] = false
  196.                         }
  197.                         if ((contain(cvarflags,"c") != -1) && (g_pl_spr[id] == true)) {
  198.                                 new parm[2]
  199.                                 parm[0] = id
  200.                                 parm[1] = 0
  201.                                 set_task(0.5,"clear_spr",TASK_CAMP+id,parm,2)
  202.                         }
  203.                         if ((contain(cvarflags,"e") != -1) && g_pl_glow[id]) {
  204.                                 set_user_rendering(id,kRenderFxNone,255,255,255,kRenderNormal,1)
  205.                                 g_pl_glow[id] = false
  206.                         }
  207.                         if (contain(cvarflags,"d") != -1) {
  208.                                 emit_sound(id,CHAN_VOICE,"player/breathe2.wav", 0.0, ATTN_NORM, SND_STOP, PITCH_NORM)
  209.                         }
  210.                 }
  211.                 if ((campmeter[id] < 0) && is_user_connected(id)){
  212.                         campmeter[id] = 0
  213.                 } else if ((campmeter[id]>100) && is_user_connected(id)) {
  214.                         if (contain(cvarflags,"a") != -1) {
  215.                                 user_slap(id,get_cvar_num("anticamping_healthpunish"))
  216.                         }
  217.                         if (contain(cvarflags,"b") != -1) {
  218.                                 set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish"))
  219.                         }
  220.                         if ((contain(cvarflags,"c") != -1) && (g_pl_spr[id] == false)) {
  221.                                 new parm[1]
  222.                                 parm[0] = id
  223.                                 set_task(0.5,"show_camper_spr",TASK_CAMP+id,parm,1)
  224.                         }
  225.                         if (contain(cvarflags,"d") != -1) {
  226.                                 emit_sound(id,CHAN_VOICE,"player/breathe2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  227.                         }
  228.                         if (contain(cvarflags,"e") != -1) {
  229.                                 new colour_r,colour_b
  230.                                 if (team == 1){
  231.                                         colour_r = 255
  232.                                         colour_b = 0
  233.                                 }else{
  234.                                         colour_r = 0
  235.                                         colour_b = 255
  236.                                 }
  237.                                 set_user_rendering(id,kRenderFxGlowShell,colour_r,0,colour_b,kRenderNormal,17)
  238.                                 g_pl_glow[id] = true
  239.                         }
  240.                         if (g_pl_lim[id] == false){
  241.                                 g_pl_camptimes[id]++
  242.                                 detect_enemy(id)
  243.                                 g_pl_lim[id] = true
  244.                         }
  245.                         campmeter[id] = 100
  246.                 } else if ((campmeter[id] > 90) && is_user_connected(id)) {
  247.                         if (contain(cvarflags,"a") != -1) {
  248.                                 user_slap(id,get_cvar_num("anticamping_healthpunish") / 5)
  249.                         }
  250.                         if (contain(cvarflags,"b") != -1) {
  251.                                 set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish") / 5)
  252.                         }
  253.                         if (contain(cvarflags,"d") != -1) {
  254.                                 emit_sound(id,CHAN_VOICE,"player/breathe2.wav", 0.5, ATTN_NORM, 0, PITCH_NORM)
  255.                         }
  256.                 } else if ((campmeter[id]>80) && is_user_connected(id)) {
  257.                         if (contain(cvarflags,"a") != -1) {
  258.                                 user_slap(id,get_cvar_num("anticamping_healthpunish") / 10)
  259.                         }
  260.                         if (contain(cvarflags,"b") != -1) {
  261.                                 set_user_health(id, get_user_health(id) - get_cvar_num("anticamping_healthpunish") / 10)
  262.                         }
  263.                         if (contain(cvarflags,"d") != -1) {
  264.                                 emit_sound(id,CHAN_VOICE,"player/breathe2.wav", 0.1, ATTN_NORM, 0, PITCH_NORM)
  265.                         }
  266.                 }
  267.                 if (is_user_connected(id) && get_cvar_num("anticamping"))
  268.                         displaymeter(id)
  269.         }
  270.         set_task(1.5,"checkcamping",1)
  271.         return PLUGIN_CONTINUE
  272. }

  273. public damage_event(id) {
  274.         if (get_cvar_num("anticamping")) {
  275.                 new enemy = get_user_attacker(id)
  276.                 if (get_user_team(id)!=get_user_team(enemy)) {
  277.                         campmeter[id]=0
  278.                         campmeter[enemy]=0
  279.                 }
  280.                 return PLUGIN_CONTINUE
  281.         }
  282.         return PLUGIN_CONTINUE
  283. }

  284. public new_round(id) {
  285.         if (get_cvar_num("anticamping")) {
  286.                 bombplanted=false
  287.                 pausecounter[id]=true
  288.                 campmeter[id]=0
  289.                 new Float:freezetime = get_cvar_float("mp_freezetime")+1.0
  290.                 new parm[1]
  291.                 parm[0]=id
  292.                 set_task(freezetime,"unpausecounter",0,parm,1)
  293.                 return PLUGIN_CONTINUE
  294.         }
  295.         return PLUGIN_CONTINUE
  296. }

  297. public bartime_event(id) {
  298.         if (get_cvar_num("anticamping")) {
  299.                 pausecounter[id]=true
  300.                 campmeter[id]=0
  301.                 new Float:bar_time=float(read_data(1)+1)
  302.                 new parm[1]
  303.                 parm[0]=id
  304.                 set_task(bar_time,"unpausecounter",0,parm,1)
  305.                 return PLUGIN_CONTINUE
  306.         }
  307.         return PLUGIN_CONTINUE
  308. }

  309. public bomb_planted() {
  310.         if (get_cvar_num("anticamping")) {
  311.                 bombplanted=true
  312.                 return PLUGIN_CONTINUE
  313.         }
  314.         return PLUGIN_CONTINUE
  315. }

  316. public got_bomb(id) {
  317.         if (get_cvar_num("anticamping")) {
  318.                 de_map=true
  319.                 return PLUGIN_CONTINUE
  320.         }
  321.         return PLUGIN_CONTINUE
  322. }

  323. public round_end() {
  324.         if (get_cvar_num("anticamping")) {
  325.                 new players[32]
  326.                 new numberofplayers
  327.                 new id
  328.                 new i
  329.                 get_players(players, numberofplayers, "a")
  330.                 for (i = 0; i < numberofplayers; ++i) {
  331.                         id=players[i]
  332.                         //pausecounter[id]=true
  333.                         campmeter[id]=0
  334.                         return PLUGIN_CONTINUE
  335.                 }
  336.         }
  337.         return PLUGIN_CONTINUE
  338. }

  339. public plugin_precache() {
  340.         precache_sound("player/breathe2.wav")
  341.         camper_sprite = precache_model("sprites/camper.spr")
  342.         return PLUGIN_CONTINUE
  343. }

  344. public show_camper_spr(parm[]) {       
  345.         new id = parm[0]
  346.         message_begin(MSG_ALL,SVC_TEMPENTITY)
  347.         write_byte(124)
  348.         write_byte(id)
  349.         write_coord(65)
  350.         write_short(camper_sprite)
  351.         write_short(32767)
  352.         message_end()
  353.         g_pl_spr[id] = true
  354.         show_camp_message(id,1)
  355.         return PLUGIN_CONTINUE
  356. }

  357. show_camp_message(id,type) {
  358.         new wps[32],buffer[512],name[32],wpnname[32]
  359.         new num,clip,ammo,pos
  360.         new health = get_user_health(id)
  361.         new armor = get_user_armor(id)
  362.         get_user_name(id,name,31)
  363.         if (type == 1){
  364.                 pos += format(buffer[pos],511-pos,"警告: %s (HP %d AP %d) 已长时间蹲坑^n他配备的武器及弹药量:^n",name,health,armor)
  365.         }else{
  366.                 pos += format(buffer[pos],511-pos,"警告: %s (HP %d AP %d) 离开了蹲坑点^n他配备的武器及弹药量:^n",name,health,armor)
  367.         }
  368.         get_user_weapons(id,wps,num)
  369.         for (new i=0; i<num; i++) {
  370.                 get_wpname(wps[i],wpnname,31)
  371.                 get_user_ammo(id, wps[i], ammo, clip)
  372.                 if (ammo < 0) ammo = 0
  373.                 if (clip < 0) clip = 0
  374.                 if (wps[i] == CSW_C4 || wps[i] == CSW_HEGRENADE || wps[i] == CSW_SMOKEGRENADE || wps[i] == CSW_FLASHBANG )
  375.                         pos += format(buffer[pos],511-pos,"%s  %d 枚^n",wpnname,clip)
  376.                 else if (wps[i] == CSW_KNIFE )
  377.                         pos += format(buffer[pos],511-pos,"%s^n",wpnname)
  378.                 else
  379.                         pos += format(buffer[pos],511-pos,"%s  弹夹%d发/备用%d发^n",wpnname,ammo,clip)
  380.         }
  381.         if (type == 1){
  382.                 pos += format(buffer[pos],511-pos,"请大家搜捕并歼灭他!")
  383.         }else{
  384.                 pos += format(buffer[pos],511-pos,"大家请留神任何可蹲坑的地点.")
  385.         }
  386.         if (type == 1)
  387.                 set_hudmessage(230, 180, 0, 0.17, 0.05, 0, 6.0, 10.0, 0.1, 0.15, 3)
  388.         else
  389.                 set_hudmessage(154, 20, 255, 0.17, 0.05, 0, 6.0, 10.0, 0.1, 0.15, 3)
  390.         show_hudmessage(0,buffer)
  391. }

  392. get_wpname(wp, name[], imax) {
  393.         switch (wp) {
  394.                 case CSW_P228:
  395.                         copy(name, imax, "P228")
  396.                 case CSW_SCOUT:
  397.                         copy(name, imax, "Scout")
  398.                 case CSW_HEGRENADE:
  399.                         copy(name, imax, "高爆手雷")
  400.                 case CSW_XM1014:
  401.                         copy(name, imax, "Xm1014")
  402.                 case CSW_C4:
  403.                         copy(name, imax, "炸药包")
  404.                 case CSW_MAC10:
  405.                         copy(name, imax, "Mac10")
  406.                 case CSW_AUG:
  407.                         copy(name, imax, "Aug")
  408.                 case CSW_SMOKEGRENADE:
  409.                         copy(name, imax, "烟雾雷")
  410.                 case CSW_ELITE:
  411.                         copy(name, imax, "Elite")
  412.                 case CSW_FIVESEVEN:
  413.                         copy(name, imax, "Fiveseven")
  414.                 case CSW_UMP45:
  415.                         copy(name, imax, "Ump45")
  416.                 case CSW_SG550:
  417.                         copy(name, imax, "Sg550")
  418.                 case CSW_GALIL:
  419.                         copy(name, imax, "Galil")
  420.                 case CSW_FAMAS:
  421.                         copy(name, imax, "Famas")
  422.                 case CSW_USP:
  423.                         copy(name, imax, "Usp")
  424.                 case CSW_GLOCK18:
  425.                         copy(name, imax, "Glock18")
  426.                 case CSW_AWP:
  427.                         copy(name, imax, "Awp")
  428.                 case CSW_MP5NAVY:
  429.                         copy(name, imax, "Mp5navy")
  430.                 case CSW_M249:
  431.                         copy(name, imax, "M249")
  432.                 case CSW_M3:
  433.                         copy(name, imax, "M3")
  434.                 case CSW_M4A1:
  435.                         copy(name, imax, "M4a1")
  436.                 case CSW_TMP:
  437.                         copy(name, imax, "Tmp")
  438.                 case CSW_G3SG1:
  439.                         copy(name, imax, "G3sg1")
  440.                 case CSW_FLASHBANG:
  441.                         copy(name, imax, "闪光雷")
  442.                 case CSW_DEAGLE:
  443.                         copy(name, imax, "Deagle")
  444.                 case CSW_SG552:
  445.                         copy(name, imax, "Sg552")
  446.                 case CSW_AK47:
  447.                         copy(name, imax, "Ak47")
  448.                 case CSW_KNIFE:
  449.                         copy(name, imax, "野战匕首")
  450.                 case CSW_P90:
  451.                         copy(name, imax, "P90")
  452.         }
  453.         return 1
  454. }

  455. public clear_spr(parm[]) {
  456.         new id = parm[0]
  457.         new type = parm[1]        // type 0=alive, 1=disconnect, 2=die in camping
  458.         message_begin(MSG_ALL,SVC_TEMPENTITY)
  459.         write_byte(125)
  460.         write_byte(id)
  461.         message_end()

  462.         if (type == 2 && g_pl_dtp[id] && parm[2] == id) {
  463.                 new name_camper[32]
  464.                 get_user_name(id,name_camper,31)
  465.                 set_hudmessage(154, 20, 255, 0.17, 0.1, 0, 6.0, 10.0, 0.1, 0.15, 3)
  466.                 show_hudmessage(0,"上局 %s 蹲的太专心了, 一不留神把自己给蹲死了^n这局请时刻留意自己的蹲坑状态",name_camper)
  467.                 g_pl_dtp[id] = false
  468.         }else if (type == 1) {
  469.                 set_hudmessage(154, 20, 255, 0.17, 0.1, 0, 6.0, 10.0, 0.1, 0.15, 3)
  470.                 show_hudmessage(0,"正在蹲坑的 %s 离开了服务器",parm[2])
  471.         }else if (type == 0)
  472.                 show_camp_message(id,0)
  473.         g_pl_spr[id] = false
  474.         return PLUGIN_CONTINUE
  475. }

  476. public client_connect(id) {
  477.         g_pl_camptimes[id] = 0
  478.         g_pl_lim[id] = false
  479.         g_pl_spr[id] = false
  480.         campmeter[id] = 0
  481.         return PLUGIN_CONTINUE
  482. }

  483. public client_disconnect(id) {
  484.         if ((contain(cvarflags,"c") != -1) && (g_pl_spr[id] == true)) {
  485.                 new parm[34]
  486.                 parm[0] = id
  487.                 parm[1] = 1
  488.                 get_user_name(id,parm[2],31)
  489.                 set_task(0.5,"clear_spr",TASK_CAMP+id,parm,34)
  490.         }
  491.         if (contain(cvarflags,"d") != -1) {
  492.                 emit_sound(id,CHAN_VOICE,"player/breathe2.wav", 0.0, ATTN_NORM, SND_STOP, PITCH_NORM)
  493.         }
  494.         campmeter[id] = 0
  495.         return PLUGIN_CONTINUE
  496. }

  497. public on_death(){
  498.         new killer = read_data(1)
  499.         new id = read_data(2)
  500.         pausecounter[id]=true
  501.         g_pl_dtp[id] = true
  502.         if ((contain(cvarflags,"c") != -1) && (g_pl_spr[id] == true)) {
  503.                 new parm[3]
  504.                 parm[0] = id
  505.                 parm[1] = 2
  506.                 parm[2] = killer
  507.                 set_task(0.1,"clear_spr",TASK_CAMP+id,parm,3)
  508.         }
  509.         return PLUGIN_CONTINUE
  510. }

  511. public detect_enemy(id) {
  512.         if (!is_user_alive(id))
  513.                 return PLUGIN_CONTINUE
  514.         new myorigin[3],emorigin[3]
  515.         new name[32],plist[32],pnum
  516.        
  517.         get_user_name(id,name,31)
  518.         get_user_origin(id, myorigin)
  519.         get_players(plist, pnum, "a")
  520.         for(new i = 0; i < pnum; i++) {
  521.                 if (plist[i] == id)
  522.                         continue

  523.                 get_user_origin(plist[i], emorigin)
  524.                 new distance = get_distance(emorigin, myorigin)
  525.                 if ( float(distance) * 0.0254 < DETECT_RANGE ){
  526.                         if (get_user_team(id) == get_user_team(plist[i])){
  527.                                 set_hudmessage(230, 180, 0, -1.0, 0.70, 0, 6.0, 6.0, 0.1, 0.15, 1)
  528.                                 show_hudmessage(plist[i],"注意: 你的队友 %s 在与你距离 %.2f 米的地方蹲坑",name,float(distance) * 0.0254)
  529.                                 client_print(plist[i],print_chat,"* 注意: 你的队友 %s 在与你距离 %.2f 米的地方蹲坑.",name,float(distance) * 0.0254)
  530.                         }else{
  531.                                 set_hudmessage(230, 180, 0, -1.0, 0.70, 0, 6.0, 6.0, 0.1, 0.15, 1)
  532.                                 show_hudmessage(plist[i],"注意: 有敌人在距离你 %.2f 米的地方蹲坑",float(distance) * 0.0254)
  533.                                 client_print(plist[i],print_chat,"* 注意: 有敌人在距离你 %.2f 米的地方蹲坑.",float(distance) * 0.0254)
  534.                         }
  535.                 }
  536.         }
  537.         return PLUGIN_CONTINUE
  538. }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

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