HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <engine>
  4. #include <fakemeta>
  5. #include <fun>
  6. #include <hamsandwich>
  7. #include <mapname_patcher>
  8.  
  9. #define PLUGIN "[CSO] Challenge"
  10. #define VERSION "1.0"
  11. #define AUTHOR "RaZzoR"
  12.  
  13. #define DICTIONARY "cso_challenge.txt"
  14. #define USE_CSO_SKINS
  15.  
  16. #if defined USE_CSO_SKINS
  17. new const chall_new_v_models[][][] = {
  18. { "models/v_knife.mdl", "models/cso_challenge/v_knife.mdl" }
  19. }
  20. #endif
  21.  
  22. new const allow_maps[][][] = {
  23. { "cso_jump1", "Jump 1" },
  24. { "cso_jump2", "Jump 2" },
  25. { "cso_run1", "Run 1" },
  26. { "cso_run2", "Run 2" }
  27. }
  28.  
  29. new const entity_hook[][][] = {
  30. { "chall_start", "func_buyzone" },
  31. { "chall_check0", "func_bomb_target" },
  32. { "chall_check1", "func_hostage_rescue" },
  33. { "chall_check2", "func_vip_safetyzone" },
  34. { "chall_finish", "func_escapezone" },
  35. { "chall_return", "func_wall" }
  36. }
  37.  
  38. new const objective_icons[][] = {
  39. "c4",
  40. "buyzone",
  41. "rescue",
  42. "escape",
  43. "vipsafety"
  44. }
  45.  
  46. new const chall_sounds[][]= {
  47. "cso_challenge/cm_check.wav",
  48. "cso_challenge/cm_down.wav",
  49. "cso_challenge/cm_goal.wav",
  50. "cso_challenge/cm_start.wav",
  51. "cso_challenge/task_complete.wav"
  52. }
  53.  
  54. new const chall_blockmsgs[][] = {
  55. "#Terrorist_Escaped",
  56. "#Terrorists_Escaped",
  57. "#Hint_ct_vip_zone",
  58. "#Hint_hostage_rescue_zone",
  59. "#Hint_you_are_in_targetzone",
  60. "#Hint_you_are_the_vip",
  61. "#Hint_you_have_the_bomb",
  62. "#Hint_terrorist_vip_zone",
  63. "#Hint_terrorist_escape_zone"
  64. }
  65.  
  66. new const challenge_gamename[] = "Challenge"
  67.  
  68. new const chall_bgsound[] = "sound/cso_challenge/chall_ambience.mp3"
  69.  
  70. new bool:ch_touched_ent_start[33], bool:ch_touched_ent_check0[33], bool:ch_touched_ent_check1[33], bool:ch_touched_ent_check2[33], bool:ch_touched_ent_finish[33], bool:ch_touched_ent_return[33]
  71. new Float:ch_save_timer[33][5], Float:ch_timer[33], Float:get_player_time[33], Float:ch_delay
  72. new ch_semiclip[33], ch_origin[3], ch_plr_origin[33][3], random_map
  73.  
  74. /* ch_save_timer[0][0] = save 1st checkpoint (top1)
  75.   ch_save_timer[0][1] = save 2nd checkpoint (top1)
  76.   ch_save_timer[0][2] = save 3rd checkpoint (top1)
  77.   ch_save_timer[index][3] = save best time (top1, top2, top3)
  78.   ch_save_timer[index][4] = save best time (player)
  79. */
  80.  
  81. public plugin_init() {
  82. register_dictionary(DICTIONARY)
  83.  
  84. new map_name[32], buffer[128], index
  85. get_mapname(map_name, 31)
  86.  
  87. for(index=0;index<sizeof(allow_maps);index++) {
  88. if(equal(map_name, allow_maps[index][0])) {
  89. if(strlen(allow_maps[index][1]) > 0)
  90. Patch_MapName(allow_maps[index][1])
  91. break
  92. }
  93. }
  94.  
  95. if(index == sizeof(allow_maps)) {
  96. formatex(buffer, sizeof(buffer), "%L", LANG_SERVER, "CHALL_WRONG_MAP")
  97. set_fail_state(buffer)
  98. return
  99. }
  100.  
  101. register_plugin(PLUGIN, VERSION, AUTHOR)
  102.  
  103. register_message(get_user_msgid("StatusIcon"), "msgStatusIcon")
  104. register_message(get_user_msgid("RoundTime"), "msgRoundTime")
  105. register_message(get_user_msgid("HideWeapon"), "msgHideWeapon")
  106. register_message(get_user_msgid("Money"), "msgMoney")
  107. register_message(get_user_msgid("TextMsg"), "msgTextMsg")
  108.  
  109. register_clcmd("chooseteam", "block_cmd")
  110.  
  111. RegisterHam(Ham_TraceAttack, "player", "HamTraceAttack_Pre")
  112. RegisterHam(Ham_Spawn, "player", "Spawn", 1)
  113.  
  114. register_forward(FM_StartFrame, "fwStartFrame", 0)
  115. register_forward(FM_AddToFullPack, "fwFullPack", 1)
  116. register_forward(FM_ClientKill, "Forward_ClientKill")
  117. register_forward(FM_GetGameDescription, "GameDesc")
  118.  
  119. for(new i=0;i<sizeof(entity_hook);i++) {
  120. new buffer[128]
  121. formatex(buffer, sizeof(buffer), "hook_%s", entity_hook[i][0])
  122.  
  123. register_touch(entity_hook[i][0], "player", buffer)
  124. }
  125.  
  126. register_event("ResetHUD", "onResetHUD", "b")
  127. register_event("DeathMsg", "death", "a")
  128.  
  129. #if defined USE_CSO_SKINS
  130. register_event("CurWeapon","Weapon_Hook","be","1=1")
  131. #endif
  132.  
  133. random_map = random(sizeof(allow_maps))
  134. }
  135.  
  136. public plugin_cfg()
  137. server_cmd("sv_restart 1")
  138.  
  139. public plugin_precache() {
  140. for(new i=0;i<sizeof(chall_new_v_models);i++)
  141. precache_model(chall_new_v_models[i][1])
  142.  
  143. for(new i=0;i<sizeof(chall_sounds);i++)
  144. precache_sound(chall_sounds[i])
  145.  
  146. precache_generic(chall_bgsound)
  147. }
  148.  
  149. #if defined USE_CSO_SKINS
  150. public Weapon_Hook(id) {
  151. if(!is_user_alive(id))
  152. return PLUGIN_CONTINUE
  153.  
  154. static model[32]
  155. pev(id, pev_viewmodel2, model, 31)
  156.  
  157. for(new i=0;i<sizeof(chall_new_v_models);i++) {
  158. if(equali(model, chall_new_v_models[i][0])) {
  159. set_pev(id, pev_viewmodel2, chall_new_v_models[i][1])
  160. break
  161. }
  162. }
  163.  
  164. return PLUGIN_CONTINUE
  165.  
  166. }
  167. #endif
  168.  
  169. public block_cmd(id)
  170. return PLUGIN_HANDLED
  171.  
  172. public Forward_ClientKill(id)
  173. return FMRES_SUPERCEDE
  174.  
  175. public GameDesc() {
  176. forward_return(FMV_STRING, challenge_gamename)
  177. return FMRES_SUPERCEDE
  178. }
  179.  
  180. public onResetHUD(id) {
  181. if(!is_user_connected(id))
  182. return
  183.  
  184. message_begin(MSG_ONE, get_user_msgid("HideWeapon"), _, id)
  185. write_byte((1<<5))
  186. message_end()
  187. }
  188.  
  189. public msgRoundTime(const MsgId, const MsgDest, const MsgEnt)
  190. set_msg_arg_int(1, ARG_SHORT, get_timeleft())
  191.  
  192. public msgHideWeapon()
  193. set_msg_arg_int(1, ARG_BYTE, get_msg_arg_int(1) | (1<<5))
  194.  
  195. public msgMoney(msgid, dest, id) {
  196. set_pdata_int(id, 115, 0)
  197. set_msg_arg_int(1, ARG_LONG, 0)
  198. }
  199.  
  200. public msgTextMsg(msg_id, msg_dest, msg_entity) {
  201. static message[32]
  202. get_msg_arg_string(2, message, charsmax(message))
  203.  
  204. for(new i=0; i < sizeof(chall_blockmsgs); i++) {
  205. if(equal(message, chall_blockmsgs[i]))
  206. return PLUGIN_HANDLED
  207. }
  208.  
  209. return PLUGIN_CONTINUE
  210. }
  211.  
  212. public msgStatusIcon(msgid, msgdest, id) {
  213. static szIcon[11]
  214. get_msg_arg_string(2, szIcon, 10)
  215.  
  216. for(new i=0;i<sizeof(objective_icons);i++) {
  217. if(equal(szIcon, objective_icons[i]) && get_msg_arg_int(1)) {
  218. set_pdata_int(id, 235, get_pdata_int(id, 235) & ~(1<<0))
  219. return PLUGIN_HANDLED
  220. }
  221. }
  222.  
  223. return PLUGIN_CONTINUE
  224. }
  225.  
  226. public HamTraceAttack_Pre(iVictim, iAttacker, Float:flDamage, Float:fVecDir[3], tr)
  227. return HAM_IGNORED
  228.  
  229. public map_change()
  230. server_cmd("changelevel %s", allow_maps[random_map][0])
  231.  
  232. public client_disconnect(id) {
  233. ch_timer[id] = 0.0
  234. get_player_time[id] = 0.0
  235.  
  236. remove(id)
  237. client_cmd(id, "mp3 stop")
  238. }
  239.  
  240. public client_putinserver(id) {
  241. if(is_user_bot(id)) {
  242. new buffer[128]
  243.  
  244. formatex(buffer, sizeof(buffer), "%L", LANG_SERVER, "CHALL_BOT")
  245. set_fail_state(buffer)
  246. return
  247. }
  248.  
  249. set_task(0.1, "play_bg_sound", id)
  250. }
  251.  
  252. public play_bg_sound(id) {
  253. client_cmd(id, "mp3 play %s", chall_bgsound)
  254. set_task(234.0, "play_bg_sound", id)
  255. }
  256.  
  257. public pfn_keyvalue(entid) {
  258.  
  259. new classname[32], key[32], value[32]
  260. copy_keyvalue(classname, 31, key, 31, value, 31)
  261.  
  262. for(new i=0;i<sizeof(entity_hook);i++) {
  263. if(equal(key, "classname") && equal(value, entity_hook[i][0]))
  264. DispatchKeyValue("classname", entity_hook[i][1])
  265. }
  266.  
  267. for(new i=0;i<sizeof(entity_hook);i++) {
  268. if(equal(classname, entity_hook[i][1])) {
  269. entity_set_string(entid, EV_SZ_classname, entity_hook[i][0])
  270. set_entity_visibility(entid, 0)
  271. }
  272. }
  273. }
  274.  
  275. public fwFullPack(es, e, ent, host, flags, player, pSet) {
  276. if(player && ch_semiclip[ent] && ch_semiclip[host]) {
  277. static Float:flDistance
  278. flDistance = entity_range(host, ent)
  279.  
  280. set_es(es, ES_Solid, SOLID_NOT)
  281. set_es(es, ES_RenderMode, kRenderTransAlpha)
  282. set_es(es, ES_RenderAmt, floatround(flDistance * 1.5))
  283. }
  284.  
  285. return FMRES_IGNORED
  286. }
  287.  
  288. public fwStartFrame(id) {
  289. static iPlayers[32], iNum, iPlayer, iPlayer2
  290. get_players(iPlayers, iNum)
  291.  
  292. arrayset(ch_semiclip, 0, sizeof(ch_semiclip))
  293.  
  294. for(new i=0;i<iNum; i++) {
  295. iPlayer = iPlayers[i]
  296.  
  297. if(!is_user_alive(iPlayer))
  298. continue
  299.  
  300. for(new j=0;j<iNum;j++) {
  301. iPlayer2 = iPlayers[j]
  302.  
  303. if(iPlayer == iPlayer2 || !is_user_alive(iPlayer2))
  304. continue
  305.  
  306. static Float:vOrigin1[3], Float:vOrigin2[3]
  307. pev(iPlayer, pev_origin, vOrigin1)
  308. pev(iPlayer2, pev_origin, vOrigin2)
  309.  
  310. if(vector_distance(vOrigin1, vOrigin2) < 96) {
  311. ch_semiclip[iPlayer] = true
  312. ch_semiclip[iPlayer2] = true
  313. }
  314. }
  315. }
  316.  
  317. for(new i=0;i<iNum; i++) {
  318. iPlayer = iPlayers[i]
  319.  
  320. if(is_user_alive(iPlayer))
  321. set_pev(iPlayer, pev_solid, ch_semiclip[iPlayer] ? SOLID_NOT : SOLID_SLIDEBOX)
  322. }
  323.  
  324. return FMRES_IGNORED
  325. }
  326.  
  327. public death() {
  328. new victim = read_data(2)
  329. set_task(0.1, "spawn_plr", victim)
  330. }
  331.  
  332. public spawn_plr(id) {
  333. ExecuteHamB(Ham_CS_RoundRespawn, id)
  334.  
  335. ch_origin[0] = ch_plr_origin[id][0]
  336. ch_origin[1] = ch_plr_origin[id][1]
  337. ch_origin[2] = ch_plr_origin[id][2] + 10
  338. set_user_origin(id, ch_origin)
  339. }
  340.  
  341. public Spawn(id) {
  342. if(!is_user_connected(id)) return
  343.  
  344. new weapon_name[15]
  345. switch(get_user_team(id)) {
  346. case 1: weapon_name = "weapon_glock18"
  347. case 2: weapon_name = "weapon_usp"
  348. default: return
  349. }
  350.  
  351. new weapon = find_ent_by_owner(-1, weapon_name, id)
  352. if(!weapon) return
  353.  
  354. engclient_cmd(id, "drop", weapon_name)
  355. new weaponbox = entity_get_edict(weapon, EV_ENT_owner)
  356. if(!weaponbox || weaponbox == id) return
  357.  
  358. remove_entity(weaponbox)
  359. remove_entity(weapon)
  360. }
  361.  
  362. public client_PostThink(id) {
  363. /* Check Timeleft */
  364. if(get_timeleft() <= 0) {
  365. client_print(0, print_center, "%L: %s", LANG_PLAYER, "CHALL_TIMERUP", strlen(allow_maps[random_map][1]) > 0 ? allow_maps[random_map][1] : allow_maps[random_map][0])
  366. set_task(1.0, "map_change")
  367. }
  368.  
  369. /* Player Info(s)*/
  370. new Plr_Time[15], TimeTOP[15]
  371.  
  372. TOPtimesToString((ch_timer[id] == 0.0 ? get_player_time[id] : get_gametime() - ch_timer[id] - ch_delay), Plr_Time, 14)
  373. TOPtimesToString((ch_save_timer[id][4] - ch_delay), TimeTOP, 14)
  374.  
  375. set_hudmessage(255, 255, 255, -1.00, 0.00, 0, 6.0, 12.0, 0.1, 0.2, -1)
  376. show_hudmessage(id, "%s^n^n[%L]^n%s", Plr_Time, id, "CHALL_TOPSCORE", TimeTOP)
  377.  
  378. /* TOP3 HUD */
  379. new players[32], num, top1, top2, top3
  380. new top1_name[33], top2_name[33], top3_name[33], TimeTOP1[15], TimeTOP2[15], TimeTOP3[15]
  381. get_players(players, num)
  382. SortCustom1D(players, num, "sort_bestplayer")
  383.  
  384. top1 = players[0]
  385. top2 = players[1]
  386. top3 = players[2]
  387.  
  388. if(ch_save_timer[top1][3] > 1) {
  389. get_user_name(top1, top1_name, charsmax(top1_name))
  390. TOPtimesToString((ch_save_timer[top1][3] - ch_delay), TimeTOP1, 14)
  391. }
  392.  
  393. if(ch_save_timer[top2][3] > 1) {
  394. get_user_name(top2, top2_name, charsmax(top2_name))
  395. TOPtimesToString((ch_save_timer[top2][3] - ch_delay), TimeTOP2, 14)
  396. }
  397.  
  398. if(ch_save_timer[top3][3] > 1) {
  399. get_user_name(top3, top3_name, charsmax(top3_name))
  400. TOPtimesToString((ch_save_timer[top3][3] - ch_delay), TimeTOP3, 14)
  401. }
  402.  
  403. set_hudmessage(255, 153, 0, -0.00, 0.21, 0, 6.0, 12.0, 0.1, 0.2, -1)
  404. show_hudmessage(0, "[%L] %s^n%s^n^n[%L] %s^n%s^n^n[%L] %s^n%s", LANG_PLAYER, "CHALL_1ST", top1_name, TimeTOP1, LANG_PLAYER, "CHALL_2ND", top2_name, TimeTOP2, LANG_PLAYER, "CHALL_3RD", top3_name, TimeTOP3)
  405. }
  406.  
  407. public hook_chall_start(ent, id) {
  408. if(is_user_alive(id) && !ch_touched_ent_start[id]) {
  409. ch_touched_ent_start[id] = true
  410.  
  411. get_user_origin(id, ch_origin, 0)
  412. ch_plr_origin[id][0] = ch_origin[0]
  413. ch_plr_origin[id][1] = ch_origin[1]
  414. ch_plr_origin[id][2] = ch_origin[2]
  415.  
  416. ch_timer[id] = get_gametime()
  417.  
  418. client_cmd(id, "spk ^"%s^"", chall_sounds[3])
  419. client_print(id, print_center, "%L", id, "CHALL_GOGOGO")
  420. }
  421. }
  422.  
  423. public hook_chall_check0(ent, id) {
  424. if(is_user_alive(id) && !ch_touched_ent_check0[id]) {
  425. ch_touched_ent_check0[id] = true
  426.  
  427. get_user_origin(id, ch_origin, 0)
  428. ch_plr_origin[id][0] = ch_origin[0]
  429. ch_plr_origin[id][1] = ch_origin[1]
  430. ch_plr_origin[id][2] = ch_origin[2]
  431.  
  432. client_cmd(id, "spk ^"%s^"", chall_sounds[0])
  433.  
  434. new minutes = floatround((get_gametime() - ch_timer[id] - ch_delay) / 60, floatround_floor)
  435. new seconds = floatround((get_gametime() - ch_timer[id] - ch_delay) - minutes * 60, floatround_floor)
  436. new miliseconds = floatround(((get_gametime() - ch_timer[id] - ch_delay) - (minutes * 60 + seconds)) * 100, floatround_floor)
  437.  
  438. get_player_time[id] = (minutes * 60.0) + (seconds * 1.0) + (miliseconds / 100.0)
  439.  
  440. if(get_player_time[id] < ch_save_timer[0][0] || ch_save_timer[0][0] < 1) {
  441. new TimeBetter[15]
  442. TOPtimesToString((ch_save_timer[0][0] < 1 ? 0.0 : ch_save_timer[0][0] - get_player_time[id] - ch_delay), TimeBetter, 14)
  443.  
  444. client_print(id, print_center, "%L -%s %L", id, "CHALL_CHECKPTS", TimeBetter, id, "CHALL_BESTREC")
  445.  
  446. ch_save_timer[0][0] = get_player_time[id]
  447. }
  448.  
  449. else {
  450. new TimeMore[15]
  451. TOPtimesToString((get_player_time[id] - ch_save_timer[0][0] - ch_delay), TimeMore, 14)
  452.  
  453. client_print(id, print_center, "%L +%s", id, "CHALL_CHECKPTS", TimeMore)
  454. }
  455. }
  456. }
  457.  
  458. public hook_chall_check1(ent, id) {
  459. if(is_user_alive(id) && !ch_touched_ent_check1[id]) {
  460. ch_touched_ent_check1[id] = true
  461.  
  462. get_user_origin(id, ch_origin, 0)
  463. ch_plr_origin[id][0] = ch_origin[0]
  464. ch_plr_origin[id][1] = ch_origin[1]
  465. ch_plr_origin[id][2] = ch_origin[2]
  466.  
  467. client_cmd(id, "spk ^"%s^"", chall_sounds[0])
  468.  
  469. new minutes = floatround((get_gametime() - ch_timer[id] - ch_delay) / 60, floatround_floor)
  470. new seconds = floatround((get_gametime() - ch_timer[id] - ch_delay) - minutes * 60, floatround_floor)
  471. new miliseconds = floatround(((get_gametime() - ch_timer[id] - ch_delay) - (minutes * 60 + seconds)) * 100, floatround_floor)
  472.  
  473. get_player_time[id] = (minutes * 60.0) + (seconds * 1.0) + (miliseconds / 100.0)
  474.  
  475. if(get_player_time[id] < ch_save_timer[0][1] || ch_save_timer[0][1] < 1) {
  476. new TimeBetter[15]
  477. TOPtimesToString((ch_save_timer[0][1] < 1 ? 0.0 : ch_save_timer[0][1] - get_player_time[id] - ch_delay), TimeBetter, 14)
  478.  
  479. client_print(id, print_center, "%L -%s %L", id, "CHALL_CHECKPTS", TimeBetter, id, "CHALL_BESTREC")
  480.  
  481. ch_save_timer[0][1] = get_player_time[id]
  482. }
  483.  
  484. else {
  485. new TimeMore[15]
  486. TOPtimesToString((get_player_time[id] - ch_save_timer[0][1] - ch_delay), TimeMore, 14)
  487.  
  488. client_print(id, print_center, "%L +%s", id, "CHALL_CHECKPTS", TimeMore)
  489. }
  490. }
  491. }
  492.  
  493. public hook_chall_check2(ent, id) {
  494. if(is_user_alive(id) && !ch_touched_ent_check2[id]) {
  495. ch_touched_ent_check2[id] = true
  496.  
  497. get_user_origin(id, ch_origin, 0)
  498. ch_plr_origin[id][0] = ch_origin[0]
  499. ch_plr_origin[id][1] = ch_origin[1]
  500. ch_plr_origin[id][2] = ch_origin[2]
  501.  
  502. client_cmd(id, "spk ^"%s^"", chall_sounds[0])
  503.  
  504. new minutes = floatround((get_gametime() - ch_timer[id] - ch_delay) / 60, floatround_floor)
  505. new seconds = floatround((get_gametime() - ch_timer[id] - ch_delay) - minutes * 60, floatround_floor)
  506. new miliseconds = floatround(((get_gametime() - ch_timer[id] - ch_delay) - (minutes * 60 + seconds)) * 100, floatround_floor)
  507.  
  508. get_player_time[id] = (minutes * 60.0) + (seconds * 1.0) + (miliseconds / 100.0)
  509.  
  510. if(get_player_time[id] < ch_save_timer[0][2] || ch_save_timer[0][2] < 1) {
  511. new TimeBetter[15]
  512. TOPtimesToString((ch_save_timer[0][2] < 1 ? 0.0 : ch_save_timer[0][2] - get_player_time[id] - ch_delay), TimeBetter, 14)
  513.  
  514. client_print(id, print_center, "%L -%s %L", id, "CHALL_CHECKPTS", TimeBetter, id, "CHALL_BESTREC")
  515.  
  516. ch_save_timer[0][2] = get_player_time[id]
  517. }
  518.  
  519. else {
  520. new TimeMore[15]
  521. TOPtimesToString((get_player_time[id] - ch_save_timer[0][2] - ch_delay), TimeMore, 14)
  522.  
  523. client_print(id, print_center, "%L +%s", id, "CHALL_CHECKPTS", TimeMore)
  524. }
  525. }
  526. }
  527.  
  528. public hook_chall_finish(ent, id) {
  529. if(is_user_alive(id) && !ch_touched_ent_finish[id]) {
  530. ch_touched_ent_finish[id] = true
  531.  
  532. new minutes = floatround((get_gametime() - ch_timer[id] - ch_delay) / 60, floatround_floor)
  533. new seconds = floatround((get_gametime() - ch_timer[id] - ch_delay) - minutes * 60, floatround_floor)
  534. new miliseconds = floatround(((get_gametime() - ch_timer[id] - ch_delay) - (minutes * 60 + seconds)) * 100, floatround_floor)
  535.  
  536. new players[32], num, top1, top2, top3, tempid
  537. get_players(players, num)
  538. SortCustom1D(players, num, "sort_bestplayer")
  539.  
  540. top1 = players[0]
  541. top2 = players[1]
  542. top3 = players[2]
  543.  
  544. if(ch_save_timer[top1][3] < 1)
  545. top1 = 0
  546. if(ch_save_timer[top2][3] < 1)
  547. top2 = 0
  548. if(ch_save_timer[top3][3] < 1)
  549. top3 = 0
  550.  
  551. get_player_time[id] = (minutes * 60.0) + (seconds * 1.0) + (miliseconds / 100.0)
  552.  
  553. if(get_player_time[id] < ch_save_timer[top1][3] || (ch_save_timer[id][3] < 1 && ch_save_timer[top1][3] < 1)) {
  554. for(new i=0;i<num;i++) {
  555. tempid = players[i]
  556.  
  557. if(tempid != id) {
  558. client_cmd(tempid, "spk ^"%s^"", chall_sounds[1])
  559. client_print(tempid, print_center, "%L", id, "CHALL_RANK")
  560. }
  561. }
  562.  
  563. if(id == top1) {
  564. client_cmd(id, "spk ^"%s^"", chall_sounds[2])
  565. client_print(id, print_center, "%L", id, "CHALL_FINISH")
  566. }
  567.  
  568. else {
  569. client_cmd(id, "spk ^"%s^"", chall_sounds[4])
  570. client_print(id, print_center, "%L", id, "CHALL_ACH_1ST")
  571. }
  572.  
  573. ch_save_timer[id][3] = get_player_time[id]
  574. }
  575.  
  576. else if(get_player_time[id] < ch_save_timer[top2][3] || (ch_save_timer[id][3] < 1 && ch_save_timer[top2][3] < 1)) {
  577. for(new i=0;i<num;i++) {
  578. tempid = players[i]
  579.  
  580. if(tempid != id) {
  581. client_cmd(tempid, "spk ^"%s^"", chall_sounds[1])
  582. client_print(tempid, print_center, "%L", id, "CHALL_RANK")
  583. }
  584. }
  585.  
  586. if(id == top2) {
  587. client_cmd(id, "spk ^"%s^"", chall_sounds[2])
  588. client_print(id, print_center, "%L", id, "CHALL_FINISH")
  589. }
  590.  
  591. else {
  592. client_cmd(id, "spk ^"%s^"", chall_sounds[4])
  593. client_print(id, print_center, "%L", id, "CHALL_ACH_2ND")
  594. }
  595.  
  596. ch_save_timer[id][3] = get_player_time[id]
  597. }
  598.  
  599. else if(get_player_time[id] < ch_save_timer[top3][3] || (ch_save_timer[id][3] < 1 && ch_save_timer[top3][3] < 1)) {
  600. for(new i=0;i<num;i++) {
  601. tempid = players[i]
  602.  
  603. if(tempid != id) {
  604. client_cmd(tempid, "spk ^"%s^"", chall_sounds[1])
  605. client_print(tempid, print_center, "%L", id, "CHALL_RANK")
  606. }
  607. }
  608.  
  609. if(id == top3) {
  610. client_cmd(id, "spk ^"%s^"", chall_sounds[2])
  611. client_print(id, print_center, "%L", id, "CHALL_FINISH")
  612. }
  613.  
  614. else {
  615. client_cmd(id, "spk ^"%s^"", chall_sounds[4])
  616. client_print(id, print_center, "%L", id, "CHALL_ACH_3RD")
  617. }
  618.  
  619. ch_save_timer[id][3] = get_player_time[id]
  620. }
  621.  
  622. else {
  623. client_cmd(id, "spk ^"%s^"", chall_sounds[2])
  624. client_print(id, print_center, "%L", id, "CHALL_FINISH")
  625. }
  626.  
  627.  
  628. if(get_player_time[id] < ch_save_timer[id][4] || ch_save_timer[id][4] < 1)
  629. ch_save_timer[id][4] = get_player_time[id]
  630.  
  631. ch_timer[id] = 0.0
  632.  
  633. new frags = get_user_frags(id) + 1
  634. set_user_frags(id, frags)
  635.  
  636. message_begin(MSG_ALL, get_user_msgid("ScoreInfo"))
  637. write_byte(id)
  638. write_short(frags)
  639. write_short(get_user_deaths(id))
  640. write_short(0)
  641. write_short(get_user_team(id))
  642. message_end()
  643. }
  644. }
  645.  
  646. public hook_chall_return(ent, id) {
  647. if(is_user_alive(id) && !ch_touched_ent_return[id]) {
  648. ch_touched_ent_return[id] = true
  649.  
  650. ExecuteHamB(Ham_CS_RoundRespawn, id)
  651. remove(id)
  652.  
  653. get_player_time[id] = 0.0
  654. }
  655. }
  656.  
  657. public sort_bestplayer(id1, id2) {
  658. if(ch_save_timer[id1][3] < ch_save_timer[id2][3]) {
  659. if(ch_save_timer[id1][3] < 1 || ch_save_timer[id2][3] < 1) return 1
  660. return -1
  661. }
  662.  
  663. else if(ch_save_timer[id1][3] > ch_save_timer[id2][3] ) {
  664. if(ch_save_timer[id1][3] < 1 || ch_save_timer[id2][3] < 1) return -1
  665. return 1
  666. }
  667.  
  668. return 0
  669. }
  670.  
  671. remove(id) {
  672. ch_touched_ent_start[id] = false
  673. ch_touched_ent_check0[id] = false
  674. ch_touched_ent_check1[id] = false
  675. ch_touched_ent_check2[id] = false
  676. ch_touched_ent_finish[id] = false
  677. ch_touched_ent_return[id] = false
  678. }
  679.  
  680. TOPtimesToString(const Float:top, szOutPut[], const iLen) {
  681. new iMinutes = floatround(top / 60.0, floatround_floor)
  682. new iSeconds = floatround(top - iMinutes * 60, floatround_floor)
  683. new iMiliSeconds = floatround((top - (iMinutes * 60 + iSeconds)) * 100, floatround_floor)
  684.  
  685. formatex(szOutPut, iLen, "%02i:%02i:%02i", iMinutes, iSeconds, iMiliSeconds)
  686. }