找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 633|回复: 4

【已解决】 §求§能报时的插件!

[复制链接]

该用户从未签到

发表于 2010-11-26 08:06:20 | 显示全部楼层 |阅读模式
就是像赛盟服务器里那样,输入thetime,系统就会显示及播报时间的…
最好能给单独的…

该用户从未签到

发表于 2010-11-26 09:45:20 | 显示全部楼层
XJ插件貌似可以的

该用户从未签到

发表于 2010-11-26 10:43:28 | 显示全部楼层
哎。你求的东西都是那么古怪啊!

该用户从未签到

 楼主| 发表于 2010-11-26 11:57:53 | 显示全部楼层
回复 2# shihaibao64168
    赛盟的也可以,可放我家就没用了…所以我想求单独的

该用户从未签到

发表于 2010-11-26 12:54:30 | 显示全部楼层
timeleft.sma
  1. #include <amxmodx>

  2. new g_TimeSet[32][2]
  3. new g_LastTime
  4. new g_CountDown
  5. new g_Switch

  6. public plugin_init()
  7. {
  8. register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
  9. register_dictionary("timeleft.txt")
  10. register_cvar("amx_time_voice", "1")
  11. register_srvcmd("amx_time_display", "setDisplaying")
  12. register_cvar("amx_timeleft", "00:00", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
  13. register_clcmd("say timeleft", "sayTimeLeft", 0, "- displays timeleft")
  14. register_clcmd("say thetime", "sayTheTime", 0, "- displays current time")

  15. set_task(0.8, "timeRemain", 8648458, "", 0, "b")
  16. }

  17. public sayTheTime(id)
  18. {
  19. if (get_cvar_num("amx_time_voice"))
  20. {
  21. new mhours[6], mmins[6], whours[32], wmins[32], wpm[6]

  22. get_time("%H", mhours, 5)
  23. get_time("%M", mmins, 5)

  24. new mins = str_to_num(mmins)
  25. new hrs = str_to_num(mhours)

  26. if (mins)
  27. num_to_word(mins, wmins, 31)
  28. else
  29. wmins[0] = 0

  30. if (hrs < 12)
  31. wpm = "am "
  32. else
  33. {
  34. if (hrs > 12) hrs -= 12
  35. wpm = "pm "
  36. }

  37. if (hrs)
  38. num_to_word(hrs, whours, 31)
  39. else
  40. whours = "twelve "

  41. client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
  42. }

  43. new ctime[64]

  44. get_time("%m/%d/%Y - %H:%M:%S", ctime, 63)
  45. client_print(0, print_chat, "%L: %s", LANG_PLAYER, "THE_TIME", ctime)

  46. return PLUGIN_CONTINUE
  47. }

  48. public sayTimeLeft(id)
  49. {
  50. if (get_cvar_float("mp_timelimit"))
  51. {
  52. new a = get_timeleft()

  53. if (get_cvar_num("amx_time_voice"))
  54. {
  55. new svoice[128]
  56. setTimeVoice(svoice, 127, 0, a)
  57. client_cmd(id, "%s", svoice)
  58. }
  59. client_print(0, print_chat, "%L: %d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60), (a % 60))
  60. }
  61. else
  62. client_print(0, print_chat, "%L", LANG_PLAYER, "NO_T_LIMIT")

  63. return PLUGIN_CONTINUE
  64. }

  65. setTimeText(text[], len, tmlf, id)
  66. {
  67. new secs = tmlf % 60
  68. new mins = tmlf / 60

  69. if (secs == 0)
  70. format(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
  71. else if (mins == 0)
  72. format(text, len, "%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
  73. else
  74. format(text, len, "%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
  75. }

  76. setTimeVoice(text[], len, flags, tmlf)
  77. {
  78. new temp[7][32]
  79. new secs = tmlf % 60
  80. new mins = tmlf / 60

  81. for (new a = 0;a < 7;++a)
  82. temp[a][0] = 0

  83. if (secs > 0)
  84. {
  85. num_to_word(secs, temp[4], 31)

  86. if (!(flags & 8))
  87. temp[5] = "seconds " /* there is no "second" in default hl */
  88. }

  89. if (mins > 59)
  90. {
  91. new hours = mins / 60

  92. num_to_word(hours, temp[0], 31)

  93. if (!(flags & 8))
  94. temp[1] = "hours "

  95. mins = mins % 60
  96. }

  97. if (mins > 0)
  98. {
  99. num_to_word(mins, temp[2], 31)

  100. if (!(flags & 8))
  101. temp[3] = "minutes "
  102. }

  103. if (!(flags & 4))
  104. temp[6] = "remaining "

  105. return format(text, len, "spk ^"vox/%s%s%s%s%s%s%s^"", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6])
  106. }

  107. findDispFormat(time)
  108. {
  109. for (new i = 0; g_TimeSet[i][0]; ++i)
  110. {
  111. if (g_TimeSet[i][1] & 16)
  112. {
  113. if (g_TimeSet[i][0] > time)
  114. {
  115. if (!g_Switch)
  116. {
  117. g_CountDown = g_Switch = time
  118. remove_task(8648458)
  119. set_task(1.0, "timeRemain", 34543, "", 0, "b")
  120. }

  121. return i
  122. }
  123. }
  124. else if (g_TimeSet[i][0] == time)
  125. {
  126. return i
  127. }
  128. }

  129. return -1
  130. }

  131. public setDisplaying()
  132. {
  133. new arg[32], flags[32], num[32]
  134. new argc = read_argc() - 1
  135. new i = 0

  136. while (i < argc && i < 32)
  137. {
  138. read_argv(i + 1, arg, 31)
  139. parse(arg, flags, 31, num, 31)

  140. g_TimeSet[i][0] = str_to_num(num)
  141. g_TimeSet[i][1] = read_flags(flags)

  142. i++
  143. }
  144. g_TimeSet[i][0] = 0

  145. return PLUGIN_HANDLED
  146. }

  147. public timeRemain(param[])
  148. {
  149. new gmtm = get_timeleft()
  150. new tmlf = g_Switch ? --g_CountDown : gmtm
  151. new stimel[12]

  152. format(stimel, 11, "%02d:%02d", gmtm / 60, gmtm % 60)
  153. set_cvar_string("amx_timeleft", stimel)

  154. if (g_Switch && gmtm > g_Switch)
  155. {
  156. remove_task(34543)
  157. g_Switch = 0
  158. set_task(0.8, "timeRemain", 8648458, "", 0, "b")

  159. return
  160. }

  161. if (tmlf > 0 && g_LastTime != tmlf)
  162. {
  163. g_LastTime = tmlf
  164. new tm_set = findDispFormat(tmlf)

  165. if (tm_set != -1)
  166. {
  167. new flags = g_TimeSet[tm_set][1]
  168. new arg[128]

  169. if (flags & 1)
  170. {
  171. new players[32], pnum

  172. get_players(players, pnum, "c")

  173. for (new i = 0; i < pnum; i++)
  174. {
  175. setTimeText(arg, 127, tmlf, players[i])

  176. if (flags & 16)
  177. set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
  178. else
  179. set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 3.0, 0.0, 0.5, -1)

  180. show_hudmessage(players[i], "%s", arg)
  181. }
  182. }

  183. if (flags & 2)
  184. {
  185. setTimeVoice(arg, 127, flags, tmlf)
  186. client_cmd(0, "%s", arg)
  187. }
  188. }
  189. }
  190. }
复制代码


timeleft.txt

  1. [en]
  2. THE_TIME = The time
  3. TIME_LEFT = Time Left
  4. NO_T_LIMIT = No Time Limit
  5. MINUTE = minute
  6. MINUTES = minutes
  7. SECOND = second
  8. SECONDS = seconds
  9. [cn]
  10. THE_TIME = 当前系统时间
  11. TIME_LEFT = 地图剩余时间
  12. NO_T_LIMIT = 无时间限制
  13. MINUTE = 分钟
  14. MINUTES = 分钟
  15. SECOND = 秒
  16. SECONDS = 秒
  17. [tc]
  18. THE_TIME = 當前時間
  19. TIME_LEFT = 剩餘時間
  20. NO_T_LIMIT = 無時間限制
  21. MINUTE = 分鐘
  22. MINUTES = 分鐘
  23. SECOND = 秒
  24. SECONDS = 秒
复制代码

评分

参与人数 1金币 +3 +5 收起 理由
honwenle + 3 + 5 KK太给力啦,哈哈哈…

查看全部评分

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

本版积分规则

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