Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.65 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <engine>
  4. #include <fakemeta>
  5. #include <fakemeta_util>
  6. #include <hamsandwich>
  7. #include <kz_stocks>
  8.  
  9. #pragma semicolon 1
  10.  
  11. new const PLUGIN[]= "EdgeBug & JumpBug Stats";
  12. new const VERSION[] = "1.5";
  13. new const AUTHOR[] = "newbie & Kpoluk";
  14.  
  15. // Player Flags
  16. #define PF_None 0
  17. #define PF_Falling (1 << 0)
  18. #define PF_HasDucked (1 << 1)
  19. #define PF_DuckReleased (1 << 2)
  20. #define PF_Jumped (1 << 3)
  21.  
  22. new g_iPlayerFlags[33];
  23. new g_iEdgeBugCount[33];
  24.  
  25. new g_iBeamSprite;
  26.  
  27. // player settings
  28. new g_EdgeBug[33];
  29. new g_JumpBug[33];
  30. new bool:g_bColorchat[33];
  31. new bool:g_bSound[33];
  32.  
  33. // eb cvars
  34. new g_pEdgeBugEnabled;
  35. new g_pEdgeBugSound;
  36. new g_pEdgeBugDistanceMin;
  37. new g_pEdgeBugDistanceGood;
  38. new g_pEdgeBugDistancePro;
  39. new g_pEdgeBugDistanceLeet;
  40. new g_pEdgeBugBeam;
  41.  
  42. // jb cvars
  43. new g_pJumpBugEnabled;
  44. new g_pJumpBugSound;
  45. new g_pJumpBugDistanceMin;
  46. new g_pJumpBugDistanceGood;
  47. new g_pJumpBugDistancePro;
  48. new g_pJumpBugDistanceLeet;
  49.  
  50. // top cvars
  51. new g_pBugTop;
  52. new g_pBugTopAlone;
  53. new g_pBugTopShowPlace;
  54.  
  55. new g_iEdgeBug[33];
  56. new g_iJumpBug[33];
  57.  
  58. new Float:g_flVelocity[33][3];
  59. new Float:g_flFallingFromPoint[33][3];
  60. new Float:g_flJumped[33][3];
  61. new Float:g_flLandingOrigin[33][3];
  62. new Float:g_flCurrentAbsMin[33][3];
  63. new Float:g_flLastAbsMin[33][3][3];
  64.  
  65. new Float:g_flPrevOrigin[33][3];
  66. new Float:g_flPrevVelocity[33][3];
  67. new Float:g_flEstimDistance[33];
  68.  
  69. new g_szMapName[34];
  70.  
  71. new g_iEbTopLocalhost[15];
  72. new g_szEbFile[128];
  73. new g_szEbTopPlayer[15][22];
  74. new g_iEbTopDistance[15];
  75. new g_szEbTopDate[15][22];
  76.  
  77. new g_iJbTopLocalhost[15];
  78. new g_szJbFile[128];
  79. new g_szJbTopPlayer[15][22];
  80. new g_iJbTopDistance[15];
  81. new g_szJbTopDate[15][22];
  82.  
  83. new Array:g_aOrigins[33];
  84. new g_iWaitForGoodFrame[33];
  85.  
  86. #define EPSILON 0.03125
  87.  
  88. new Float:g_flFrameTime[33];
  89.  
  90.  
  91. public plugin_init()
  92. {
  93. // registering plugin
  94. register_plugin(PLUGIN, VERSION, AUTHOR);
  95.  
  96. // registering cvars
  97. g_pEdgeBugEnabled = register_cvar("kz_eb_enable", "1");
  98. g_pEdgeBugSound = register_cvar("kz_eb_sound", "1");
  99. g_pEdgeBugDistanceMin = register_cvar("kz_eb_min", "150");
  100. g_pEdgeBugDistanceGood = register_cvar("kz_eb_good", "1500");
  101. g_pEdgeBugDistancePro = register_cvar("kz_eb_pro", "3500");
  102. g_pEdgeBugDistanceLeet = register_cvar("kz_eb_leet", "6000");
  103.  
  104. g_pEdgeBugBeam = register_cvar("kz_eb_beam", "1");
  105.  
  106. g_pJumpBugEnabled = register_cvar("kz_jb_enable", "1");
  107. g_pJumpBugSound = register_cvar("kz_jb_sound", "1");
  108. g_pJumpBugDistanceMin = register_cvar("kz_jb_min", "150");
  109. g_pJumpBugDistanceGood = register_cvar("kz_jb_good", "1500");
  110. g_pJumpBugDistancePro = register_cvar("kz_jb_pro", "3500");
  111. g_pJumpBugDistanceLeet = register_cvar("kz_jb_leet", "6000");
  112.  
  113. g_pBugTop = register_cvar("kz_bug_top", "1");
  114. g_pBugTopAlone = register_cvar("kz_bug_topalone", "0");
  115. g_pBugTopShowPlace = register_cvar("kz_bug_showplace", "1");
  116.  
  117. // tops
  118. new szDir[128];
  119. get_localinfo("amxx_datadir", szDir, charsmax(szDir));
  120. format(szDir, charsmax(szDir),"%s/bugtop", szDir);
  121. if(!dir_exists(szDir))
  122. mkdir(szDir);
  123.  
  124. get_mapname(g_szMapName, charsmax(g_szMapName));
  125.  
  126. if(get_pcvar_num(g_pBugTop) > 1)
  127. {
  128. format(g_szEbFile, charsmax(g_szEbFile),"%s/edgebug", szDir);
  129. if(!dir_exists(g_szEbFile))
  130. mkdir(g_szEbFile);
  131. format(g_szJbFile, charsmax(g_szJbFile),"%s/jumpbug", szDir);
  132. if(!dir_exists(g_szJbFile))
  133. mkdir(g_szJbFile);
  134.  
  135. format(g_szEbFile, charsmax(g_szEbFile), "%s/%s.txt", g_szEbFile, g_szMapName);
  136. format(g_szJbFile, charsmax(g_szJbFile), "%s/%s.txt", g_szJbFile, g_szMapName);
  137. }
  138. else
  139. {
  140. format(g_szEbFile, charsmax(g_szEbFile), "%s/ebtop.txt", szDir);
  141. format(g_szJbFile, charsmax(g_szJbFile), "%s/jbtop.txt", szDir);
  142. }
  143.  
  144. readEbTop();
  145. readJbTop();
  146.  
  147. // registering forwards
  148. RegisterHam(Ham_Touch, "player", "hamPlayerTouch");
  149. RegisterHam(Ham_Player_PreThink, "player", "hamPlayerPreThink");
  150. RegisterHam(Ham_Touch, "trigger_teleport", "hamTouch");
  151.  
  152. // registering commands
  153. register_saycmd("ebstats", "cmdEbStats");
  154. register_saycmd("jbstats", "cmdJbStats");
  155. register_saycmd("bugcolorchat", "cmdColorChat");
  156. register_saycmd("colorchatbug", "cmdColorChat");
  157. register_saycmd("bugsound", "cmdBugSound");
  158. register_saycmd("soundbug", "cmdBugSound");
  159.  
  160. register_saycmd("jbtrainer", "cmdJbTrainer");
  161.  
  162. register_saycmd("ebtop", "cmdShowEbTop");
  163. register_saycmd("ebtop10", "cmdShowEbTop");
  164. register_saycmd("ebtop15", "cmdShowEbTop");
  165. register_saycmd("eb10", "cmdShowEbTop");
  166. register_saycmd("eb15", "cmdShowEbTop");
  167.  
  168. register_saycmd("jbtop", "cmdShowJbTop");
  169. register_saycmd("jbtop10", "cmdShowJbTop");
  170. register_saycmd("jbtop15", "cmdShowJbTop");
  171. register_saycmd("jb10", "cmdShowJbTop");
  172. register_saycmd("jb15", "cmdShowJbTop");
  173.  
  174. for(new id = 0; id < 33; id++)
  175. {
  176. g_aOrigins[id] = ArrayCreate(1);
  177. g_iWaitForGoodFrame[id] = 0;
  178.  
  179. g_flFrameTime[id] = 0.01;
  180. }
  181.  
  182. register_forward(FM_CmdStart, "fwCmdStart");
  183. }
  184.  
  185. public fwCmdStart(id, uc_handle)
  186. {
  187. if(is_user_bot(id))
  188. return;
  189.  
  190. g_flFrameTime[id] = get_uc(uc_handle, UC_Msec) / 1000.0;
  191. }
  192.  
  193. public plugin_end()
  194. {
  195. for(new id = 0; id < 33; id++)
  196. ArrayDestroy(g_aOrigins[id]);
  197. }
  198.  
  199. public plugin_precache()
  200. {
  201. g_iBeamSprite = precache_model("sprites/zbeam4.spr");
  202.  
  203. precache_sound("misc/mod_godlike.wav");
  204. precache_sound("misc/mod_wickedsick.wav");
  205. precache_sound("misc/perfect.wav");
  206. precache_sound("misc/impressive.wav");
  207. precache_sound("misc/double.wav");
  208. precache_sound("misc/triple.wav");
  209. precache_sound("misc/holyshit.wav");
  210. }
  211.  
  212. public plugin_cfg()
  213. {
  214. new szConfigsDir[128];
  215. get_configsdir(szConfigsDir, charsmax(szConfigsDir));
  216. format(szConfigsDir, charsmax(szConfigsDir), "%s/kz_bug_stats.cfg", szConfigsDir);
  217.  
  218. if(file_exists(szConfigsDir))
  219. {
  220. server_cmd("exec %s", szConfigsDir);
  221. server_exec();
  222. }
  223. }
  224.  
  225. public client_connect(id)
  226. {
  227. g_iPlayerFlags[id] = PF_None;
  228. g_iEdgeBugCount[id] = 0;
  229.  
  230. g_EdgeBug[id] = get_pcvar_num(g_pEdgeBugEnabled);
  231. g_JumpBug[id] = get_pcvar_num(g_pJumpBugEnabled);
  232. g_bColorchat[id] = true;
  233. g_bSound[id] = true;
  234.  
  235. g_iEdgeBug[id] = 0;
  236. g_iJumpBug[id] = 0;
  237.  
  238. copy_vector(VEC_NULL, g_flVelocity[id]);
  239.  
  240. copy_vector(VEC_NULL, g_flFallingFromPoint[id]);
  241. copy_vector(VEC_NULL, g_flJumped[id]);
  242. copy_vector(VEC_NULL, g_flLandingOrigin[id]);
  243.  
  244. copy_vector(VEC_NULL, g_flPrevOrigin[id]);
  245. copy_vector(VEC_NULL, g_flPrevVelocity[id]);
  246. g_flEstimDistance[id] = 0.0;
  247. }
  248.  
  249. public fwResetBug(id) // forward
  250. {
  251. clear(id);
  252. }
  253.  
  254. public hamTouch(ent, id)
  255. {
  256. if(is_user_bot(id))
  257. return HAM_IGNORED;
  258.  
  259. if(!is_user_alive(id))
  260. return HAM_IGNORED;
  261.  
  262. clear(id);
  263.  
  264. return HAM_IGNORED;
  265. }
  266.  
  267. public hamPlayerTouch(id, ent)
  268. {
  269. if(is_user_bot(id))
  270. return HAM_IGNORED;
  271.  
  272. new Float:flVelocity[3];
  273. pev(id, pev_velocity, flVelocity);
  274.  
  275. if(flVelocity[2] > 0.0)
  276. return HAM_IGNORED;
  277.  
  278. if(!(g_iPlayerFlags[id] & PF_Falling) || pev(id, pev_flags) & FL_ONGROUND)
  279. return HAM_IGNORED;
  280.  
  281. pev(id, pev_absmin, g_flCurrentAbsMin[id]);
  282. if(floatround(g_flCurrentAbsMin[id][2], floatround_floor) != g_flCurrentAbsMin[id][2] - EPSILON)
  283. return HAM_IGNORED;
  284.  
  285. if(is_player_sliding(id))
  286. return HAM_IGNORED;
  287.  
  288. g_iEdgeBug[id] = 1;
  289.  
  290. return HAM_IGNORED;
  291. }
  292.  
  293. public hamPlayerPreThink(id)
  294. {
  295. if(is_user_bot(id))
  296. return HAM_IGNORED;
  297.  
  298. if(!is_user_alive(id))
  299. {
  300. ArrayClear(g_aOrigins[id]);
  301. return HAM_IGNORED;
  302. }
  303.  
  304. // incorrect cvars
  305. new Float:fGravity;
  306. pev(id, pev_gravity, fGravity);
  307.  
  308. if(fGravity != 1.0 || get_cvar_num("sv_gravity") != 800 || get_cvar_num("sv_maxvelocity") != 2000)
  309. {
  310. clear(id);
  311. return HAM_IGNORED;
  312. }
  313.  
  314.  
  315. copy_vector(g_flLastAbsMin[id][1], g_flLastAbsMin[id][2]);
  316. copy_vector(g_flLastAbsMin[id][0], g_flLastAbsMin[id][1]);
  317. pev(id, pev_absmin, g_flLastAbsMin[id][0]);
  318.  
  319.  
  320. new flags = pev(id, pev_flags);
  321.  
  322. // water
  323. if(flags & FL_INWATER && pev(id, pev_waterlevel) >= 2)
  324. {
  325. ArrayClear(g_aOrigins[id]);
  326. clear(id);
  327. return HAM_IGNORED;
  328. }
  329.  
  330. // ladder
  331. if(pev(id, pev_movetype) == MOVETYPE_FLY)
  332. {
  333. ArrayClear(g_aOrigins[id]);
  334. clear(id);
  335. return HAM_IGNORED;
  336. }
  337.  
  338. // detect teleport
  339. pev(id, pev_velocity, g_flVelocity[id]);
  340.  
  341. new Float:flOrigin[3];
  342. pev(id, pev_origin, flOrigin);
  343.  
  344. if(!is_zero_vec(g_flPrevOrigin[id]) && is_zero_vec(g_flVelocity[id]))
  345. {
  346. new Float:flPassedDistance = floatsqroot((flOrigin[0] - g_flPrevOrigin[id][0]) * (flOrigin[0] - g_flPrevOrigin[id][0]) +
  347. (flOrigin[1] - g_flPrevOrigin[id][1]) * (flOrigin[1] - g_flPrevOrigin[id][1]) +
  348. (flOrigin[2] - g_flPrevOrigin[id][2]) * (flOrigin[2] - g_flPrevOrigin[id][2]));
  349.  
  350. if(flPassedDistance > 19.0)
  351. clear(id);
  352. }
  353.  
  354. // save new height
  355. if(ArraySize(g_aOrigins[id]) >= 40)
  356. ArrayDeleteItem(g_aOrigins[id], 0);
  357. ArrayPushCell(g_aOrigins[id], flOrigin[2]);
  358.  
  359. // check for bugs
  360. if(g_EdgeBug[id] || g_bColorchat[id])
  361. {
  362. if(g_iEdgeBug[id])
  363. checkEdgeBug(id);
  364. }
  365.  
  366. if(g_JumpBug[id] || g_bColorchat[id])
  367. {
  368. if(g_JumpBug[id] > 1)
  369. {
  370. if(g_iWaitForGoodFrame[id] > 0)
  371. findGoodFrame(id); // waiting for good frame, no jb check
  372. else
  373. traceJumpBug(id);
  374. }
  375. else
  376. {
  377. if(g_iJumpBug[id])
  378. checkJumpBug(id);
  379. else
  380. traceJumpBug(id);
  381. }
  382. }
  383.  
  384. if(flags & FL_ONGROUND && (g_iPlayerFlags[id] & PF_Falling))
  385. clear(id);
  386.  
  387. new buttons = pev(id, pev_button);
  388. new oldbuttons = pev(id, pev_oldbuttons);
  389.  
  390. // falling start...
  391. if(!(flags & FL_ONGROUND) && !(flags & FL_INWATER) && !(g_iPlayerFlags[id] & PF_Falling))
  392. {
  393. g_iPlayerFlags[id] |= PF_Falling;
  394. pev(id, pev_origin, g_flFallingFromPoint[id]);
  395. }
  396.  
  397. // save duck's release state
  398. if((g_iPlayerFlags[id] & PF_Falling) && oldbuttons & IN_DUCK && !(buttons & IN_DUCK))
  399. {
  400. g_iPlayerFlags[id] |= PF_DuckReleased;
  401. }
  402.  
  403. copy_vector(flOrigin, g_flPrevOrigin[id]);
  404. copy_vector(g_flVelocity[id], g_flPrevVelocity[id]);
  405.  
  406. return HAM_IGNORED;
  407. }
  408.  
  409. public traceJumpBug(id)
  410. {
  411. if(pev(id, pev_flags) & FL_ONGROUND)
  412. return;
  413.  
  414. if((pev(id, pev_oldbuttons) & IN_JUMP) || !(pev(id, pev_button) & IN_JUMP))
  415. return;
  416.  
  417. if(!(pev(id, pev_oldbuttons) & IN_DUCK) || (pev(id, pev_button) & IN_DUCK))
  418. return;
  419.  
  420. if(g_flVelocity[id][2] >= 0.0)
  421. return;
  422.  
  423. pev(id, pev_origin, g_flJumped[id]);
  424.  
  425. if(g_JumpBug[id] < 2)
  426. g_iJumpBug[id] = 2;
  427. else
  428. checkJumpBugDetailed(id);
  429. }
  430.  
  431. public checkJumpBugDetailed(id)
  432. {
  433. g_flLandingOrigin[id][0] = g_flJumped[id][0];
  434. g_flLandingOrigin[id][1] = g_flJumped[id][1];
  435. g_flLandingOrigin[id][2] = float(floatround(g_flJumped[id][2], floatround_floor));
  436.  
  437. if(fm_trace_hull(g_flLandingOrigin[id], HULL_HUMAN, id)) // instant stuck -> too low
  438. {
  439. new iCounter = 18; // just to be safe
  440. while(!fm_trace_hull(g_flLandingOrigin[id], HULL_HEAD, id) && iCounter > 0) // trace in duck
  441. {
  442. g_flLandingOrigin[id][2] -= 1.0;
  443. iCounter--;
  444. }
  445.  
  446. if(iCounter <= 0) // impossible
  447. return;
  448.  
  449. g_flLandingOrigin[id][2] = g_flLandingOrigin[id][2] + 18.0 + 1.0; // 36 units above the ground
  450.  
  451. new Float:flDistance = g_flFallingFromPoint[id][2] - g_flLandingOrigin[id][2];
  452. if(flDistance < get_pcvar_float(g_pJumpBugDistanceMin))
  453. return;
  454.  
  455. new Float:flUnitsUnder = g_flJumped[id][2] - 36.0 - g_flLandingOrigin[id][2];
  456.  
  457. if(flUnitsUnder >= 0.0)
  458. return; // something went wrong
  459.  
  460. if(ArraySize(g_aOrigins[id]) < 40)
  461. return; // not enough origins
  462.  
  463. new iFramesShift = 1;
  464.  
  465. new pos = 38; // last height
  466. new Float:flCorrOrigin = Float:ArrayGetCell(g_aOrigins[id], pos);
  467.  
  468. flUnitsUnder = flCorrOrigin - g_flLandingOrigin[id][2];
  469.  
  470. while(flUnitsUnder < 0.0) // still too late, let's take one frame before
  471. {
  472. pos--;
  473. if(pos < 1)
  474. return; // shouldn't be
  475. flCorrOrigin = Float:ArrayGetCell(g_aOrigins[id], pos);
  476. flUnitsUnder = flCorrOrigin - g_flLandingOrigin[id][2];
  477.  
  478. iFramesShift++;
  479. }
  480.  
  481. if(flUnitsUnder > 2.0)
  482. jumpBugNotPoss(id, flDistance, g_flJumped[id][2], g_flLandingOrigin[id][2], flCorrOrigin, iFramesShift, Float:ArrayGetCell(g_aOrigins[id], pos + 1), iFramesShift - 1, true); // oh no now we're too low
  483. else
  484. jumpBugFailed(id, flDistance, g_flJumped[id][2], g_flLandingOrigin[id][2], flCorrOrigin, iFramesShift, true); // finally found good position
  485. }
  486. else
  487. {
  488. new iCounter = floatround(-g_flVelocity[id][2] * g_flFrameTime[id] * 7.0, floatround_floor); // about 7 frames higher
  489.  
  490. while(!fm_trace_hull(g_flLandingOrigin[id], HULL_HUMAN, id) && iCounter > 0) // trace no duck
  491. {
  492. g_flLandingOrigin[id][2] -= 1.0;
  493. iCounter--;
  494. }
  495.  
  496. if(iCounter <= 0) // too high
  497. return;
  498.  
  499. g_flLandingOrigin[id][2] = g_flLandingOrigin[id][2] + 1.0; // 36 units above the ground
  500.  
  501. new Float:flDistance = g_flFallingFromPoint[id][2] - g_flLandingOrigin[id][2];
  502. if(flDistance < get_pcvar_float(g_pJumpBugDistanceMin))
  503. return;
  504.  
  505. new Float:flUnitsAbove = g_flJumped[id][2] - g_flLandingOrigin[id][2];
  506.  
  507. if(flUnitsAbove <= 0.0)
  508. return; // something went wrong
  509.  
  510. if(flUnitsAbove > 2.0)
  511. g_iWaitForGoodFrame[id] = 40; // wait for it
  512. else
  513. jumpBugSuccessful(id, flDistance, g_flJumped[id][2], g_flLandingOrigin[id][2]);
  514. }
  515. }
  516.  
  517. public findGoodFrame(id)
  518. {
  519. g_iWaitForGoodFrame[id]--;
  520. if(g_iWaitForGoodFrame[id] == 0)
  521. return; // waiting too long
  522.  
  523. if(ArraySize(g_aOrigins[id]) < 40)
  524. return; // not enough origins
  525.  
  526. new Float:flDistance = g_flFallingFromPoint[id][2] - g_flLandingOrigin[id][2];
  527.  
  528. new iFramesShift = 40 - g_iWaitForGoodFrame[id];
  529.  
  530. new pos = 39; // last height
  531. new Float:flCorrOrigin = Float:ArrayGetCell(g_aOrigins[id], pos);
  532.  
  533. if(pev(id, pev_flags) & FL_ONGROUND) // ground
  534. {
  535. g_iWaitForGoodFrame[id] = 0;
  536.  
  537. new Float:flPrevOrigin = Float:ArrayGetCell(g_aOrigins[id], pos - 1);
  538.  
  539. // prediction (prethink called at the moment when Velocity[2] is + (400 * frametime) from what it should be for calculating new origin)
  540. new Float:flPredictedOrigin = flPrevOrigin + (g_flPrevVelocity[id][2] - 400.0 * g_flFrameTime[id]) * g_flFrameTime[id];
  541.  
  542. if(flPredictedOrigin < flCorrOrigin)
  543. jumpBugNotPoss(id, flDistance, g_flJumped[id][2], g_flLandingOrigin[id][2], flPrevOrigin, iFramesShift - 1, flCorrOrigin, 999, false); // 999 ground (falling too fast, skipping 2 units near the ground)
  544. else
  545. jumpBugFailed(id, flDistance, g_flJumped[id][2], g_flLandingOrigin[id][2], flPredictedOrigin, iFramesShift, false);
  546.  
  547. // return;
  548. }
  549.  
  550. /*
  551. new Float:flUnitsAbove = flCorrOrigin - g_flLandingOrigin[id][2];
  552.  
  553. if(flUnitsAbove < 2.0)
  554. {
  555. client_print(id, print_chat, "WRONG flUnitsAbove %f", flUnitsAbove);
  556.  
  557. if(flUnitsAbove < 0.0)
  558. jumpBugNotPoss(id, flDistance, g_flJumped[id][2], g_flLandingOrigin[id][2], Float:ArrayGetCell(g_aOrigins[id], pos - 1), iFramesShift - 1, flCorrOrigin, iFramesShift, false); // now we're too low (shouldn't be possible)
  559. else
  560. jumpBugFailed(id, flDistance, g_flJumped[id][2], g_flLandingOrigin[id][2], flCorrOrigin, iFramesShift, false); // finally found good position (shouldn't be possible cause teleport near the ground)
  561.  
  562. g_iWaitForGoodFrame[id] = 0;
  563. }
  564. */
  565. }
  566.  
  567. public jumpBugNotPoss(id, Float:flDistance, Float:flMyZ, Float:flRequiredZ, Float:flNearestZ1, iFramesShift1, Float:flNearestZ2, iFramesShift2, bool:bLater)
  568. {
  569. new szMessage1[500], szMessage2[500], szMessage3[500];
  570.  
  571. if(bLater)
  572. formatex(szMessage1, charsmax(szMessage1), "Impossible JumpBug^nDistance: %.2f units^nLower by: %.2f units", flDistance, flRequiredZ - flMyZ);
  573. else
  574. formatex(szMessage1, charsmax(szMessage1), "Impossible JumpBug^nDistance: %.2f units^nHigher by: %.2f units", flDistance, flMyZ - flRequiredZ);
  575.  
  576. set_hudmessage(255, 0, 255, -1.0, 0.75, 0, 0.0, 3.0, 0.1, 0.1, 4);
  577. show_hudmessage(id, "%s", szMessage1);
  578.  
  579. formatex(szMessage2, charsmax(szMessage2), "Your Z: %.6f^nRequired Z: %.6f (+ 2.0)", flMyZ, flRequiredZ);
  580.  
  581. new szNearest1[50], szNearest2[50];
  582.  
  583. if(bLater)
  584. {
  585. formatex(szNearest1, charsmax(szNearest1), "%d frame%s earlier", iFramesShift1, iFramesShift1 > 1 ? "s" : "");
  586.  
  587. if(iFramesShift2 == 0)
  588. formatex(szNearest2, charsmax(szNearest2), "same frame");
  589. else
  590. formatex(szNearest2, charsmax(szNearest2), "%d frame%s earlier", iFramesShift2, iFramesShift2 > 1 ? "s" : "");
  591.  
  592. formatex(szMessage3, charsmax(szMessage3), "Nearest Z1: %.6f (%s)^nNearest Z2: %.6f (%s)", flNearestZ1, szNearest1, flNearestZ2, szNearest2);
  593. }
  594. else
  595. {
  596. if(iFramesShift1 == 0)
  597. formatex(szNearest1, charsmax(szNearest1), "same frame");
  598. else
  599. formatex(szNearest1, charsmax(szNearest1), "%d frame%s later", iFramesShift1, iFramesShift1 > 1 ? "s" : "");
  600.  
  601. if(iFramesShift2 == 999)
  602. formatex(szNearest2, charsmax(szNearest2), "ground");
  603. else
  604. formatex(szNearest2, charsmax(szNearest2), "%d frame%s later", iFramesShift2, iFramesShift2 > 1 ? "s" : "");
  605.  
  606. formatex(szMessage3, charsmax(szMessage3), "Nearest Z1: %.6f (%s)^nNearest Z2: %.6f (%s)", flNearestZ1, szNearest1, flNearestZ2, szNearest2);
  607. }
  608.  
  609. client_print(id, print_console, szMessage1);
  610. client_print(id, print_console, szMessage2);
  611. client_print(id, print_console, szMessage3);
  612. }
  613.  
  614.  
  615. public jumpBugFailed(id, Float:flDistance, Float:flMyZ, Float:flRequiredZ, Float:flPossibleZ, iFramesShift, bool:bLater)
  616. {
  617. new szMessage1[500], szMessage2[500];
  618.  
  619. if(bLater)
  620. {
  621. formatex(szMessage1, charsmax(szMessage1), "Failed JumpBug^nDistance: %.2f units^n%d frame%s later^nLower by: %.2f units", flDistance, iFramesShift, iFramesShift > 1 ? "s" : "", flRequiredZ - flMyZ);
  622. formatex(szMessage2, charsmax(szMessage2), "Your Z: %.6f^nRequired Z: %.6f (+ 2.0)^nPossible Z: %.6f (%d frame%s earlier)", flMyZ, flRequiredZ, flPossibleZ, iFramesShift, iFramesShift > 1 ? "s" : "");
  623. }
  624. else
  625. {
  626. formatex(szMessage1, charsmax(szMessage1), "Failed JumpBug^nDistance: %.2f units^n%d frame%s earlier^nHigher by: %.2f units", flDistance, iFramesShift, iFramesShift > 1 ? "s" : "", flMyZ - flRequiredZ);
  627. formatex(szMessage2, charsmax(szMessage2), "Your Z: %.6f^nRequired Z: %.6f (+ 2.0)^nPossible Z: %.6f (%d frame%s later)", flMyZ, flRequiredZ, flPossibleZ, iFramesShift, iFramesShift > 1 ? "s" : "");
  628. }
  629.  
  630. set_hudmessage(255, 0, 0, -1.0, 0.75, 0, 0.0, 3.0, 0.1, 0.1, 4);
  631. show_hudmessage(id, "%s", szMessage1);
  632.  
  633. client_print(id, print_console, szMessage1);
  634. client_print(id, print_console, szMessage2);
  635. }
  636.  
  637. public jumpBugSuccessful(id, Float:flDistance, Float:flMyZ, Float:flRequiredZ)
  638. {
  639. new szMessage1[500], szMessage2[500];
  640.  
  641. formatex(szMessage1, charsmax(szMessage1), "JumpBug^nDistance: %.2f units^nLeft: %.2f units", flDistance, flMyZ - flRequiredZ);
  642.  
  643. formatex(szMessage2, charsmax(szMessage2), "Your Z: %.6f^nRequired Z: %.6f (+ 2.0)", flMyZ, flRequiredZ);
  644.  
  645. set_hudmessage(0, 255, 0, -1.0, 0.75, 0, 0.0, 3.0, 0.1, 0.1, 4);
  646. show_hudmessage(id, szMessage1);
  647.  
  648. client_print(id, print_console, szMessage1);
  649. client_print(id, print_console, szMessage2);
  650.  
  651. jumpBugSoundAndTop(id, flDistance);
  652. }
  653.  
  654. public checkJumpBug(id)
  655. {
  656. if(g_iJumpBug[id])
  657. {
  658. g_iJumpBug[id]--;
  659. if(g_iJumpBug[id])
  660. return;
  661. }
  662.  
  663. if(g_flVelocity[id][2] <= 0.0)
  664. return;
  665.  
  666. g_flLandingOrigin[id][0] = g_flJumped[id][0];
  667. g_flLandingOrigin[id][1] = g_flJumped[id][1];
  668. g_flLandingOrigin[id][2] = float(floatround(g_flJumped[id][2], floatround_floor));
  669.  
  670. while(!fm_trace_hull(g_flLandingOrigin[id], HULL_HUMAN, id))
  671. g_flLandingOrigin[id][2] -= 1.0;
  672.  
  673. g_flLandingOrigin[id][2] = g_flLandingOrigin[id][2] + 1.0;
  674.  
  675. new Float:distance = g_flFallingFromPoint[id][2] - g_flLandingOrigin[id][2];
  676. if(distance < get_pcvar_float(g_pJumpBugDistanceMin))
  677. return;
  678.  
  679. new Float:flUnitsAbove = g_flJumped[id][2] - g_flLandingOrigin[id][2];
  680.  
  681. jumpBugDone(id, distance, flUnitsAbove);
  682. }
  683.  
  684. public jumpBugDone(id, Float:flDistance, Float:fUnitsLeft)
  685. {
  686. new iDistance = floatround(flDistance, floatround_floor);
  687.  
  688. if(g_JumpBug[id] > 0)
  689. {
  690. set_hudmessage(0, 255, 0, -1.0, 0.75, 0, 0.0, 2.0, 0.1, 0.1, 4);
  691. show_hudmessage(id, "JumpBug: %d units^nLeft: %.2f units^nWell done!", iDistance, fUnitsLeft);
  692. client_print(id, print_console, "JumpBug: %d units^nLeft: %.6f units^nWell done!", iDistance, fUnitsLeft);
  693. }
  694.  
  695. jumpBugSoundAndTop(id, flDistance);
  696. }
  697.  
  698. public jumpBugSoundAndTop(id, Float:flDistance)
  699. {
  700. new iDistance = floatround(flDistance, floatround_floor);
  701.  
  702. new name[33];
  703. get_user_name(id, name, charsmax(name));
  704.  
  705. new players[32], num, plr;
  706. get_players(players, num);
  707.  
  708. for(new i = 0; i < num; i++)
  709. {
  710. plr = players[i];
  711.  
  712. if(g_bColorchat[plr])
  713. {
  714. if(flDistance >= get_pcvar_float(g_pJumpBugDistanceLeet))
  715. {
  716. client_print_f(plr, RED, "[KZ] %s has done %d units with JumpBug", name, iDistance);
  717.  
  718. if(get_pcvar_num(g_pJumpBugSound) && g_bSound[plr])
  719. {
  720. if(id == plr)
  721. client_cmd(id, "speak misc/mod_wickedsick");
  722. else
  723. client_cmd(plr, "speak misc/mod_godlike");
  724. }
  725. }
  726. else if(flDistance >= get_pcvar_float(g_pJumpBugDistancePro))
  727. {
  728. client_print_f(plr, GREEN, "[KZ] %s has done %d units with JumpBug", name, iDistance);
  729.  
  730. if(get_pcvar_num(g_pJumpBugSound) && g_bSound[plr])
  731. client_cmd(id, "speak misc/perfect");
  732. }
  733. else if(flDistance >= get_pcvar_float(g_pJumpBugDistanceGood))
  734. {
  735. client_print_f(plr, GREY, "[KZ] %s has done %d units with JumpBug", name, iDistance);
  736.  
  737. if(get_pcvar_num(g_pJumpBugSound) && g_bSound[plr])
  738. client_cmd(id, "speak misc/impressive");
  739. }
  740. }
  741. }
  742.  
  743. if(get_pcvar_num(g_pBugTop) && (is_user_localhost(id) || get_pcvar_num(g_pBugTopAlone) == 0))
  744. setJbTop(id, iDistance);
  745. }
  746.  
  747. public checkEdgeBug(id)
  748. {
  749. if(g_iEdgeBug[id])
  750. g_iEdgeBug[id] = 0;
  751.  
  752. if(g_flVelocity[id][2] < 0.0 && g_flVelocity[id][2] >= -20.0)
  753. {
  754. g_flCurrentAbsMin[id][0] += 16.0;
  755. g_flCurrentAbsMin[id][1] += 16.0;
  756. g_flCurrentAbsMin[id][2] += 0.96875;
  757.  
  758. g_flLastAbsMin[id][2][0] += 16.0;
  759. g_flLastAbsMin[id][2][1] += 16.0;
  760. g_flLastAbsMin[id][2][2] += 0.96875;
  761.  
  762. new Float:flEdgeOrigin[3];
  763. flEdgeOrigin[0] = (g_flLastAbsMin[id][2][0] + g_flCurrentAbsMin[id][0]) / 2;
  764. flEdgeOrigin[1] = (g_flLastAbsMin[id][2][1] + g_flCurrentAbsMin[id][1]) / 2;
  765. flEdgeOrigin[2] = g_flCurrentAbsMin[id][2];
  766.  
  767. new Float:distance = g_flFallingFromPoint[id][2] - flEdgeOrigin[2];
  768.  
  769. if(distance >= get_pcvar_float(g_pEdgeBugDistanceMin))
  770. {
  771. if(get_pcvar_num(g_pEdgeBugBeam))
  772. {
  773. fnDrawLine(id, flEdgeOrigin[0] - 16.0, flEdgeOrigin[1] - 16.0, flEdgeOrigin[2], flEdgeOrigin[0] - 16.0, flEdgeOrigin[1] + 16.0, flEdgeOrigin[2], {0, 255, 0});
  774. fnDrawLine(id, flEdgeOrigin[0] - 16.0, flEdgeOrigin[1] - 16.0, flEdgeOrigin[2], flEdgeOrigin[0] + 16.0, flEdgeOrigin[1] - 16.0, flEdgeOrigin[2], {0, 255, 0});
  775. fnDrawLine(id, flEdgeOrigin[0] + 16.0, flEdgeOrigin[1] - 16.0, flEdgeOrigin[2], flEdgeOrigin[0] + 16.0, flEdgeOrigin[1] + 16.0, flEdgeOrigin[2], {0, 255, 0});
  776. fnDrawLine(id, flEdgeOrigin[0] + 16.0, flEdgeOrigin[1] + 16.0, flEdgeOrigin[2], flEdgeOrigin[0] - 16.0, flEdgeOrigin[1] + 16.0, flEdgeOrigin[2], {0, 255, 0});
  777. }
  778.  
  779. g_iEdgeBugCount[id]++;
  780.  
  781. edgeBugDone(id, distance, g_iEdgeBugCount[id]);
  782. }
  783. }
  784. }
  785.  
  786. public edgeBugDone(id, Float:flDistance, count)
  787. {
  788. new name[33];
  789. get_user_name(id, name, charsmax(name));
  790.  
  791. new iDistance = floatround(flDistance, floatround_floor);
  792.  
  793. if(g_EdgeBug[id])
  794. {
  795. set_hudmessage(0, 255, 0, -1.0, 0.75, 0, 0.0, 2.0, 0.1, 0.1, 4);
  796. show_hudmessage(id, "Fall Distance: %d^nWell done!", iDistance);
  797. client_print(id, print_console, "Fall Distance: %d^nWell done!", iDistance);
  798. }
  799.  
  800. new players[32], num, plr;
  801. get_players(players, num);
  802.  
  803. for(new i = 0; i < num; i++)
  804. {
  805. plr = players[i];
  806.  
  807. if(g_bColorchat[plr])
  808. {
  809. if(count > 3)
  810. {
  811. client_print_f(plr, BLUE, "[KZ] %s has done %d EdgeBugs in a row (%d units)", name, count, iDistance);
  812.  
  813. if(get_pcvar_num(g_pEdgeBugSound) && g_bSound[plr])
  814. client_cmd(plr, "speak misc/holyshit");
  815. }
  816. else if(count == 3)
  817. {
  818. client_print_f(plr, BLUE, "[KZ] %s has done 3 EdgeBugs in a row (%d units)", name, iDistance);
  819.  
  820. if(get_pcvar_num(g_pEdgeBugSound) && g_bSound[plr])
  821. client_cmd(plr, "speak misc/triple");
  822. }
  823. else if(count == 2)
  824. {
  825. client_print_f(plr, RED, "[KZ] %s has done 2 EdgeBugs in a row (%d units)", name, iDistance);
  826.  
  827. if(get_pcvar_num(g_pEdgeBugSound) && g_bSound[plr])
  828. client_cmd(plr, "speak misc/double");
  829. }
  830. else if(flDistance >= get_pcvar_float(g_pEdgeBugDistanceLeet))
  831. {
  832. client_print_f(plr, RED, "[KZ] %s has done %d units with EdgeBug", name, iDistance);
  833.  
  834. if(get_pcvar_num(g_pEdgeBugSound) && g_bSound[plr])
  835. {
  836. if(id == plr)
  837. client_cmd(id, "speak misc/mod_wickedsick");
  838. else
  839. client_cmd(plr, "speak misc/mod_godlike");
  840. }
  841. }
  842. else if(flDistance >= get_pcvar_float(g_pEdgeBugDistancePro))
  843. {
  844. client_print_f(plr, GREEN, "[KZ] %s has done %d units with EdgeBug", name, iDistance);
  845.  
  846. if(get_pcvar_num(g_pEdgeBugSound) && g_bSound[plr])
  847. client_cmd(id, "speak misc/perfect");
  848. }
  849. else if(flDistance >= get_pcvar_float(g_pEdgeBugDistanceGood))
  850. {
  851. client_print_f(plr, GREY, "[KZ] %s has done %d units with EdgeBug", name, iDistance);
  852.  
  853. if(get_pcvar_num(g_pEdgeBugSound) && g_bSound[plr])
  854. client_cmd(id, "speak misc/impressive");
  855. }
  856. }
  857. }
  858.  
  859. if(get_pcvar_num(g_pBugTop) && (is_user_localhost(id) || get_pcvar_num(g_pBugTopAlone) == 0))
  860. setEbTop(id, iDistance);
  861. }
  862.  
  863. public cmdJbStats(id)
  864. {
  865. if(g_JumpBug[id])
  866. {
  867. client_print_f(id, RED, "^x04[KZ]^x01 JumpBug Stats and Trainer have been^x03 disabled");
  868. g_JumpBug[id] = 0;
  869. }
  870. else
  871. {
  872. client_print_f(id, BLUE, "^x04[KZ]^x01 JumpBug Stats has been^x03 enabled^x01. To enable Trainer, say^x04 /jbtrainer");
  873. g_JumpBug[id] = 1;
  874. }
  875.  
  876. return PLUGIN_HANDLED;
  877. }
  878.  
  879. public cmdJbTrainer(id)
  880. {
  881. if(g_JumpBug[id] == 2)
  882. {
  883. client_print_f(id, RED, "^x04[KZ]^x01 JumpBug Trainer has been^x03 disabled");
  884. g_JumpBug[id] = 1;
  885. }
  886. else if(g_JumpBug[id] == 1)
  887. {
  888. client_print_f(id, BLUE, "^x04[KZ]^x01 JumpBug Trainer has been^x03 enabled");
  889. g_JumpBug[id] = 2;
  890. }
  891. else
  892. {
  893. client_print_f(id, BLUE, "^x04[KZ]^x01 JumpBug Stats and Trainer have been^x03 enabled^x01");
  894. g_JumpBug[id] = 2;
  895. }
  896.  
  897. return PLUGIN_HANDLED;
  898. }
  899.  
  900. public cmdEbStats(id)
  901. {
  902. if(g_EdgeBug[id])
  903. {
  904. client_print_f(id, RED, "^x04[KZ]^x01 EdgeBug Stats has been^x03 disabled");
  905. g_EdgeBug[id] = 0;
  906. }
  907. else
  908. {
  909. client_print_f(id, BLUE, "^x04[KZ]^x01 EdgeBug Stats has been^x03 enabled");
  910. g_EdgeBug[id] = 1;
  911. }
  912.  
  913. return PLUGIN_HANDLED;
  914. }
  915.  
  916. public cmdColorChat(id)
  917. {
  918. if(g_bColorchat[id])
  919. client_print_f(id, RED, "^x04[KZ]^x01 Bugs Colorchat has been^x03 disabled");
  920. else
  921. client_print_f(id, BLUE, "^x04[KZ]^x01 Bugs Colorchat Stats has been^x03 enabled");
  922.  
  923. g_bColorchat[id] = !g_bColorchat[id];
  924.  
  925. return PLUGIN_HANDLED;
  926. }
  927.  
  928. public cmdBugSound(id)
  929. {
  930. if(g_bSound[id])
  931. client_print_f(id, RED, "^x04[KZ]^x01 Bug Sounds have been^x03 disabled");
  932. else
  933. client_print_f(id, BLUE, "^x04[KZ]^x01 Bugs Sounds has been^x03 enabled");
  934.  
  935. g_bSound[id] = !g_bSound[id];
  936.  
  937. return PLUGIN_HANDLED;
  938. }
  939.  
  940. public clear(id)
  941. {
  942. g_iPlayerFlags[id] = PF_None;
  943. g_iEdgeBugCount[id] = 0;
  944. }
  945.  
  946. stock fnDrawLine(id, Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, g_iColor[3])
  947. {
  948. message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, SVC_TEMPENTITY, _, id ? id : 0);
  949. write_byte(TE_BEAMPOINTS);
  950. write_coord(floatround(x1));
  951. write_coord(floatround(y1));
  952. write_coord(floatround(z1));
  953. write_coord(floatround(x2));
  954. write_coord(floatround(y2));
  955. write_coord(floatround(z2));
  956. write_short(g_iBeamSprite);
  957. write_byte(1);
  958. write_byte(1);
  959. write_byte(200);
  960. write_byte(5);
  961. write_byte(0);
  962. write_byte(g_iColor[0]);
  963. write_byte(g_iColor[1]);
  964. write_byte(g_iColor[2]);
  965. write_byte(255);
  966. write_byte(0);
  967. message_end();
  968. }
  969.  
  970. stock bool:is_in_duck(entity)
  971. {
  972. if(!pev_valid(entity))
  973. return false;
  974.  
  975. static Float:absmin[3], Float:absmax[3];
  976.  
  977. pev(entity, pev_absmin, absmin);
  978. pev(entity, pev_absmax, absmax);
  979.  
  980. if(absmin[2] + 64.0 < absmax[2])
  981. return false;
  982.  
  983. return true;
  984. }
  985.  
  986. public readEbTop()
  987. {
  988. if(file_exists(g_szEbFile))
  989. {
  990. new szData[512], handle = fopen(g_szEbFile, "rt"), szLocalhost[5], szDistance[22];
  991. for(new i = 0; i < 15; i++)
  992. {
  993. fgets(handle, szData, charsmax(szData));
  994. trim(szData);
  995. if(szData[0])
  996. {
  997. parse(szData, szLocalhost, charsmax(szLocalhost), g_szEbTopPlayer[i], charsmax(g_szEbTopPlayer[]), szDistance, charsmax(szDistance), g_szEbTopDate[i], charsmax(g_szEbTopDate[]));
  998. g_iEbTopLocalhost[i] = str_to_num(szLocalhost);
  999. g_iEbTopDistance[i] = str_to_num(szDistance);
  1000. }
  1001. else
  1002. {
  1003. g_iEbTopLocalhost[i] = 0;
  1004. g_szEbTopPlayer[i][0] = 0;
  1005. g_iEbTopDistance[i] = 0;
  1006. g_szEbTopDate[i][0] = 0;
  1007. }
  1008. }
  1009. fclose(handle);
  1010. }
  1011. }
  1012.  
  1013. public readJbTop()
  1014. {
  1015. if(file_exists(g_szJbFile))
  1016. {
  1017. new szData[512], handle = fopen(g_szJbFile, "rt"), szLocalhost[5], szDistance[22];
  1018. for(new i = 0; i < 15; i++)
  1019. {
  1020. fgets(handle, szData, charsmax(szData));
  1021. trim(szData);
  1022. if(szData[0])
  1023. {
  1024. parse(szData, szLocalhost, charsmax(szLocalhost), g_szJbTopPlayer[i], charsmax(g_szJbTopPlayer[]), szDistance, charsmax(szDistance), g_szJbTopDate[i], charsmax(g_szJbTopDate[]));
  1025. g_iJbTopLocalhost[i] = str_to_num(szLocalhost);
  1026. g_iJbTopDistance[i] = str_to_num(szDistance);
  1027. }
  1028. else
  1029. {
  1030. g_iJbTopLocalhost[i] = 0;
  1031. g_szJbTopPlayer[i][0] = 0;
  1032. g_iJbTopDistance[i] = 0;
  1033. g_szJbTopDate[i][0] = 0;
  1034. }
  1035. }
  1036. fclose(handle);
  1037. }
  1038. }
  1039.  
  1040. stock setEbTop(id, iDistance)
  1041. {
  1042. new iPlaceInTop = 0;
  1043.  
  1044. for(new i = 0; i < 15; i++)
  1045. {
  1046. if(g_iEbTopDistance[i] == 0 || iDistance > g_iEbTopDistance[i])
  1047. break;
  1048. iPlaceInTop++;
  1049. }
  1050.  
  1051. if(iPlaceInTop < 15)
  1052. {
  1053. new szData[512], handle = fopen(g_szEbFile, "wt");
  1054. for(new j = 14; j > iPlaceInTop; j--)
  1055. {
  1056. g_iEbTopLocalhost[j] = g_iEbTopLocalhost[j-1];
  1057. format(g_szEbTopPlayer[j], charsmax(g_szEbTopPlayer[]), "%s", g_szEbTopPlayer[j-1]);
  1058. g_iEbTopDistance[j] = g_iEbTopDistance[j-1];
  1059. format(g_szEbTopDate[j], charsmax(g_szEbTopDate[]), "%s", g_szEbTopDate[j-1]);
  1060. }
  1061.  
  1062. new curr_time[22];
  1063. get_time("%d/%m/%Y", curr_time, charsmax(curr_time));
  1064.  
  1065. new name[22];
  1066. get_user_name(id, name, charsmax(name));
  1067.  
  1068. if(get_pcvar_num(g_pBugTopShowPlace))
  1069. client_print_f(id, BLUE, "^x04[KZ]^x01 %s's jump is on^x03 %d place^x01 in EdgeBug Top!", name, iPlaceInTop + 1);
  1070.  
  1071. replace_all(name, charsmax(name), "<", "");
  1072. replace_all(name, charsmax(name), ">", "");
  1073. replace_all(name, charsmax(name), "^"", ""); //"
  1074. replace_all(name, charsmax(name), " ", "_");
  1075. replace_all(name, charsmax(name), ";", "");
  1076.  
  1077. g_iEbTopLocalhost[iPlaceInTop] = is_user_localhost(id);
  1078. formatex(g_szEbTopPlayer[iPlaceInTop], charsmax(g_szEbTopPlayer[]), "%s", name);
  1079. g_iEbTopDistance[iPlaceInTop] = iDistance;
  1080. formatex(g_szEbTopDate[iPlaceInTop], charsmax(g_szEbTopDate[]), "%s", curr_time);
  1081.  
  1082. for(new i = 0; (i < 15 && g_iEbTopDistance[i] > 0); i++)
  1083. {
  1084. formatex(szData, charsmax(szData), "%d %s %d %s^n", g_iEbTopLocalhost[i], g_szEbTopPlayer[i], g_iEbTopDistance[i], g_szEbTopDate[i]);
  1085. fputs(handle, szData);
  1086. }
  1087.  
  1088. fclose(handle);
  1089. }
  1090. }
  1091.  
  1092. stock setJbTop(id, iDistance)
  1093. {
  1094. new iPlaceInTop = 0;
  1095.  
  1096. for(new i = 0; i < 15; i++)
  1097. {
  1098. if(g_iJbTopDistance[i] == 0 || iDistance > g_iJbTopDistance[i])
  1099. break;
  1100. iPlaceInTop++;
  1101. }
  1102.  
  1103. if(iPlaceInTop < 15)
  1104. {
  1105. new szData[512], handle = fopen(g_szJbFile, "wt");
  1106. for(new j = 14; j > iPlaceInTop; j--)
  1107. {
  1108. g_iJbTopLocalhost[j] = g_iJbTopLocalhost[j-1];
  1109. format(g_szJbTopPlayer[j], charsmax(g_szJbTopPlayer[]), "%s", g_szJbTopPlayer[j-1]);
  1110. g_iJbTopDistance[j] = g_iJbTopDistance[j-1];
  1111. format(g_szJbTopDate[j], charsmax(g_szJbTopDate[]), "%s", g_szJbTopDate[j-1]);
  1112. }
  1113.  
  1114. new curr_time[22];
  1115. get_time("%d/%m/%Y", curr_time, charsmax(curr_time));
  1116.  
  1117. new name[22];
  1118. get_user_name(id, name, charsmax(name));
  1119.  
  1120. if(get_pcvar_num(g_pBugTopShowPlace))
  1121. client_print_f(id, BLUE, "^x04[KZ]^x01 %s's jump is on^x03 %d place^x01 in JumpBug Top!", name, iPlaceInTop + 1);
  1122.  
  1123. replace_all(name, charsmax(name), "<", "");
  1124. replace_all(name, charsmax(name), ">", "");
  1125. replace_all(name, charsmax(name), "^"", ""); //"
  1126. replace_all(name, charsmax(name), " ", "_");
  1127. replace_all(name, charsmax(name), ";", "");
  1128.  
  1129. g_iJbTopLocalhost[iPlaceInTop] = is_user_localhost(id);
  1130. formatex(g_szJbTopPlayer[iPlaceInTop], charsmax(g_szJbTopPlayer[]), "%s", name);
  1131. g_iJbTopDistance[iPlaceInTop] = iDistance;
  1132. formatex(g_szJbTopDate[iPlaceInTop], charsmax(g_szJbTopDate[]), "%s", curr_time);
  1133.  
  1134. for(new i = 0; (i < 15 && g_iJbTopDistance[i] > 0); i++)
  1135. {
  1136. formatex(szData, charsmax(szData), "%d %s %d %s^n", g_iJbTopLocalhost[i], g_szJbTopPlayer[i], g_iJbTopDistance[i], g_szJbTopDate[i]);
  1137. fputs(handle, szData);
  1138. }
  1139.  
  1140. fclose(handle);
  1141. }
  1142. }
  1143.  
  1144. public cmdShowEbTop(id)
  1145. {
  1146. if(get_pcvar_num(g_pBugTop) == 0)
  1147. {
  1148. client_print_f(id, RED, "^x03[KZ]^x01 Bug Tops are disabled");
  1149. return PLUGIN_HANDLED;
  1150. }
  1151.  
  1152. new buffer[15*122], szPlayerName[22];
  1153.  
  1154. new len = formatex(buffer, charsmax(buffer), "<body bgcolor=#ffffff><table width=100%% cellpadding=2 cellspacing=0 border=0>");
  1155. len += formatex(buffer[len], charsmax(buffer)-len, "<tr align=center bgcolor=#008bdb><th width=5%%> # <th width=35%%> Name <th width=30%%> Distance <th width=30%%> Date ");
  1156.  
  1157. for(new i = 0; (i < 15 && g_iEbTopDistance[i] > 0); i++)
  1158. {
  1159. if(g_iEbTopLocalhost[i])
  1160. formatex(szPlayerName, charsmax(szPlayerName), "<b>%s</b>", g_szEbTopPlayer[i]);
  1161. else
  1162. formatex(szPlayerName, charsmax(szPlayerName), "%s", g_szEbTopPlayer[i]);
  1163.  
  1164. len += formatex(buffer[len], charsmax(buffer)-len, "<tr align=center%s><td> %d <td> %s <td> %d units <td> %s", ((i%2)==0) ? "" : " bgcolor=#e2eefa", i+1, szPlayerName, g_iEbTopDistance[i], g_szEbTopDate[i]);
  1165. }
  1166.  
  1167. show_motd(id, buffer, "EdgeBug Top");
  1168. return PLUGIN_HANDLED;
  1169. }
  1170.  
  1171. public cmdShowJbTop(id)
  1172. {
  1173. if(get_pcvar_num(g_pBugTop) == 0)
  1174. {
  1175. client_print_f(id, RED, "^x03[KZ]^x01 Bug Tops are disabled");
  1176. return PLUGIN_HANDLED;
  1177. }
  1178.  
  1179. new buffer[15*122], szPlayerName[22];
  1180.  
  1181. new len = formatex(buffer, charsmax(buffer), "<body bgcolor=#ffffff><table width=100%% cellpadding=2 cellspacing=0 border=0>");
  1182. len += formatex(buffer[len], charsmax(buffer)-len, "<tr align=center bgcolor=#008bdb><th width=5%%> # <th width=35%%> Name <th width=30%%> Distance <th width=30%%> Date ");
  1183.  
  1184. for(new i = 0; (i < 15 && g_iJbTopDistance[i] > 0); i++)
  1185. {
  1186. if(g_iJbTopLocalhost[i])
  1187. formatex(szPlayerName, charsmax(szPlayerName), "<b>%s</b>", g_szJbTopPlayer[i]);
  1188. else
  1189. formatex(szPlayerName, charsmax(szPlayerName), "%s", g_szJbTopPlayer[i]);
  1190.  
  1191. len += formatex(buffer[len], charsmax(buffer)-len, "<tr align=center%s><td> %d <td> %s <td> %d units <td> %s", ((i%2)==0) ? "" : " bgcolor=#e2eefa", i+1, szPlayerName, g_iJbTopDistance[i], g_szJbTopDate[i]);
  1192. }
  1193.  
  1194. show_motd(id, buffer, "JumpBug Top");
  1195. return PLUGIN_HANDLED;
  1196. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement