找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 974|回复: 8

求显示玩家按键插件使用方法

[复制链接]

该用户从未签到

发表于 2010-1-17 07:42:00 | 显示全部楼层 |阅读模式
RT!!!   请大虾跳出帮我解决此问题。。。  好用就给加分。。

该用户从未签到

发表于 2010-1-17 08:03:36 | 显示全部楼层
我 过两天到杭州旅游去。。

该用户从未签到

 楼主| 发表于 2010-1-17 11:09:39 | 显示全部楼层
回复 2# so1e


    真的假的。。。那你把号码留给我。。

该用户从未签到

发表于 2010-1-18 19:43:32 | 显示全部楼层
回复  so1e


    真的假的。。。那你把号码留给我。。
wzq5417601 发表于 2010-1-17 11:09




    我现在在宁波HOHO

该用户从未签到

发表于 2010-1-18 20:05:03 | 显示全部楼层
本帖最后由 Pledges 于 2010-1-18 20:19 编辑

Installation:
0. You need to have installed amxmodx to run this.
1. Put the file showkeys.amxx into /cstrike/addons/amxmodx/plugins/
2. Open /cstrike/addons/amxmodx/configs/plugins.ini with notepad
3. Add line "showkeys.amxx" at the end of plugins.ini.
4. Make shure that fakemeta module is running. You can find that out by opening /cstrike/addons/amxmodx/configs/modules.ini with notepad.

User commands:

say /keys
turns plugin on/off

say /keyscfg
configuration menu (position, color...)

Server cvar:

keys_channel 4
If you don't see other important text on hud you can try to change this value in interval of 1 to 4. The value -1 means that it will try to find unused channel, however I don't recommend you to use -1.

keys_autostart 0
If this is set to 1 /keys will be enabled by default.

Known bugs

Showkeys saves the configuration into "setinfo" string. Half-life has a limit of 7 setinfo strings. So if you will have problems with saving configuration, check your /cstrike/config.cfg and remove unused "setinfo" strings.

this is sma :

  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #define PLUGIN "Showkeys"
  5. #define VERSION "2.1"
  6. #define AUTHOR "coderiz"

  7. #define MENU_CONFIG MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0
  8. #define MENU_POSITION MENU_KEY_0
  9. #define MENU_COLOR MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_0
  10. // Uncoment this for some bhop info on hud.
  11. //#define BHOP 1
  12. // cvar pointers
  13. new cvar_keys_channel
  14. new cvar_autostart

  15. // Server settings
  16. new g_srv_channel
  17. new g_srv_struct[10][12][10]
  18. // player settings
  19. new bool:g_plr_showkeys[32]
  20. new bool:g_plr_showspeed[32]
  21. new g_plr_struct[32]
  22. new Float:g_plr_hudpos[32][2]
  23. new g_plr_hudcolor[32][3]

  24. // config menu
  25. new g_plr_configon[32]
  26. new g_plr_buttons[32][5]
  27. new g_plr_editcolor[32]

  28. #if defined BHOP
  29. new g_counter[32]
  30. new g_flags[32]
  31. #endif

  32. // Main
  33. // -------------------------------------------------------------------------------------------------
  34. public plugin_init() {
  35. register_plugin(PLUGIN, VERSION, AUTHOR)
  36. cvar_keys_channel = register_cvar ( "keys_channel", "4", FCVAR_SERVER)
  37. cvar_autostart = register_cvar ( "keys_autostart", "0", FCVAR_SERVER)

  38. g_srv_channel = get_pcvar_num ( cvar_keys_channel )
  39. if(g_srv_channel < 1 || g_srv_channel > 4)
  40. {
  41.   g_srv_channel = -1
  42. }

  43. // CMD
  44. register_clcmd("say /keys","cl_ShowKeys")
  45. register_clcmd("show_keys","cl_ShowKeys")
  46. register_clcmd("say /keysmenu","cl_config")
  47. register_clcmd("say /keyscfg","cl_config")
  48. register_clcmd("say /keysconf","cl_config")
  49. register_clcmd("say /keysconfig","cl_config")

  50. // Menu
  51. register_menu("Showkeys config", MENU_CONFIG,"menu_config_act")
  52. register_menu("Showkeys position", MENU_CONFIG,"menu_position_act")
  53. register_menu("Showkeys color", MENU_CONFIG,"menu_color_act")

  54. // Forwards
  55. register_forward(FM_PlayerPreThink, "fwd_PlayerPreThink")
  56. register_forward(FM_ClientPutInServer, "fwd_ClientPutInServer")


  57. //
  58. g_srv_struct[0][0] = "[w]"
  59. g_srv_struct[0][1] = "[s]"
  60. g_srv_struct[0][2] = "[a]"
  61. g_srv_struct[0][3] = "[d]"
  62. g_srv_struct[0][4] = "[-]"
  63. g_srv_struct[0][5] = "[Duck]"
  64. g_srv_struct[0][6] = "[Jump]"
  65. g_srv_struct[0][7] = "[----]"
  66. g_srv_struct[0][8] = "[----]"
  67. g_srv_struct[0][9] = "Speed: %s"

  68. g_srv_struct[1][0] = "w"
  69. g_srv_struct[1][1] = "s"
  70. g_srv_struct[1][2] = "a"
  71. g_srv_struct[1][3] = "d"
  72. g_srv_struct[1][4] = "-"
  73. g_srv_struct[1][5] = "duck"
  74. g_srv_struct[1][6] = "jump"
  75. g_srv_struct[1][7] = "       "
  76. g_srv_struct[1][8] = "       "
  77. g_srv_struct[1][9] = "%s"

  78. g_srv_struct[2][0] = "w"
  79. g_srv_struct[2][1] = "s"
  80. g_srv_struct[2][2] = "a"
  81. g_srv_struct[2][3] = "d"
  82. g_srv_struct[2][4] = "-"
  83. g_srv_struct[2][5] = "Duck"
  84. g_srv_struct[2][6] = "Jump"
  85. g_srv_struct[2][7] = "----"
  86. g_srv_struct[2][8] = "----"
  87. g_srv_struct[2][9] = "Speed: %s"

  88. g_srv_struct[3][0] = "w"
  89. g_srv_struct[3][1] = "s"
  90. g_srv_struct[3][2] = "a"
  91. g_srv_struct[3][3] = "d"
  92. g_srv_struct[3][4] = "-"
  93. g_srv_struct[3][5] = "duck"
  94. g_srv_struct[3][6] = "jump"
  95. g_srv_struct[3][7] = "-----"
  96. g_srv_struct[3][8] = "-----"
  97. g_srv_struct[3][9] = "speed: %s"

  98. g_srv_struct[4][0] = "W"
  99. g_srv_struct[4][1] = "S"
  100. g_srv_struct[4][2] = "A"
  101. g_srv_struct[4][3] = "D"
  102. g_srv_struct[4][4] = "#"
  103. g_srv_struct[4][5] = "Duck"
  104. g_srv_struct[4][6] = "Jump"
  105. g_srv_struct[4][7] = "--..--"
  106. g_srv_struct[4][8] = "--..--"
  107. g_srv_struct[4][9] = "  |  %s"


  108. }

  109. // Client functions
  110. // -------------------------------------------------------------------------------------------------
  111. /*
  112.    Command: say /keys
  113.    Toggles plugin ON/OFF
  114. */
  115. public cl_ShowKeys (id)
  116. {
  117. new index = id - 1

  118. new arg[10]
  119. read_argv(0, arg, 9)

  120. if(equal(arg, "show_keys"))
  121. {
  122.   read_argv(1, arg, 9)
  123.   
  124.   if(equal(arg, "on") || equal(arg, "1"))
  125.   {
  126.    g_plr_showkeys[index] = true
  127.   } else if(equal(arg, "off") || equal(arg, "0"))
  128.   {
  129.    g_plr_showkeys[index] = false
  130.   } else {
  131.    client_print(id, print_console, "Usage: show_keys <on|off>")
  132.   }
  133.   
  134.   return 1
  135. }


  136. if(!is_user_connected(id))
  137. {
  138.   g_plr_showkeys[index] = false
  139.   return 1
  140. }

  141. if(g_plr_showkeys[index])
  142. {
  143.   g_plr_showkeys[index] = false
  144.   return 0
  145. }
  146. else
  147. {
  148.   g_plr_showkeys[index] = true
  149.   return 0
  150. }

  151. return 0
  152. }

  153. /*
  154.    say /keysmenu
  155.    Shows config menu
  156. */
  157. public cl_config(id)
  158. {
  159. menu_config_show(id)
  160. return 0
  161. }

  162. // Forwards
  163. // -------------------------------------------------------------------------------------------------
  164. public fwd_ClientPutInServer(id)
  165. {
  166. new index = id - 1

  167. if(get_pcvar_num(cvar_autostart) == 1) g_plr_showkeys[index] = true
  168. else g_plr_showkeys[index] = false

  169. g_plr_hudpos[index][0] = 0.8
  170. g_plr_hudpos[index][1] = 0.01

  171. g_plr_hudcolor[index][0] = 150
  172. g_plr_hudcolor[index][1] = 0
  173. g_plr_hudcolor[index][2] = 0

  174. g_plr_showspeed[index] = true

  175. config_load(id)
  176. }
  177. public fwd_PlayerPreThink(id)
  178. {
  179. static index

  180. index = id - 1

  181. if(is_user_connected(id) && is_user_alive(id) && g_plr_showkeys[index])
  182. {
  183.   new buttons = pev(id, pev_button)
  184.   new kw[10], ka[10], ks[10], kd[10], kjump[10], kduck[10]
  185.   
  186.   
  187.   
  188.   #if defined BHOP
  189.   new flags = pev(id, pev_flags)
  190.   if(flags & FL_ONGROUND)
  191.   {
  192.    if(g_counter[index] < 99)
  193.     g_counter[index]++
  194.   }
  195.   if( (g_flags[index] & FL_ONGROUND) && !(flags & FL_ONGROUND) )
  196.   {
  197.    if(g_counter[index] < 10)
  198.    {
  199.     set_hudmessage(0, 150, 0, -1.0, 0.1, 0, 0.0, 2.0, 0.0, 0.2, 2)
  200.     show_hudmessage(id, "Bhop frames: %i", g_counter[index])
  201.    }
  202.    
  203.    g_counter[index] = 0
  204.   }
  205.   g_flags[index] = flags
  206.   #endif
  207.   
  208.   
  209.   if(buttons & IN_FORWARD)
  210.   {
  211.    kw = g_srv_struct[g_plr_struct[index]][0]
  212.   }
  213.   else
  214.   {
  215.    kw = g_srv_struct[g_plr_struct[index]][4]
  216.   }
  217.   
  218.   if(buttons & IN_MOVELEFT)
  219.   {
  220.    ka = g_srv_struct[g_plr_struct[index]][2]
  221.   }
  222.   else
  223.   {
  224.    ka = g_srv_struct[g_plr_struct[index]][4]
  225.   }
  226.   
  227.   if(buttons & IN_MOVERIGHT)
  228.   {
  229.    kd = g_srv_struct[g_plr_struct[index]][3]
  230.   }
  231.   else
  232.   {
  233.    kd = g_srv_struct[g_plr_struct[index]][4]
  234.   }
  235.   
  236.   if(buttons & IN_BACK)
  237.   {
  238.    ks = g_srv_struct[g_plr_struct[index]][1]
  239.   }
  240.   else
  241.   {
  242.    ks = g_srv_struct[g_plr_struct[index]][4]
  243.   }
  244.   
  245.   if(buttons & IN_JUMP)
  246.   {
  247.    kjump = g_srv_struct[g_plr_struct[index]][6]
  248.   }
  249.   else
  250.   {
  251.    kjump = g_srv_struct[g_plr_struct[index]][8]
  252.   }
  253.   
  254.   if(buttons & IN_DUCK)
  255.   {
  256.    kduck = g_srv_struct[g_plr_struct[index]][5]
  257.   }
  258.   else
  259.   {
  260.    kduck = g_srv_struct[g_plr_struct[index]][7]
  261.   }
  262.   
  263.   set_hudmessage(g_plr_hudcolor[index][0], g_plr_hudcolor[index][1], g_plr_hudcolor[index][2],
  264.   g_plr_hudpos[index][0], g_plr_hudpos[index][1], 0, 2.5, 0.0, 0.0, 0.1,
  265.   g_srv_channel)
  266.   
  267.   new speedstr[32] = ""
  268.   
  269.   if(g_plr_showspeed[index])
  270.   {
  271.    new Float:speed[3]
  272.    pev(id, pev_velocity, speed)
  273.   
  274.    float_to_str (
  275.    floatsqroot(floatadd(floatpower(speed[0], 2.0), floatpower(speed[1], 2.0)))
  276.    , speedstr, 5)
  277.    format(speedstr, 31, g_srv_struct[g_plr_struct[index]][9], speedstr)
  278.   }
  279.   
  280.   switch(g_plr_struct[index])
  281.   {
  282.    case 0:
  283.     show_hudmessage(id, "   %s^n%s %s %s^n%s %s^n^n%s",
  284.     kw, ka, ks, kd, kduck, kjump, speedstr)
  285.    case 1:
  286.     show_hudmessage(id, "      %s^n    %s %s %s^n%s %s^n   %s",
  287.     kw, ka, ks, kd, kduck, kjump, speedstr)
  288.    case 2:
  289.     show_hudmessage(id, "  %s      %s^n%s %s %s    %s^n%s",
  290.     kw, kduck, ka, ks, kd,  kjump, speedstr)
  291.    case 3:
  292.     show_hudmessage(id, "  %s       %s %s^n%s %s %s    %s",
  293.     kw, kduck, kjump, ka, ks, kd, speedstr)
  294.    case 4:
  295.     show_hudmessage(id, " %s  |  %s %s %s  |  %s %s%s",
  296.     kw, ka, ks, kd, kduck, kjump, speedstr)
  297.    
  298.   }
  299. }

  300. switch(g_plr_configon[index])
  301. {
  302.   case 1: config_position_think(id)
  303.   case 2: config_color_think(id)
  304. }

  305. return 1
  306. }
  307. //
  308. // -------------------------------------------------------------------------------------------------
  309. public config_save(id)
  310. {
  311. new index = id - 1

  312. new color[8], position[18], speed[2], struct[2], config[32]

  313. color_enc(color, g_plr_hudcolor[index][0], g_plr_hudcolor[index][1], g_plr_hudcolor[index][2])
  314. position_enc(position, g_plr_hudpos[index][0], g_plr_hudpos[index][1])

  315. if(g_plr_showspeed[index]) speed = "1"
  316. else speed = "0"

  317. num_to_str(g_plr_struct[index], struct, 1)

  318. format(config, 31, "%sq%sq%sq%s", color, position, speed, struct)
  319. client_cmd(id, "setinfo ^"showkeys^" ^"%s^"", config)
  320. }
  321. public config_load(id)
  322. {
  323. new index = id - 1

  324. new config[32]
  325. get_user_info(id, "showkeys", config, 31)

  326. if(strlen(config) < 1)
  327. {
  328.   g_plr_struct[index] = 3
  329.   g_plr_showspeed[index] = true
  330.   g_plr_hudcolor[index] = {15, 15, 200}
  331.   g_plr_hudpos[index][0] = 0.4
  332.   g_plr_hudpos[index][1] = 0.05
  333. } else {
  334.   new color[8], position[18], speed[2], struct[2]
  335.   
  336.   format(color, 7, config)
  337.   format(position, 17, config[8])
  338.   format(speed, 1, config[26])
  339.   format(struct, 1, config[28])
  340.   
  341.   color_dec(color, g_plr_hudcolor[index][0], g_plr_hudcolor[index][1], g_plr_hudcolor[index][2])
  342.   position_dec(position, g_plr_hudpos[index][0], g_plr_hudpos[index][1])
  343.   
  344.   g_plr_showspeed[index] = equal(speed, "1") ? true : false
  345.   g_plr_struct[index] = str_to_num(struct)
  346. }
  347. }

  348. // Config Menu
  349. //--------------------------------------------------------------------------------------------------
  350. public menu_config_show(id) {
  351. new index = id - 1

  352. new menustr[512]

  353. g_plr_showkeys[index] = true

  354. new str[32]

  355. add(menustr, 511, "\yShowkeys config^n^n")
  356. add(menustr, 511, "\r01. \wPosition^n")
  357. add(menustr, 511, "\r02. \wColor^n")
  358. add(menustr, 511, "\r03. \wStructure")
  359. format(str, 31, " \d[%i/5]^n", g_plr_struct[index]+1)
  360. add(menustr, 511, str)

  361. if(g_plr_showspeed[index]) add(menustr, 511, "\r04. \wShow Speed \d[ON]^n")
  362. else add(menustr, 511, "\r04. \wShow Speed \d[OFF]^n")

  363. add(menustr, 511, "\r05. \wReload Settings^n")
  364. add(menustr, 511, "\r06. \wSave Settings^n^n")
  365. add(menustr, 511, "\y00. Close")

  366. show_menu(id, MENU_CONFIG, menustr)
  367. }
  368. public menu_config_act(id, key) {
  369. new index = id - 1

  370. switch (key) {
  371.   case 0: {
  372.    menu_position_show(id)
  373.    return 1
  374.   }
  375.   case 1: {
  376.    menu_color_show(id)
  377.    return 1
  378.   }
  379.   case 2: {
  380.    g_plr_struct[index] = g_plr_struct[index] > 3 ? 0 : g_plr_struct[index] + 1
  381.    menu_config_show(id)
  382.   }
  383.   case 3: {
  384.    g_plr_showspeed[index] = !g_plr_showspeed[index]
  385.    menu_config_show(id)
  386.   }
  387.   case 4: {
  388.    client_print(id, print_chat, "[Showkeys] Settings loaded.")
  389.    config_load(id)
  390.    menu_config_show(id)
  391.   }
  392.   case 5: {
  393.    client_print(id, print_chat, "[Showkeys] Settings saved.")
  394.    config_save(id)
  395.    menu_config_show(id)
  396.   }
  397.   case 6: {
  398.    
  399.   }
  400. }

  401. return 1
  402. }
  403. // Color and position menu
  404. // -------------------------------------------------------------------------------------------------
  405. public menu_position_show(id)
  406. {
  407. new index = id - 1

  408. new menustr[512]

  409. add(menustr, 511, "\yShowkeys position^n^n")
  410. add(menustr, 511, "\r a. \dLeft^n")
  411. add(menustr, 511, "\r d. \dRight^n")
  412. add(menustr, 511, "\r w. \dUp^n")
  413. add(menustr, 511, "\r s. \dDown^n^n")
  414. add(menustr, 511, "\rJump. \yGo back")
  415. show_menu(id, MENU_POSITION, menustr)

  416. g_plr_configon[index] = 1
  417. g_plr_showkeys[index] = true
  418. }
  419. public menu_position_act(id)
  420. {
  421. new index = id - 1

  422. g_plr_configon[index] = 0
  423. menu_config_show(id)
  424. return 1
  425. }
  426. public menu_color_show(id)
  427. {
  428. new index = id - 1

  429. new menustr[512]

  430. g_plr_configon[index] = 2
  431. g_plr_showkeys[index] = true

  432. new red[64], green[64], blue[64]

  433. switch (g_plr_editcolor[index])
  434. {
  435.   case 1: {
  436.    format(red, 63, "\r01. \wRed (%i)^n", g_plr_hudcolor[index][0])
  437.    format(green, 63, "\r02. \dGreen (%i)^n", g_plr_hudcolor[index][1])
  438.    format(blue, 63, "\r03. \dBlue (%i)^n", g_plr_hudcolor[index][2])
  439.   } case 2: {
  440.    format(red, 63, "\r01. \dRed (%i)^n", g_plr_hudcolor[index][0])
  441.    format(green, 63, "\r02. \wGreen (%i)^n", g_plr_hudcolor[index][1])
  442.    format(blue, 63, "\r03. \dBlue (%i)^n", g_plr_hudcolor[index][2])
  443.   } case 3: {
  444.    format(red, 63, "\r01. \dRed (%i)^n", g_plr_hudcolor[index][0])
  445.    format(green, 63, "\r02. \dGreen (%i)^n", g_plr_hudcolor[index][1])
  446.    format(blue, 63, "\r03. \wBlue (%i)^n", g_plr_hudcolor[index][2])
  447.   } default: {
  448.    format(red, 63, "\r01. \dRed (%i)^n", g_plr_hudcolor[index][0])
  449.    format(green, 63, "\r02. \dGreen (%i)^n", g_plr_hudcolor[index][1])
  450.    format(blue, 63, "\r03. \dBlue (%i)^n", g_plr_hudcolor[index][2])
  451.   }
  452. }

  453. add(menustr, 511, "\yShowkeys color^n^n")
  454. add(menustr, 511, red)
  455. add(menustr, 511, green)
  456. add(menustr, 511, blue)
  457. add(menustr, 511, "\dUse \rw\d and \rs\d to set the value.^n^n")
  458. add(menustr, 511, "\y00. Go back")

  459. format(menustr, 511, menustr, red, green, blue)

  460. show_menu(id, MENU_COLOR, menustr)
  461. }
  462. public menu_color_act(id, key)
  463. {
  464. new index = id - 1

  465. switch(key)
  466. {
  467.   case 0:{
  468.    g_plr_configon[index] = 2
  469.    g_plr_editcolor[index] = 1
  470.    menu_color_show(id)
  471.   } case 1: {
  472.    g_plr_configon[index] = 2
  473.    g_plr_editcolor[index] = 2
  474.    menu_color_show(id)
  475.   } case 2: {
  476.    g_plr_configon[index] = 2
  477.    g_plr_editcolor[index] = 3
  478.    menu_color_show(id)
  479.   } default: {
  480.    set_pev(id, pev_maxspeed, 250.0)
  481.    g_plr_configon[index] = 0
  482.    menu_config_show(id)
  483.   }
  484. }
  485. return 1
  486. }
  487. // Position and color config think.
  488. // -------------------------------------------------------------------------------------------------
  489. public config_position_think(id)
  490. {
  491. new index = id - 1

  492. new buttons = pev(id, pev_button)
  493. set_pev(id, pev_maxspeed, -1.0)

  494. new Float:speed=0.005

  495. // left
  496. if(buttons & IN_MOVELEFT) g_plr_buttons[index][0]++
  497. else g_plr_buttons[index][0] = 0
  498. // right
  499. if(buttons & IN_MOVERIGHT) g_plr_buttons[index][1]++
  500. else g_plr_buttons[index][1] = 0
  501. // forward
  502. if(buttons & IN_FORWARD) g_plr_buttons[index][2]++
  503. else g_plr_buttons[index][2] = 0
  504. // back
  505. if(buttons & IN_BACK) g_plr_buttons[index][3]++
  506. else g_plr_buttons[index][3] = 0
  507. // any
  508. if((buttons&IN_MOVELEFT)||(buttons&IN_MOVERIGHT)||(buttons&IN_FORWARD)||
  509. (buttons&IN_BACK)) g_plr_buttons[index][4]++
  510. else g_plr_buttons[index][4] = 0

  511. if(g_plr_buttons[index][4] < 10) speed=0.0005
  512. else if(g_plr_buttons[index][4] < 20) speed=0.001
  513. else if(g_plr_buttons[index][4] < 30) speed=0.002
  514. if(g_plr_buttons[index][0] > 0)
  515.   if(g_plr_hudpos[index][0]-speed >= 0.0) g_plr_hudpos[index][0] -= speed // left
  516. if(g_plr_buttons[index][1] > 0)
  517.   if(g_plr_hudpos[index][0]+speed <= 1.0) g_plr_hudpos[index][0] += speed // right
  518. if(g_plr_buttons[index][2] > 0)
  519.   if(g_plr_hudpos[index][1]-speed >= 0.0) g_plr_hudpos[index][1] -= speed // up
  520. if(g_plr_buttons[index][3] > 0)
  521.   if(g_plr_hudpos[index][1]+speed <= 1.0) g_plr_hudpos[index][1] += speed // down


  522. if(buttons & IN_JUMP)
  523. {
  524.   set_pev(id, pev_maxspeed, 250.0)
  525.   g_plr_configon[index] = 0
  526.   menu_config_show(id)
  527. } else {
  528.   if(g_plr_buttons[index][4] >= 10 && g_plr_buttons[index][4] % 10 == 0) menu_position_show(id)
  529. }

  530. }
  531. public config_color_think(id)
  532. {
  533. new index = id - 1

  534. if(g_plr_editcolor[index] < 1) return 0
  535. new color = g_plr_editcolor[index] - 1

  536. new buttons = pev(id, pev_button)
  537. set_pev(id, pev_maxspeed, -1.0)

  538. new oldw, olds
  539. oldw = g_plr_buttons[index][2]
  540. olds = g_plr_buttons[index][3]

  541. // forward
  542. if(buttons & IN_FORWARD) g_plr_buttons[index][2]++
  543. else g_plr_buttons[index][2] = 0
  544. // back
  545. if(buttons & IN_BACK) g_plr_buttons[index][3]++
  546. else g_plr_buttons[index][3] = 0


  547. if(
  548. (oldw==0 && g_plr_buttons[index][2]>0) ||
  549. (g_plr_buttons[index][2] > 30 && g_plr_buttons[index][2] % 5 == 0)
  550. ){
  551.   if(g_plr_hudcolor[index][color] + 5 <= 255) g_plr_hudcolor[index][color] += 5
  552.   else g_plr_hudcolor[index][color] = 255
  553.   
  554.   menu_color_show(id)
  555. }

  556. if(
  557. (olds==0 && g_plr_buttons[index][3]>0) ||
  558. (g_plr_buttons[index][3] > 30 && g_plr_buttons[index][3] % 5 == 0)
  559. ){
  560.   if(g_plr_hudcolor[index][color] - 5 >= 0) g_plr_hudcolor[index][color] -= 5
  561.   else g_plr_hudcolor[index][color] = 0
  562.    
  563.   menu_color_show(id)
  564. }

  565. return 0
  566. }

  567. // Color enc/dec html hex / dec rgb
  568. // -------------------------------------------------------------------------------------------------

  569. // encode rgb to html hex
  570. stock color_enc(output[], r, g, b)
  571. {
  572. new red[3], green[3], blue[3]

  573. num_to_hex(red, 2, r)
  574. num_to_hex(green, 2, g)
  575. num_to_hex(blue, 2, b)

  576. format(output, 7, "#%s%s%s", red, green, blue)
  577. }
  578. stock num_to_hex(output[], len, num)
  579. {
  580. new i[2]
  581. i[1] = 0

  582. if(num == 0) format(output, len,"00")
  583. else if(num < 16) {
  584.   i[0] = (num < 10 ? num + 48 : num + 55)
  585.   format(output, len, "0%s", i)
  586. } else while (num > 0)
  587. {
  588.   i[0] = num % 16
  589.   num = num / 16
  590.   
  591.   if(i[0] <= 9) i[0] += 48
  592.   else i[0] += 55
  593.   
  594.   format(output, len, "%s%s", i, output)
  595. }
  596. }
  597. stock hex_to_num(const hex[])
  598. {
  599. new r, num
  600. for(new i=0; i<strlen(hex); i++)
  601. {
  602.   num = hex[i]
  603.   num = num >= 65 ? num - 55 : num - 48
  604.   
  605.   if(num < 0 || num > 15) return 0
  606.   
  607.   r = r * 16 + num
  608. }

  609. return r
  610. }
  611. // decode html hex to dec rgb
  612. stock color_dec(const color[], &r, &g, &b)
  613. {
  614. new i[3]
  615. i[2] = 0

  616. i[0] = color[1]
  617. i[1] = color[2]
  618. r = hex_to_num(i)

  619. i[0] = color[3]
  620. i[1] = color[4]
  621. g = hex_to_num(i)

  622. i[0] = color[5]
  623. i[1] = color[6]
  624. b = hex_to_num(i)
  625. }
  626. // Position enc/dec from float to string...
  627. // -------------------------------------------------------------------------------------------------
  628. stock position_enc(output[], Float:x, Float:y)
  629. {
  630. format(output, 17, "%fx%f", x, y)
  631. }
  632. stock position_dec(position[], & Float:x, & Float:y)
  633. {
  634. new xstr[9], ystr[9]

  635. format(xstr, 8, position)
  636. format(ystr, 5, position[9])

  637. x = str_to_float(xstr)
  638. y = str_to_float(ystr)
  639. }

复制代码



//--------------------------------------------------------------------------

//And Multifunction is ,
//SpecInfo v1.3.1.sma:
//Description:
//This plugin displays a list of spectators currently viewing the live player.
//This list is visible to the living player as well as other players currently
//spectating that player.  Also spectators can see which movement commands the
//the live player is using.   

//Commands:
//say /speclist : Toggle viewing list of spectators.
//say /speckeys : Toggle viewing keys of player you are spectating.
//say /spechide : Immune admins toggle whether or not they're hidden from list.
//say /showkeys : View your own keys on screen while alive.


  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <engine>
  4. #include <fakemeta>
  5. new const VERSION[ ] = "1.3.1"
  6. new const TRKCVAR[ ] = "specinfo_version"
  7. #define IMMUNE_FLAG ADMIN_IMMUNITY
  8. #define KEYS_STR_LEN 31
  9. #define LIST_STR_LEN 610
  10. #define BOTH_STR_LEN KEYS_STR_LEN + LIST_STR_LEN
  11. //cl_prefs constants
  12. #define FL_LIST    ( 1 << 0 )
  13. #define FL_KEYS    ( 1 << 1 )
  14. #define FL_OWNKEYS ( 1 << 2 )
  15. #define FL_HIDE    ( 1 << 3 )
  16. //cvar pointers
  17. new p_enabled, p_list_enabled, p_keys_enabled, p_list_default, p_keys_default;
  18. new p_red, p_grn, p_blu, p_immunity;
  19. //data arrays
  20. new cl_keys[33], cl_prefs[33];
  21. new keys_string[33][KEYS_STR_LEN + 1], list_string[33][LIST_STR_LEN + 1]
  22. new cl_names[33][21], spec_ids[33][33];
  23. public plugin_init( )
  24. {
  25. register_plugin( "SpecInfo", VERSION, "Ian Cammarata" );
  26. register_cvar( TRKCVAR, VERSION, FCVAR_SERVER );
  27. set_cvar_string( TRKCVAR, VERSION );

  28. p_enabled = register_cvar( "si_enabled", "1" );
  29. p_list_enabled = register_cvar( "si_list_enabled", "1" );
  30. p_keys_enabled = register_cvar( "si_keys_enabled", "1" );
  31. p_list_default = register_cvar( "si_list_default", "1" );
  32. p_keys_default = register_cvar( "si_keys_default", "1" );
  33. p_immunity = register_cvar( "si_immunity", "1" );
  34. p_red = register_cvar( "si_msg_r", "45" );
  35. p_grn = register_cvar( "si_msg_g", "89" );
  36. p_blu = register_cvar( "si_msg_b", "116" );

  37. register_clcmd( "say /speclist", "toggle_list", _, "Toggle spectator list." );
  38. register_clcmd( "say /speckeys", "toggle_keys", _, "Toggle spectator keys." );
  39. register_clcmd( "say /showkeys", "toggle_ownkeys", _, "Toggle viewing own keys." );
  40. register_clcmd( "say /spechide", "toggle_hide", IMMUNE_FLAG, "Admins toggle being hidden from list." );

  41. set_task( 1.0, "list_update", _, _, _, "b" );
  42. set_task( 0.1, "keys_update", _, _, _, "b" );

  43. register_dictionary( "specinfo.txt" );
  44. }
  45. public client_connect( id )
  46. {
  47. cl_prefs[id] = 0;
  48. if( !is_user_bot( id ) )
  49. {
  50.   if( get_pcvar_num( p_list_default ) ) cl_prefs[id] |= FL_LIST;
  51.   if( get_pcvar_num( p_keys_default ) ) cl_prefs[id] |= FL_KEYS;
  52. }
  53. get_user_name( id, cl_names[id], 20 );
  54. return PLUGIN_CONTINUE;
  55. }
  56. public client_infochanged( id )
  57. {
  58. get_user_name( id, cl_names[id], 20 );
  59. return PLUGIN_CONTINUE;
  60. }
  61. public list_update( )
  62. {
  63. if( get_pcvar_num( p_enabled ) && get_pcvar_num ( p_list_enabled ) )
  64.   {
  65.   new players[32], num, id, id2, i, j;
  66.   for( i = 1; i < 33; i++ ) spec_ids[i][0] = 0;
  67.   
  68.   get_players( players, num, "bch" );
  69.   for( i = 0; i < num; i++ )
  70.     {
  71.    id = players[i];
  72.    if( !( get_user_flags( id ) & IMMUNE_FLAG && get_pcvar_num( p_immunity ) && cl_prefs[id] & FL_HIDE ) )
  73.    {
  74.     id2 = pev( id, pev_iuser2 );
  75.     if( id2 )
  76.     {
  77.      spec_ids[ id2 ][ 0 ]++;
  78.      spec_ids[ id2 ][ spec_ids[ id2 ][ 0 ] ] = id;
  79.     }
  80.    }
  81.   }
  82.   new tmplist[ LIST_STR_LEN + 1 ], tmpstr[41];
  83.   new count, namelen, tmpname[21];
  84.   for( i=1; i<33; i++ )
  85.     {
  86.    count = spec_ids[i][0];
  87.    if( count )
  88.    {
  89.     namelen = ( LIST_STR_LEN - 10 ) / count;
  90.     clamp( namelen, 10, 20 );
  91.     format( tmpname, namelen, cl_names[i] );
  92.     formatex( tmplist, LIST_STR_LEN - 1, "^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t(%d) %s %s:^n", count, "%L", tmpname);
  93.     for( j=1; j<=count; j++ )
  94.         {
  95.      format( tmpname, namelen, cl_names[spec_ids[i][j]]);
  96.      formatex( tmpstr, 40, "^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t%s", tmpname );
  97.      if( strlen( tmplist ) + strlen( tmpstr ) + ( 11 - j ) < ( LIST_STR_LEN - 1 ) )
  98.       format( tmplist, LIST_STR_LEN - 10, "%s%s^n", tmplist, tmpstr );
  99.      else
  100.           {
  101.       format( tmplist, LIST_STR_LEN, "%s...^n", tmplist );
  102.       break;
  103.      }
  104.     }
  105.     if( count < 10 )
  106.           format( tmplist, LIST_STR_LEN,
  107.       "%s^n^n^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^t^tSpecInfo v%s^n",
  108.       tmplist, VERSION
  109.      );
  110.     for( j+=0; j<10; j++ )
  111.           format( tmplist, LIST_STR_LEN, "%s%s", tmplist, "^n" );
  112.     list_string[i] = tmplist;
  113.    }
  114.   }
  115.   get_players( players, num, "ch" );
  116.   for( i=0; i<num; i++ ) clmsg( players[i] );
  117. }
  118. return PLUGIN_HANDLED;
  119. }
  120. public keys_update( )
  121. {
  122. if( !get_pcvar_num( p_enabled ) && !get_pcvar_num( p_keys_enabled ) ) return;
  123. new players[32], num, id, i;
  124. get_players( players, num, "a" );
  125. for( i = 0; i < num; i++ )
  126.   {
  127.   id = players[i];
  128.   formatex( keys_string[id], KEYS_STR_LEN, " ^n^t^t%s^t^t^t%s^n^t%s %s %s^t^t%s",
  129.    cl_keys[id] & IN_FORWARD ? "W" : " .",
  130.    "%L",
  131.    cl_keys[id] & IN_MOVELEFT ? "A" : ".",
  132.    cl_keys[id] & IN_BACK ? "S" : ".",
  133.    cl_keys[id] & IN_MOVERIGHT ? "D" : ".",
  134.    "%L"
  135.   );
  136.   
  137.   //Flags stored in string to fill translation char in clmsg function
  138.   keys_string[id][0] = 0;
  139.   if( cl_keys[id] & IN_JUMP ) keys_string[id][0] |= IN_JUMP;
  140.   if( cl_keys[id] & IN_DUCK ) keys_string[id][0] |= IN_DUCK;
  141.   
  142.   cl_keys[id] = 0;
  143. }

  144. new id2;
  145. get_players( players, num, "ch" );
  146. for( i=0; i<num; i++ )
  147.   {
  148.   id = players[i];
  149.   if( is_user_alive( id ) )
  150.   {
  151.    if( cl_prefs[id] & FL_OWNKEYS ) clmsg( id );
  152.   }
  153.   else
  154.   {
  155.    id2 = pev( id, pev_iuser2 );
  156.    if( cl_prefs[id] & FL_KEYS && id2 && id2 != id ) clmsg( id );
  157.   }
  158. }
  159. }
  160. public server_frame( )
  161. {
  162. if( get_pcvar_num( p_enabled ) && get_pcvar_num( p_keys_enabled ) )
  163.   {
  164.   new players[32], num, id;
  165.   get_players( players, num, "a" );
  166.   for( new i = 0; i < num; i++ )
  167.   {
  168.    id = players[i];
  169.    if( get_user_button( id ) & IN_FORWARD )
  170.     cl_keys[id] |= IN_FORWARD;
  171.    if( get_user_button( id ) & IN_BACK )
  172.     cl_keys[id] |= IN_BACK;
  173.    if( get_user_button( id ) & IN_MOVELEFT )
  174.     cl_keys[id] |= IN_MOVELEFT;
  175.    if( get_user_button( id ) & IN_MOVERIGHT )
  176.     cl_keys[id] |= IN_MOVERIGHT;
  177.    if( get_user_button( id ) & IN_DUCK )
  178.     cl_keys[id] |= IN_DUCK;
  179.    if( get_user_button( id ) & IN_JUMP )
  180.     cl_keys[id] |= IN_JUMP;
  181.   }
  182. }
  183. return PLUGIN_CONTINUE
  184. }
  185. public clmsg( id )
  186. {
  187. if( !id ) return;

  188. new prefs = cl_prefs[id];

  189. new bool:show_own = false;
  190. if( is_user_alive( id ) && prefs & FL_OWNKEYS ) show_own = true;

  191. if( is_user_alive( id ) && !show_own )
  192.   {
  193.   if( prefs & FL_LIST && spec_ids[id][0] && get_pcvar_num( p_list_enabled ) )
  194.   {
  195.    set_hudmessage(
  196.         get_pcvar_num( p_red ),
  197.         get_pcvar_num( p_grn ),
  198.         get_pcvar_num( p_blu ),
  199.         0.7, /*x*/
  200.         0.1, /*y*/
  201.         0, /*fx*/
  202.         0.0, /*fx time*/
  203.         1.1, /*hold time*/
  204.         0.1, /*fade in*/
  205.         0.1, /*fade out*/
  206.         3 /*chan*/
  207.    );
  208.    show_hudmessage( id, list_string[id], id, "SPECTATING" );
  209.   }
  210. }
  211. else
  212.   {
  213.   new id2;
  214.   if( show_own ) id2 = id;
  215.   else id2 = pev( id, pev_iuser2 );
  216.   if( !id2 ) return;
  217.   
  218.   if( prefs & FL_LIST || prefs & FL_KEYS || show_own )
  219.     {
  220.    set_hudmessage(
  221.         get_pcvar_num( p_red ),
  222.         get_pcvar_num( p_grn ),
  223.         get_pcvar_num( p_blu ),
  224.         0.48, /*x*/
  225.         0.14, /*y*/
  226.         0, /*fx*/
  227.         0.0, /*fx time*/
  228.         prefs & FL_KEYS || show_own ? 0.1 : 1.1, /*hold time*/
  229.         0.1, /*fade in*/
  230.         0.1, /*fade out*/
  231.         3 /*chan*/
  232.    );
  233.    new msg[BOTH_STR_LEN + 1];
  234.    if( prefs & FL_LIST && get_pcvar_num( p_list_enabled ) && spec_ids[id2][0] )
  235.         formatex(msg,BOTH_STR_LEN,list_string[id2],id,"SPECTATING");
  236.    else msg ="^n^n^n^n^n^n^n^n^n^n^n^n";
  237.    if( get_pcvar_num( p_keys_enabled ) && ( prefs & FL_KEYS || show_own ) )
  238.       {
  239.         format( msg, BOTH_STR_LEN, "%s%s", msg, keys_string[id2][1] );
  240.         format( msg, BOTH_STR_LEN, msg,
  241.      id, keys_string[id2][0] & IN_JUMP ? "JUMP" : "LAME",
  242.      id, keys_string[id2][0] & IN_DUCK ? "DUCK" : "LAME"
  243.     );
  244.       }
  245.    show_hudmessage( id, msg );
  246.   }
  247. }
  248. }
  249. public set_hudmsg_flg_notify( )
  250. {
  251. set_hudmessage(
  252.   get_pcvar_num( p_red ),
  253.   get_pcvar_num( p_grn ),
  254.   get_pcvar_num( p_blu ),
  255.   -1.0, /*x*/
  256.   0.8, /*y*/
  257.   0, /*fx*/
  258.   0.0, /*fx time*/
  259.   3.0, /*hold time*/
  260.   0.0, /*fade in*/
  261.   0.0, /*fade out*/
  262.   -1 /*chan*/
  263. );
  264. }
  265. public toggle_list( id )
  266. {
  267. set_hudmsg_flg_notify( );
  268. cl_prefs[id] ^= FL_LIST;
  269. show_hudmessage( id, "%L", id, cl_prefs[id] & FL_LIST ? "SPEC_LIST_ENABLED" : "SPEC_LIST_DISABLED" );
  270. return PLUGIN_HANDLED;
  271. }
  272. public toggle_keys( id )
  273. {
  274. set_hudmsg_flg_notify( );
  275. cl_prefs[id] ^= FL_KEYS;
  276. show_hudmessage( id, "%L", id, cl_prefs[id] & FL_KEYS ? "SPEC_KEYS_ENABLED" : "SPEC_KEYS_DISABLED" );
  277. return PLUGIN_HANDLED;
  278. }
  279. public toggle_ownkeys( id )
  280. {
  281. set_hudmsg_flg_notify( );
  282. cl_prefs[id] ^= FL_OWNKEYS;
  283. show_hudmessage( id, "%L", id, cl_prefs[id] & FL_OWNKEYS ? "SPEC_OWNKEYS_ENABLED" : "SPEC_OWNKEYS_DISABLED" );
  284. return PLUGIN_HANDLED;
  285. }
  286. public toggle_hide( id, level, cid )
  287. {
  288. if( cmd_access( id, level, cid, 0 ) )
  289. {
  290.   set_hudmsg_flg_notify( );
  291.   cl_prefs[id] ^= FL_HIDE;
  292.   show_hudmessage( id, "%L", id, cl_prefs[id] & FL_HIDE ? "SPEC_HIDE_ENABLED" : "SPEC_HIDE_DISABLED" );
  293. }
  294. return PLUGIN_HANDLED;
  295. }

复制代码

该用户从未签到

 楼主| 发表于 2010-1-18 20:10:15 | 显示全部楼层
回复 5# Pledges


    咱说中文行不

该用户从未签到

发表于 2010-1-18 20:25:28 | 显示全部楼层
呵呵 不好意思哈!

将showkeys.amxx 放到 /cstrike/addons/amxmodx/plugins/
打开 /cstrike/addons/amxmodx/configs/plugins.ini 另其一行写入showkeys.amxx 保存 OK

评分

参与人数 1金币 +5 +5 收起 理由
wzq5417601 + 5 + 5 鼓励分享

查看全部评分

该用户从未签到

 楼主| 发表于 2010-1-18 21:13:53 | 显示全部楼层
回复 7# Pledges


    再给个下载地址好不,再给分。。

该用户从未签到

发表于 2010-1-18 21:20:13 | 显示全部楼层
回复  Pledges


    再给个下载地址好不,再给分。。
wzq5417601 发表于 2010-1-18 21:13



    我Ri  你不会吧,咱们论坛上下载地址多的是,而且我上面吧源代码都给你了!

汗啊!果然懒的够呛,有我当年的风范!哈哈!开玩笑的!
下载地址
http://Pledges.ys168.com

评分

参与人数 1金币 +3 +3 收起 理由
wzq5417601 + 3 + 3 那么多到底是哪个啊。。。

查看全部评分

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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