找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1741|回复: 12

【已解决】 求助主视角显示按键插件

[复制链接]

该用户从未签到

发表于 2010-3-19 13:10:41 | 显示全部楼层 |阅读模式
本帖最后由 Pledges 于 2010-4-20 22:44 编辑



有没有助主视角显示按键插件 , 有的话给我一个

该用户从未签到

发表于 2010-3-19 13:50:06 | 显示全部楼层
问问当官的看看

该用户从未签到

发表于 2010-3-19 14:11:32 | 显示全部楼层

  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. }

复制代码

该用户从未签到

发表于 2010-3-19 17:51:10 | 显示全部楼层
我滴 乖乖``~~

该用户从未签到

 楼主| 发表于 2010-3-20 12:16:38 | 显示全部楼层
  当官的 在没有.   给一个给小弟吧

该用户从未签到

发表于 2010-3-20 14:33:09 | 显示全部楼层
当官的 在没有.   给一个给小弟吧
aa825583615 发表于 2010-3-20 12:16



    我不是给你了嘛     3#那个

该用户从未签到

发表于 2010-3-20 14:45:13 | 显示全部楼层
回复 6# Pledges


    估计LZ不会转插件

该用户从未签到

发表于 2010-3-20 20:19:52 | 显示全部楼层
本帖最后由 Pledges 于 2010-3-20 20:25 编辑

回复 7# SiMen.iiN


    无奈啊,

  1. //使用到的命令
  2. register_clcmd("say /keys","cl_ShowKeys")
  3. register_clcmd("show_keys","cl_ShowKeys")
  4. register_clcmd("say /keysmenu","cl_config")
  5. register_clcmd("say /keyscfg","cl_config")
  6. register_clcmd("say /keysconf","cl_config")
  7. register_clcmd("say /keysconfig","cl_config")
复制代码


点击进入下载-Showkeys.sma
点击进入下载-Showkeys.amxx

该用户从未签到

 楼主| 发表于 2010-3-21 07:11:17 | 显示全部楼层
回复 8# Pledges


       我还真不会用. 怎么弄教下嘛

该用户从未签到

发表于 2010-3-21 11:45:19 | 显示全部楼层
回复 9# aa825583615


copy  showkeys.amxx   to \addons\amxmodx\plugins\

open \addons\amxmodx\configs\plugins.ini

write showkeys.amxx

command    say /keysmenu

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

本版积分规则

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