Advertisement
Guest User

Untitled

a guest
Feb 5th, 2017
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.84 KB | None | 0 0
  1. // =================================================
  2. // BEGIN EDITING HERE
  3. // =================================================
  4.  
  5. // Should the plugin save player data in SQL database?
  6. // To save player data in a vault, change "#define USING_SQL" to "//#define USING_SQL"
  7. // To save player data in SQL, change "//#define USING_SQL" to "#define USING_SQL"
  8.  
  9. //#define USING_SQL
  10.  
  11. // The prefix in all of the plugin's messages
  12.  
  13. new const MESSAGE_TAG[] = "[HNS XP]";
  14.  
  15. // If the player hasn't ever been to your server, they will get this much xp to start with
  16.  
  17. #define ENTRY_XP 100
  18.  
  19. // These determine if these abilities should be enabled or disabled
  20. // 1 = enabled
  21. // 0 = disabled
  22.  
  23. #define ENABLE_GRENADE 1
  24. #define ENABLE_FLASHBANG_1 1
  25. #define ENABLE_FLASHBANG_2 1
  26. #define ENABLE_SMOKEGRENADE 1
  27. #define ENABLE_TERR_HEALTH 1
  28. #define ENABLE_CT_HEALTH 1
  29. #define ENABLE_TERR_ARMOR 1
  30. #define ENABLE_CT_ARMOR 1
  31. #define ENABLE_TERR_RESPAWN 1
  32. #define ENABLE_CT_RESPAWN 1
  33. #define ENABLE_TERR_NOFALL 1
  34. #define ENABLE_CT_NOFALL 1
  35.  
  36. // The maximum level for each ability
  37.  
  38. #define MAXLEVEL_GRENADE 8
  39. #define MAXLEVEL_FLASHBANG_1 4
  40. #define MAXLEVEL_FLASHBANG_2 4
  41. #define MAXLEVEL_SMOKEGRENADE 4
  42. #define MAXLEVEL_TERR_HEALTH 10
  43. #define MAXLEVEL_CT_HEALTH 5
  44. #define MAXLEVEL_TERR_ARMOR 8
  45. #define MAXLEVEL_CT_ARMOR 6
  46. #define MAXLEVEL_TERR_RESPAWN 2
  47. #define MAXLEVEL_CT_RESPAWN 2
  48. #define MAXLEVEL_TERR_NOFALL 8
  49. #define MAXLEVEL_CT_NOFALL 8
  50.  
  51. // The xp amount required to buy the first level
  52.  
  53. #define FIRST_XP_GRENADE 100
  54. #define FIRST_XP_FLASHBANG_1 100
  55. #define FIRST_XP_FLASHBANG_2 100
  56. #define FIRST_XP_SMOKEGRENADE 100
  57. #define FIRST_XP_TERR_HEALTH 100
  58. #define FIRST_XP_CT_HEALTH 100
  59. #define FIRST_XP_TERR_ARMOR 100
  60. #define FIRST_XP_CT_ARMOR 100
  61. #define FIRST_XP_TERR_RESPAWN 1000
  62. #define FIRST_XP_CT_RESPAWN 2000
  63. #define FIRST_XP_TERR_NOFALL 100
  64. #define FIRST_XP_CT_NOFALL 100
  65.  
  66. // The maximum chance possible for this ability (happens when player has maximum level)
  67.  
  68. #define CHANCE_MAX_GRENADE 100
  69. #define CHANCE_MAX_FLASHBANG_1 100
  70. #define CHANCE_MAX_FLASHBANG_2 100
  71. #define CHANCE_MAX_SMOKEGRENADE 100
  72. #define CHANCE_MAX_TERR_RESPAWN 50
  73. #define CHANCE_MAX_CT_RESPAWN 50
  74. #define CHANCE_MAX_TERR_NOFALL 80
  75. #define CHANCE_MAX_CT_NOFALL 80
  76.  
  77. // =================================================
  78. // STOP EDITING HERE
  79. // =================================================
  80.  
  81.  
  82. #include <amxmodx>
  83. #include <amxmisc>
  84. #include <cstrike>
  85. #include <hamsandwich>
  86. #include <fun>
  87. #include <regex>
  88. #include <hlsdk_const>
  89.  
  90. #if defined USING_SQL
  91. #include <sqlx>
  92.  
  93. new Handle:g_sql_tuple;
  94. #else
  95. #include <nvault>
  96.  
  97. new g_vault;
  98. #endif
  99.  
  100.  
  101. new const VERSION[] = "0.0.1";
  102.  
  103.  
  104. #pragma semicolon 1
  105.  
  106. enum _:Grenades{
  107. NADE_HE,
  108. NADE_FL1,
  109. NADE_FL2,
  110. NADE_SM
  111. };
  112.  
  113. new const g_nade_enabled[Grenades] ={
  114. ENABLE_GRENADE,
  115. ENABLE_FLASHBANG_1,
  116. ENABLE_FLASHBANG_2,
  117. ENABLE_SMOKEGRENADE
  118. };
  119.  
  120. new const g_any_nade_enabled = ENABLE_GRENADE + ENABLE_FLASHBANG_1 + ENABLE_FLASHBANG_2 + ENABLE_SMOKEGRENADE;
  121.  
  122. new const g_nade_names[Grenades][] ={
  123. "HE Grenade",
  124. "Flashbang #1",
  125. "Flashbang #2",
  126. "Frost Nade"
  127. };
  128.  
  129. new const g_nade_classnames[Grenades][] ={
  130. "weapon_hegrenade",
  131. "weapon_flashbang",
  132. "weapon_flashbang",
  133. "weapon_smokegrenade"
  134. };
  135.  
  136. new const g_nade_maxlevels[Grenades] ={
  137. MAXLEVEL_GRENADE,
  138. MAXLEVEL_FLASHBANG_1,
  139. MAXLEVEL_FLASHBANG_2,
  140. MAXLEVEL_SMOKEGRENADE
  141. };
  142.  
  143. new const g_nade_first_xp[Grenades] ={
  144. FIRST_XP_GRENADE,
  145. FIRST_XP_FLASHBANG_1,
  146. FIRST_XP_FLASHBANG_2,
  147. FIRST_XP_SMOKEGRENADE
  148. };
  149.  
  150. new const g_nade_max_chance[Grenades] ={
  151. CHANCE_MAX_GRENADE,
  152. CHANCE_MAX_FLASHBANG_1,
  153. CHANCE_MAX_FLASHBANG_2,
  154. CHANCE_MAX_SMOKEGRENADE
  155. };
  156.  
  157. new const g_team_names[CsTeams][] ={
  158. "Spectator",
  159. "Terrorist",
  160. "Counter-Terrorist",
  161. "Spectator"
  162. };
  163.  
  164. new const g_health_enabled[CsTeams] ={
  165. 0,
  166. ENABLE_TERR_HEALTH,
  167. ENABLE_CT_HEALTH,
  168. 0
  169. };
  170.  
  171. new const g_any_health_enabled = ENABLE_TERR_HEALTH + ENABLE_CT_HEALTH;
  172.  
  173. new const g_health_names[CsTeams][] ={
  174. "",
  175. "T Extra Health",
  176. "CT Extra Health",
  177. ""
  178. };
  179.  
  180. new const g_health_maxamount[CsTeams] ={
  181. 0,
  182. 100,
  183. 50,
  184. 0
  185. };
  186.  
  187. new const g_health_maxlevels[CsTeams] ={
  188. 0,
  189. MAXLEVEL_TERR_HEALTH,
  190. MAXLEVEL_CT_HEALTH,
  191. 0
  192. };
  193.  
  194. new const g_health_first_xp[CsTeams] ={
  195. 0,
  196. FIRST_XP_TERR_HEALTH,
  197. FIRST_XP_CT_HEALTH,
  198. 0
  199. };
  200.  
  201. new const g_armor_enabled[CsTeams] ={
  202. 0,
  203. ENABLE_TERR_ARMOR,
  204. ENABLE_CT_ARMOR,
  205. 0
  206. };
  207.  
  208. new const g_any_armor_enabled = ENABLE_TERR_ARMOR + ENABLE_CT_ARMOR;
  209.  
  210. new const g_armor_names[CsTeams][] ={
  211. "",
  212. "T Armor",
  213. "CT Armor",
  214. ""
  215. };
  216.  
  217. new const g_armor_maxamount[CsTeams] ={
  218. 0,
  219. 200,
  220. 150,
  221. 0
  222. };
  223.  
  224. new const g_armor_maxlevels[CsTeams] ={
  225. 0,
  226. MAXLEVEL_TERR_ARMOR,
  227. MAXLEVEL_CT_ARMOR,
  228. 0
  229. };
  230.  
  231. new const g_armor_first_xp[CsTeams] ={
  232. 0,
  233. FIRST_XP_TERR_ARMOR,
  234. FIRST_XP_CT_ARMOR,
  235. 0
  236. };
  237.  
  238. new const g_respawn_enabled[CsTeams] ={
  239. 0,
  240. ENABLE_TERR_RESPAWN,
  241. ENABLE_CT_RESPAWN,
  242. 0
  243. };
  244.  
  245. new const g_any_respawn_enabled = ENABLE_TERR_RESPAWN + ENABLE_CT_RESPAWN;
  246.  
  247. new const g_respawn_names[CsTeams][] ={
  248. "",
  249. "T Respawn Chance",
  250. "CT Respawn Chance",
  251. ""
  252. };
  253.  
  254. new const g_respawn_maxlevels[CsTeams] ={
  255. 0,
  256. MAXLEVEL_TERR_RESPAWN,
  257. MAXLEVEL_CT_RESPAWN,
  258. 0
  259. };
  260.  
  261. new const g_respawn_first_xp[CsTeams] ={
  262. 0,
  263. FIRST_XP_TERR_RESPAWN,
  264. FIRST_XP_CT_RESPAWN,
  265. 0
  266. };
  267.  
  268. new const g_respawn_max_chance[CsTeams] ={
  269. 0,
  270. CHANCE_MAX_TERR_RESPAWN,
  271. CHANCE_MAX_CT_RESPAWN,
  272. 0
  273. };
  274.  
  275. new const g_nofall_enabled[CsTeams] ={
  276. 0,
  277. ENABLE_TERR_NOFALL,
  278. ENABLE_CT_NOFALL,
  279. 0
  280. };
  281.  
  282. new const g_any_nofall_enabled = ENABLE_TERR_NOFALL + ENABLE_CT_NOFALL;
  283.  
  284. new const g_nofall_names[CsTeams][] ={
  285. "",
  286. "T Fall Damage Reducer",
  287. "CT Fall Damage Reducer",
  288. ""
  289. };
  290.  
  291. new const g_nofall_maxlevels[CsTeams] ={
  292. 0,
  293. MAXLEVEL_TERR_NOFALL,
  294. MAXLEVEL_CT_NOFALL,
  295. 0
  296. };
  297.  
  298. new const g_nofall_first_xp[CsTeams] ={
  299. 0,
  300. FIRST_XP_TERR_NOFALL,
  301. FIRST_XP_CT_NOFALL,
  302. 0
  303. };
  304.  
  305. new const g_nofall_max_chance[CsTeams] ={
  306. 0,
  307. CHANCE_MAX_TERR_NOFALL,
  308. CHANCE_MAX_CT_NOFALL,
  309. 0
  310. };
  311.  
  312. #define ANY_ABILITY_ENABLED (g_any_nade_enabled || g_any_health_enabled || g_any_armor_enabled || g_any_respawn_enabled || g_any_nofall_enabled)
  313.  
  314. new g_authid[33][35];
  315.  
  316. new g_xp[33];
  317.  
  318. new g_first_time[33];
  319. #if defined USING_SQL
  320. new g_loaded_data[33];
  321. #endif
  322.  
  323. new g_used_revive[33];
  324.  
  325. new g_nade_level[33][Grenades];
  326. new g_armor_level[33][CsTeams];
  327. new g_respawn_level[33][CsTeams];
  328. new g_health_level[33][CsTeams];
  329. new g_nofall_level[33][CsTeams];
  330.  
  331. new cvar_xp_kill;
  332. new cvar_xp_headshot;
  333. new cvar_xp_grenade;
  334.  
  335. new Float:g_nade_give_time;
  336.  
  337. new Regex:g_SteamID_pattern;
  338. new g_regex_return;
  339.  
  340. new g_first_client;
  341. new g_max_clients;
  342.  
  343. new g_msgid_SayText;
  344.  
  345. #if defined USING_SQL
  346. public plugin_precache()
  347. {
  348. g_sql_tuple = SQL_MakeStdTuple();
  349.  
  350. SQL_ThreadQuery(g_sql_tuple, "QueryCreateTable", "CREATE TABLE IF NOT EXISTS `hns_xp` ( `name` VARCHAR(32) NOT NULL, `authid` VARCHAR(35) NOT NULL, `data` VARCHAR(256) NOT NULL );" );
  351. }
  352.  
  353. public QueryCreateTable(failstate, Handle:query, error[], errnum, data[], size, Float:queuetime)
  354. {
  355. if( failstate == TQUERY_CONNECT_FAILED || failstate == TQUERY_QUERY_FAILED )
  356. {
  357. set_fail_state(error);
  358. }
  359. }
  360. #endif
  361.  
  362. public plugin_init()
  363. {
  364. register_plugin("HideNSeek XP Mod", VERSION, "Exolent");
  365. register_cvar("hnsxp_author", "Exolent", FCVAR_SPONLY);
  366. register_cvar("hnsxp_version", VERSION, FCVAR_SPONLY);
  367.  
  368. register_clcmd("say /xp", "CmdMainMenu");
  369. register_clcmd("say /exp", "CmdMainMenu");
  370.  
  371. register_concmd("hnsxp_give_xp", "CmdGiveXP", ADMIN_RCON, "<nick, #userid, authid> <xp>");
  372. register_concmd("hnsxp_remove_xp", "CmdRemoveXP", ADMIN_RCON, "<nick, #userid, authid> <xp>");
  373.  
  374. register_event("HLTV", "EventNewRound", "a", "1=0", "2=0");
  375. register_event("DeathMsg", "EventDeathMsg", "a");
  376. register_logevent("EventRoundStart", 2, "1=Round_Start");
  377. register_logevent("EventRoundEnd", 2, "1=Round_End");
  378. register_event("TextMsg", "EventRoundRestart", "a", "2&#Game_C", "2&#Game_w");
  379.  
  380. RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn", 1);
  381. RegisterHam(Ham_Killed, "player", "FwdPlayerDeath", 1);
  382. RegisterHam(Ham_TakeDamage, "player", "FwdPlayerDamage");
  383.  
  384. cvar_xp_kill = register_cvar("hnsxp_xp_kill", "3");
  385. cvar_xp_headshot = register_cvar("hnsxp_xp_headshot", "4");
  386. cvar_xp_grenade = register_cvar("hnsxp_xp_grenade", "2");
  387.  
  388. #if !defined USING_SQL
  389. g_vault = nvault_open("hnsxp");
  390. #endif
  391.  
  392. new err[2];
  393. g_SteamID_pattern = regex_compile("^^STEAM_0:(0|1):\d+$", g_regex_return, err, sizeof(err) - 1);
  394.  
  395. g_first_client = 1;
  396. g_max_clients = get_maxplayers();
  397.  
  398. g_msgid_SayText = get_user_msgid("SayText");
  399. }
  400.  
  401. #if !defined USING_SQL
  402. public plugin_end()
  403. {
  404. nvault_close(g_vault);
  405. }
  406. #endif
  407.  
  408. public plugin_natives()
  409. {
  410. register_library("hns_xp");
  411. register_native("hnsxp_get_user_xp", "_get_xp");
  412. register_native("hnsxp_set_user_xp", "_set_xp");
  413. }
  414.  
  415. public _get_xp(plugin, params)
  416. {
  417. return g_xp[get_param(1)];
  418. }
  419.  
  420. public _set_xp(plugin, params)
  421. {
  422. new client = get_param(1);
  423. g_xp[client] = max(0, get_param(2));
  424. Save(client);
  425. return g_xp[client];
  426. }
  427.  
  428. public client_authorized(client)
  429. {
  430. if( !is_user_bot(client) && !is_user_hltv(client) )
  431. {
  432. /* is this still called in LAN, non-steam, etc? */
  433. get_user_authid(client, g_authid[client], sizeof(g_authid[]) - 1);
  434.  
  435. if( !IsValidAuthid(g_authid[client]) )
  436. {
  437. g_authid[client][0] = 0;
  438. }
  439. else
  440. {
  441. Load(client);
  442. }
  443. }
  444. }
  445.  
  446. public client_disconnect(client)
  447. {
  448. Save(client);
  449.  
  450. g_authid[client][0] = 0;
  451. g_first_time[client] = 0;
  452. #if defined USING_SQL
  453. g_loaded_data[client] = 0;
  454. #endif
  455. g_used_revive[client] = 0;
  456. }
  457.  
  458. public CmdMainMenu(client)
  459. {
  460. ShowMainMenu(client);
  461. }
  462.  
  463. public CmdGiveXP(client, level, cid)
  464. {
  465. if( !cmd_access(client, level, cid, 3) ) return PLUGIN_HANDLED;
  466.  
  467. static arg[35];
  468. read_argv(1, arg, sizeof(arg) - 1);
  469.  
  470. new target = cmd_target(client, arg, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_NO_BOTS);
  471. if( !target ) return PLUGIN_HANDLED;
  472.  
  473. if( !IsUserAuthorized(target) )
  474. {
  475. console_print(client, "Target has not authorized with the server.");
  476. return PLUGIN_HANDLED;
  477. }
  478.  
  479. read_argv(2, arg, sizeof(arg) - 1);
  480. new xp = str_to_num(arg);
  481.  
  482. if( xp <= 0 )
  483. {
  484. console_print(client, "XP must be a value greater than 0!");
  485. if( xp < 0 )
  486. {
  487. console_print(client, "Use hnsxp_remove_xp instead.");
  488. }
  489. return PLUGIN_HANDLED;
  490. }
  491.  
  492. g_xp[target] += xp;
  493.  
  494. Save(target);
  495.  
  496. static name[2][32];
  497. get_user_name(client, name[0], sizeof(name[]) - 1);
  498. get_user_name(target, name[1], sizeof(name[]) - 1);
  499.  
  500. Print(0, "%s gave %i XP to %s.", name[0], xp, name[1]);
  501.  
  502. static steamid[2][35];
  503. get_user_authid(client, steamid[0], sizeof(steamid[]) - 1);
  504. get_user_authid(target, steamid[1], sizeof(steamid[]) - 1);
  505.  
  506. log_amx("%s (%s) gave %i XP to %s (%s)", name[0], steamid[0], xp, name[1], steamid[1]);
  507.  
  508. return PLUGIN_HANDLED;
  509. }
  510.  
  511. public CmdRemoveXP(client, level, cid)
  512. {
  513. if( !cmd_access(client, level, cid, 3) ) return PLUGIN_HANDLED;
  514.  
  515. static arg[35];
  516. read_argv(1, arg, sizeof(arg) - 1);
  517.  
  518. new target = cmd_target(client, arg, CMDTARGET_OBEY_IMMUNITY|CMDTARGET_NO_BOTS);
  519. if( !target ) return PLUGIN_HANDLED;
  520.  
  521. if( !IsUserAuthorized(target) )
  522. {
  523. console_print(client, "Target has not authorized with the server.");
  524. return PLUGIN_HANDLED;
  525. }
  526.  
  527. read_argv(2, arg, sizeof(arg) - 1);
  528. new xp = str_to_num(arg);
  529.  
  530. if( xp <= 0 )
  531. {
  532. console_print(client, "XP must be a value greater than 0!");
  533. if( xp < 0 )
  534. {
  535. console_print(client, "Use hnsxp_give_xp instead.");
  536. }
  537. return PLUGIN_HANDLED;
  538. }
  539.  
  540. g_xp[target] -= xp;
  541.  
  542. Save(target);
  543.  
  544. static name[2][32];
  545. get_user_name(client, name[0], sizeof(name[]) - 1);
  546. get_user_name(target, name[1], sizeof(name[]) - 1);
  547.  
  548. Print(0, "%s removed %i XP from %s.", name[0], xp, name[1]);
  549.  
  550. static steamid[2][35];
  551. get_user_authid(client, steamid[0], sizeof(steamid[]) - 1);
  552. get_user_authid(target, steamid[1], sizeof(steamid[]) - 1);
  553.  
  554. log_amx("%s (%s) removed %i XP from %s (%s)", name[0], steamid[0], xp, name[1], steamid[1]);
  555.  
  556. return PLUGIN_HANDLED;
  557. }
  558.  
  559. public EventNewRound()
  560. {
  561. arrayset(g_used_revive, 0, sizeof(g_used_revive));
  562.  
  563. g_nade_give_time = 9999999.9;
  564. }
  565.  
  566. public EventDeathMsg()
  567. {
  568. new killer = read_data(1);
  569. new victim = read_data(2);
  570.  
  571. if( (g_first_client <= killer <= g_max_clients) && victim != killer )
  572. {
  573. if( IsUserAuthorized(killer) )
  574. {
  575. // regular kill
  576. new xp = get_pcvar_num(cvar_xp_kill);
  577.  
  578. if( read_data(3) )
  579. {
  580. // headshot kill
  581. xp += get_pcvar_num(cvar_xp_headshot);
  582. }
  583. else
  584. {
  585. static weapon[20];
  586. read_data(4, weapon, sizeof(weapon) - 1);
  587.  
  588. if( contain(weapon, "grenade") >= 0 )
  589. {
  590. // grenade kill (or frostnade)
  591. xp += get_pcvar_num(cvar_xp_grenade);
  592. }
  593. }
  594.  
  595. g_xp[killer] += xp;
  596.  
  597. Print(killer,"You gained %i XP!", xp);
  598.  
  599. Save(killer);
  600. }
  601. }
  602. }
  603.  
  604. public EventRoundStart()
  605. {
  606. g_nade_give_time = get_pcvar_float();
  607.  
  608. set_task(g_nade_give_time, "TaskGiveNades", 1234);
  609.  
  610. g_nade_give_time += get_gametime();
  611. }
  612.  
  613. public EventRoundEnd()
  614. {
  615. EventRoundRestart();
  616.  
  617. new hider, seeker, hider_alive;
  618.  
  619. for( new i = g_first_client; i <= g_max_clients; i++ )
  620. {
  621. if( is_user_connected(i) )
  622. {
  623. switch( cs_get_user_team(i) )
  624. {
  625. case CS_TEAM_CT:
  626. {
  627. if( !seeker )
  628. {
  629. seeker = i;
  630. }
  631. }
  632. case CS_TEAM_T:
  633. {
  634. if( !hider )
  635. {
  636. hider = i;
  637.  
  638. if( !hider_alive && is_user_alive(i) )
  639. {
  640. hider_alive = i;
  641. }
  642. }
  643. }
  644. }
  645.  
  646. if( seeker && hider && hider_alive )
  647. {
  648. break;
  649. }
  650. }
  651. }
  652.  
  653. if( !hider || !seeker )
  654. {
  655. return;
  656. }
  657.  
  658. new CsTeams:winner = CS_TEAM_CT;
  659.  
  660. if( hider_alive )
  661. {
  662. winner = CS_TEAM_T;
  663. }
  664.  
  665. public EventRoundRestart()
  666. {
  667. remove_task(1234);
  668.  
  669. g_nade_give_time = 9999999.9;
  670. }
  671.  
  672. public FwdPlayerSpawn(client)
  673. {
  674. if( is_user_alive(client) )
  675. {
  676. new CsTeams:team = cs_get_user_team(client);
  677. if( team == CS_TEAM_T || team == CS_TEAM_CT )
  678. {
  679. if( g_first_time[client] )
  680. {
  681. Print(client, "It is your first time playing this HideNSeek XP mod, so you are rewarded with %i XP!", ENTRY_XP);
  682. Print(client, "You earn XP based upon your gameplay, and you can buy more levels in the menu.");
  683. Print(client, "Type /xp to view what you can get!");
  684.  
  685. g_first_time[client] = 0;
  686. }
  687. else
  688. {
  689. if( g_health_enabled[team] )
  690. {
  691. new health = g_health_maxamount[team] * g_health_level[client][team] / g_health_maxlevels[team];
  692. if( health > 0 )
  693. {
  694. set_user_health(client, get_user_health(client) + health);
  695. }
  696. }
  697.  
  698. if( g_armor_enabled[team] )
  699. {
  700. new armorvalue = g_armor_maxamount[team] * g_armor_level[client][team] / g_armor_maxlevels[team];
  701. if( armorvalue == 0 )
  702. {
  703. cs_set_user_armor(client, armorvalue, CS_ARMOR_NONE);
  704. }
  705. else if( armorvalue < 100 )
  706. {
  707. cs_set_user_armor(client, armorvalue, CS_ARMOR_KEVLAR);
  708. }
  709. else
  710. {
  711. cs_set_user_armor(client, armorvalue, CS_ARMOR_VESTHELM);
  712. }
  713. }
  714. }
  715.  
  716. if( get_gametime() >= g_nade_give_time )
  717. {
  718. GiveNades(client);
  719. }
  720. }
  721. }
  722. }
  723.  
  724. public FwdPlayerDeath(client, killer, shouldgib)
  725. {
  726. if( !g_used_revive[client] )
  727. {
  728. new CsTeams:team = cs_get_user_team(client);
  729. if( team == CS_TEAM_T || team == CS_TEAM_CT )
  730. {
  731. if( g_respawn_enabled[team] )
  732. {
  733. new percent = g_respawn_max_chance[team] * g_respawn_level[client][team] / g_respawn_maxlevels[team];
  734. if( random_num(1, 100) <= percent )
  735. {
  736. if( HasTeammateAlive(client, team) )
  737. {
  738. set_task(0.5, "TaskRespawn", client);
  739.  
  740. Print(client, "You have been respawned! (%i%% chance)", percent);
  741.  
  742. g_used_revive[client] = 1;
  743. }
  744. }
  745. }
  746. }
  747. }
  748. }
  749.  
  750. public FwdPlayerDamage(client, inflictor, attacker, Float:damage, damagebits)
  751. {
  752. if( is_user_alive(client) && (damagebits & DMG_FALL) )
  753. {
  754. new CsTeams:team = cs_get_user_team(client);
  755. if( team == CS_TEAM_T || team == CS_TEAM_CT )
  756. {
  757. if( g_nofall_enabled[team] )
  758. {
  759. new percent = g_nofall_max_chance[team] * g_nofall_level[client][team] / g_nofall_maxlevels[team];
  760. SetHamParamFloat(4, damage * (1.0 - (float(percent) / 100.0)));
  761. }
  762. }
  763. }
  764. }
  765.  
  766. public TaskRespawn(client)
  767. {
  768. ExecuteHamB(Ham_CS_RoundRespawn, client);
  769. }
  770.  
  771. public TaskGiveNades()
  772. {
  773. for( new client = g_first_client; client <= g_max_clients; client++ )
  774. {
  775. if( is_user_alive(client) )
  776. {
  777. GiveNades(client);
  778. }
  779. }
  780. }
  781.  
  782. HasTeammateAlive(client, CsTeams:team)
  783. {
  784. for( new i = g_first_client; i <= g_max_clients; i++ )
  785. {
  786. if( i == client ) continue;
  787.  
  788. if( is_user_alive(i) && cs_get_user_team(i) == team )
  789. {
  790. return 1;
  791. }
  792. }
  793.  
  794. return 0;
  795. }
  796.  
  797. GiveNades(client)
  798. {
  799. new CsTeams:team = cs_get_user_team(client);
  800.  
  801. if( team == CS_TEAM_T )
  802. {
  803. static percent;
  804. for( new i = 0; i < Grenades; i++ )
  805. {
  806. if( g_nade_enabled[i] )
  807. {
  808. percent = g_nade_max_chance[i] * g_nade_level[client][i] / g_nade_maxlevels[i];
  809. if( percent > 0 && (percent == 100 || random_num(1, 100) <= percent) )
  810. {
  811. give_item(client, g_nade_classnames[i]);
  812.  
  813. if( percent < 100 )
  814. {
  815. Print(client, "You received your %s! (%i%% chance)", g_nade_names[i], percent);
  816. }
  817. }
  818. }
  819. }
  820. }
  821. }
  822.  
  823. ShowMainMenu(client)
  824. {
  825. static title[128];
  826. formatex(title, sizeof(title) - 1, "[HNS XP by Exolent]^nMain Menu^n^nYour XP: \w%i", g_xp[client]);
  827. new menu = menu_create(title, "MenuMain");
  828.  
  829. //menu_additem(menu, "\yHelp", "*");
  830. if( g_any_nade_enabled )
  831. {
  832. menu_additem(menu, "Grenades Menu", "1");
  833. }
  834. if( g_any_health_enabled )
  835. {
  836. menu_additem(menu, "Health Menu", "2");
  837. }
  838. if( g_any_armor_enabled )
  839. {
  840. menu_additem(menu, "Armor Menu", "3");
  841. }
  842. if( g_any_respawn_enabled )
  843. {
  844. menu_additem(menu, "Respawn Menu", "4");
  845. }
  846. if( g_any_nofall_enabled )
  847. {
  848. menu_additem(menu, "Fall Damage Menu^n", "5");
  849. }
  850. if( ANY_ABILITY_ENABLED )
  851. {
  852. menu_additem(menu, "Player Info", "6", ADMIN_SLAY);
  853. }
  854.  
  855. menu_display(client, menu);
  856. }
  857.  
  858. public MenuMain(client, menu, item)
  859. {
  860. if( item == MENU_EXIT )
  861. {
  862. menu_destroy(menu);
  863. return;
  864. }
  865.  
  866. static _access, info[4], callback;
  867. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  868. menu_destroy(menu);
  869.  
  870. switch( info[0] )
  871. {
  872. case '*':
  873. {
  874. static motd[2500];
  875. new len = formatex(motd, sizeof(motd) - 1, "<body style=^"background-color:#030303; color:#FF8F00^">");
  876. len += format(motd[len], sizeof(motd) - len - 1, "<p align=^"center^">");
  877. len += format(motd[len], sizeof(motd) - len - 1, "HideNSeek XP Mod is an experienced based addon for HideNSeek.<br>");
  878. len += format(motd[len], sizeof(motd) - len - 1, "Players earn experience points by how well they play the game.<br>");
  879. len += format(motd[len], sizeof(motd) - len - 1, "<br>");
  880. len += format(motd[len], sizeof(motd) - len - 1, "<table border=0>");
  881. len += format(motd[len], sizeof(motd) - len - 1, "<tr><th>Action</th><th>XP</th></tr>");
  882. len += format(motd[len], sizeof(motd) - len - 1, "<tr><td>Kill</td><td>+%i</td></tr>", get_pcvar_num(cvar_xp_kill));
  883. len += format(motd[len], sizeof(motd) - len - 1, "<tr><td>Grenade</td><td>+%i</td></tr>", get_pcvar_num(cvar_xp_grenade));
  884. len += format(motd[len], sizeof(motd) - len - 1, "<tr><td>Headshot</td><td>+%i</td></tr>", get_pcvar_num(cvar_xp_headshot));
  885. len += format(motd[len], sizeof(motd) - len - 1, "<tr><td>Suicide</td><td>-%i</td></tr>", get_pcvar_num(cvar_xp_suicide));
  886. len += format(motd[len], sizeof(motd) - len - 1, "<tr><td>Survive as a T</td><td>+%i</td></tr>", get_pcvar_num(cvar_xp_survive));
  887. len += format(motd[len], sizeof(motd) - len - 1, "<tr><td>Win Round</td><td>+%i</td></tr>", get_pcvar_num(cvar_xp_win));
  888. len += format(motd[len], sizeof(motd) - len - 1, "</table>");
  889. len += format(motd[len], sizeof(motd) - len - 1, "With these XP points, you can buy upgrades.<br>");
  890. len += format(motd[len], sizeof(motd) - len - 1, "For a list of these upgrades, type /xp again and view the other menus inside.");
  891. len += format(motd[len], sizeof(motd) - len - 1, "</p>");
  892. len += format(motd[len], sizeof(motd) - len - 1, "</body>");
  893.  
  894. show_motd(client, motd, "HideNSeek XP Mod Info");
  895. }
  896. case '1':
  897. {
  898. ShowGrenadesMenu(client);
  899. }
  900. case '2':
  901. {
  902. ShowHealthMenu(client);
  903. }
  904. case '3':
  905. {
  906. ShowArmorMenu(client);
  907. }
  908. case '4':
  909. {
  910. ShowRespawnMenu(client);
  911. }
  912. case '5':
  913. {
  914. ShowNoFallMenu(client);
  915. }
  916. case '6':
  917. {
  918. ShowPlayerMenu(client);
  919. }
  920. }
  921. }
  922.  
  923. ShowGrenadesMenu(client)
  924. {
  925. static title[128];
  926. formatex(title, sizeof(title) - 1, "[HNS XP by Exolent]^nGrenades Menu^n^nNote: \wGrenade abilities are for \rT's Only!\y^n^nYour XP: \w%i", g_xp[client]);
  927. new menu = menu_create(title, "MenuGrenades");
  928. new callback = menu_makecallback("CallbackGrenades");
  929.  
  930. //menu_additem(menu, "\yHelp", "*", _, callback);
  931.  
  932. static level, xp, percent, item[128], info[4];
  933. for( new i = 0; i < Grenades; i++ )
  934. {
  935. if( g_nade_enabled[i] )
  936. {
  937. level = g_nade_level[client][i] + 1;
  938. percent = g_nade_max_chance[i] * level / g_nade_maxlevels[i];
  939.  
  940. if( g_nade_level[client][i] < g_nade_maxlevels[i] )
  941. {
  942. xp = g_nade_first_xp[i] * (1 << (level - 1));
  943. formatex(item, sizeof(item) - 1, "%s: \yLevel %i (%i%%) \r[\w%i XP\r]", g_nade_names[i], level, percent, xp);
  944. }
  945. else
  946. {
  947. formatex(item, sizeof(item) - 1, "%s: \yLevel %i (%i%%) \r[\wMaxed Out!\r]", g_nade_names[i], level, percent);
  948. }
  949.  
  950. num_to_str(i, info, sizeof(info) - 1);
  951.  
  952. menu_additem(menu, item, info, _, callback);
  953. }
  954. }
  955.  
  956. menu_display(client, menu);
  957. }
  958.  
  959. public MenuGrenades(client, menu, item)
  960. {
  961. if( item == MENU_EXIT )
  962. {
  963. menu_destroy(menu);
  964. ShowMainMenu(client);
  965. return;
  966. }
  967.  
  968. static _access, info[4], callback;
  969. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  970. menu_destroy(menu);
  971.  
  972. if( info[0] == '*' )
  973. {
  974. static motd[2500];
  975. new len = formatex(motd, sizeof(motd) - 1, "<body style=^"background-color:#030303; color:#FF8F00^">");
  976. len += format(motd[len], sizeof(motd) - len - 1, "<p align=^"center^">");
  977. len += format(motd[len], sizeof(motd) - len - 1, "The Grenades ability for the XP Mod is for Terrorists only.<br>");
  978. len += format(motd[len], sizeof(motd) - len - 1, "The Grenades ability contains the HE Grenade, 2 Flashbangs, and Frost Nade.<br>");
  979. len += format(motd[len], sizeof(motd) - len - 1, "These are the grenades you are given when you receive the your items after the hide timer ends.<br>");
  980. len += format(motd[len], sizeof(motd) - len - 1, "<br>");
  981. len += format(motd[len], sizeof(motd) - len - 1, "<table>");
  982. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  983. len += format(motd[len], sizeof(motd) - len - 1, "<th></th>");
  984. for( new i = 0; i < Grenades; i++ )
  985. {
  986. if( g_nade_enabled[i] )
  987. {
  988. len += format(motd[len], sizeof(motd) - len - 1, "<th>%s</th>", g_nade_names[i]);
  989. }
  990. }
  991. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  992. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  993. len += format(motd[len], sizeof(motd) - len - 1, "<th>Chance Intervals</th>");
  994. for( new i = 0; i < Grenades; i++ )
  995. {
  996. if( g_nade_enabled[i] )
  997. {
  998. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i%%</td>", (g_nade_max_chance[i] / g_nade_maxlevels[i]));
  999. }
  1000. }
  1001. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1002. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1003. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Level</th>");
  1004. for( new i = 0; i < Grenades; i++ )
  1005. {
  1006. if( g_nade_enabled[i] )
  1007. {
  1008. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i</td>", g_nade_maxlevels[i]);
  1009. }
  1010. }
  1011. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1012. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Chance</th>");
  1013. for( new i = 0; i < Grenades; i++ )
  1014. {
  1015. if( g_nade_enabled[i] )
  1016. {
  1017. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i%%</td>", g_nade_max_chance[i]);
  1018. }
  1019. }
  1020. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1021. len += format(motd[len], sizeof(motd) - len - 1, "</table>");
  1022. len += format(motd[len], sizeof(motd) - len - 1, "</p>");
  1023. len += format(motd[len], sizeof(motd) - len - 1, "</body>");
  1024.  
  1025. show_motd(client, motd, "XP Grenades Info");
  1026. }
  1027. else
  1028. {
  1029. new upgrade = str_to_num(info);
  1030.  
  1031. new level = g_nade_level[client][upgrade] + 1;
  1032. new xp = g_nade_first_xp[upgrade] * (1 << (level - 1));
  1033. new percent = g_nade_max_chance[upgrade] * level / g_nade_maxlevels[upgrade];
  1034.  
  1035. g_xp[client] -= xp;
  1036. g_nade_level[client][upgrade] = level;
  1037.  
  1038. Save(client);
  1039.  
  1040. Print(client, "You bought %s Level %i (%i%%) for %i XP!", g_nade_names[upgrade], level, percent, xp);
  1041. }
  1042.  
  1043. ShowGrenadesMenu(client);
  1044. }
  1045.  
  1046. public CallbackGrenades(client, menu, item)
  1047. {
  1048. static _access, info[4], callback;
  1049. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  1050.  
  1051. if( info[0] == '*' ) return ITEM_ENABLED;
  1052.  
  1053. new upgrade = str_to_num(info);
  1054. if( g_nade_level[client][upgrade] == g_nade_maxlevels[upgrade] )
  1055. {
  1056. return ITEM_DISABLED;
  1057. }
  1058.  
  1059. new xp = g_nade_first_xp[upgrade] * (1 << g_nade_level[client][upgrade]);
  1060. if( g_xp[client] < xp )
  1061. {
  1062. return ITEM_DISABLED;
  1063. }
  1064.  
  1065. return ITEM_ENABLED;
  1066. }
  1067.  
  1068. ShowHealthMenu(client)
  1069. {
  1070. static title[128];
  1071. formatex(title, sizeof(title) - 1, "[HNS XP by Exolent]^nHealth Menu^n^nYour XP: \w%i", g_xp[client]);
  1072. new menu = menu_create(title, "MenuHealth");
  1073. new callback = menu_makecallback("CallbackHealth");
  1074.  
  1075. //menu_additem(menu, "\yHelp", "*", _, callback);
  1076.  
  1077. static level, xp, amount, item[128], info[4];
  1078. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1079. {
  1080. if( g_health_enabled[i] )
  1081. {
  1082. level = g_health_level[client][i] + 1;
  1083. amount = g_health_maxamount[i] * level / g_health_maxlevels[i];
  1084.  
  1085. if( g_health_level[client][i] < g_health_maxlevels[i] )
  1086. {
  1087. xp = g_health_first_xp[i] * (1 << (level - 1));
  1088. formatex(item, sizeof(item) - 1, "%s: \yLevel %i (%i HP) \r[\w%i XP\r]", g_health_names[i], level, amount, xp);
  1089. }
  1090. else
  1091. {
  1092. formatex(item, sizeof(item) - 1, "\w%s: \yLevel %i (%i HP) \r[\wMaxed Out!\r]", g_health_names[i], level, amount);
  1093. }
  1094.  
  1095. num_to_str(_:i, info, sizeof(info) - 1);
  1096.  
  1097. menu_additem(menu, item, info, _, callback);
  1098. }
  1099. }
  1100.  
  1101. menu_display(client, menu);
  1102. }
  1103.  
  1104. public MenuHealth(client, menu, item)
  1105. {
  1106. if( item == MENU_EXIT )
  1107. {
  1108. menu_destroy(menu);
  1109. ShowMainMenu(client);
  1110. return;
  1111. }
  1112.  
  1113. static _access, info[4], callback;
  1114. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  1115. menu_destroy(menu);
  1116.  
  1117. if( info[0] == '*' )
  1118. {
  1119. static motd[2500];
  1120. new len = formatex(motd, sizeof(motd) - 1, "<body style=^"background-color:#030303; color:#FF8F00^">");
  1121. len += format(motd[len], sizeof(motd) - len - 1, "<p align=^"center^">");
  1122. len += format(motd[len], sizeof(motd) - len - 1, "The Health ability is the amount of HP that is added to your spawn health.<br>");
  1123. len += format(motd[len], sizeof(motd) - len - 1, "<br>");
  1124. len += format(motd[len], sizeof(motd) - len - 1, "<table>");
  1125. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1126. len += format(motd[len], sizeof(motd) - len - 1, "<th></th>");
  1127. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1128. {
  1129. if( g_health_enabled[i] )
  1130. {
  1131. len += format(motd[len], sizeof(motd) - len - 1, "<th>%s</th>",g_team_names[i]);
  1132. }
  1133. }
  1134. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1135. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1136. len += format(motd[len], sizeof(motd) - len - 1, "<th>Health Intervals</th>");
  1137. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1138. {
  1139. if( g_health_enabled[i] )
  1140. {
  1141. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i</td>", (g_health_maxamount[i] / g_health_maxlevels[i]));
  1142. }
  1143. }
  1144. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1145. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1146. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Level</th>");
  1147. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1148. {
  1149. if( g_health_enabled[i] )
  1150. {
  1151. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i</td>", g_health_maxlevels[i]);
  1152. }
  1153. }
  1154. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1155. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Health</th>");
  1156. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1157. {
  1158. if( g_health_enabled[i] )
  1159. {
  1160. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i</td>", g_health_maxamount[i]);
  1161. }
  1162. }
  1163. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1164. len += format(motd[len], sizeof(motd) - len - 1, "</table>");
  1165. len += format(motd[len], sizeof(motd) - len - 1, "</p>");
  1166. len += format(motd[len], sizeof(motd) - len - 1, "</body>");
  1167.  
  1168. show_motd(client, motd, "XP Health Info");
  1169. }
  1170. else
  1171. {
  1172. new CsTeams:upgrade = CsTeams:str_to_num(info);
  1173.  
  1174. new level = g_health_level[client][upgrade] + 1;
  1175. new xp = g_health_first_xp[upgrade] * (1 << (level - 1));
  1176. new amount = g_health_maxamount[upgrade] * level / g_health_maxlevels[upgrade];
  1177.  
  1178. g_xp[client] -= xp;
  1179. g_health_level[client][upgrade] = level;
  1180.  
  1181. Save(client);
  1182.  
  1183. Print(client, "You bought %s Level %i (%i HP) for %i XP!", g_health_names[upgrade], level, amount, xp);
  1184. }
  1185.  
  1186. ShowHealthMenu(client);
  1187. }
  1188.  
  1189. public CallbackHealth(client, menu, item)
  1190. {
  1191. static _access, info[4], callback;
  1192. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  1193.  
  1194. if( info[0] == '*' ) return ITEM_ENABLED;
  1195.  
  1196. new CsTeams:upgrade = CsTeams:str_to_num(info);
  1197. if( g_health_level[client][upgrade] == g_health_maxlevels[upgrade] )
  1198. {
  1199. return ITEM_DISABLED;
  1200. }
  1201.  
  1202. new xp = g_health_first_xp[upgrade] * (1 << g_health_level[client][upgrade]);
  1203. if( g_xp[client] < xp )
  1204. {
  1205. return ITEM_DISABLED;
  1206. }
  1207.  
  1208. return ITEM_ENABLED;
  1209. }
  1210.  
  1211. ShowArmorMenu(client)
  1212. {
  1213. static title[128];
  1214. formatex(title, sizeof(title) - 1, "[HNS XP by Exolent]^nArmor Menu^n^nYour XP: \w%i", g_xp[client]);
  1215. new menu = menu_create(title, "MenuArmor");
  1216. new callback = menu_makecallback("CallbackArmor");
  1217.  
  1218. //menu_additem(menu, "\yHelp", "*", _, callback);
  1219.  
  1220. static level, xp, amount, item[128], info[4];
  1221. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1222. {
  1223. if( g_armor_enabled[i] )
  1224. {
  1225. level = g_armor_level[client][i] + 1;
  1226. amount = g_armor_maxamount[i] * level / g_armor_maxlevels[i];
  1227.  
  1228. if( g_armor_level[client][i] < g_armor_maxlevels[i] )
  1229. {
  1230. xp = g_armor_first_xp[i] * (1 << (level - 1));
  1231. formatex(item, sizeof(item) - 1, "%s: \yLevel %i (%i AP) \r[\w%i XP\r]", g_armor_names[i], level, amount, xp);
  1232. }
  1233. else
  1234. {
  1235. formatex(item, sizeof(item) - 1, "\w%s: \yLevel %i (%i AP) \r[\wMaxed Out!\r]", g_armor_names[i], level, amount);
  1236. }
  1237.  
  1238. num_to_str(_:i, info, sizeof(info) - 1);
  1239.  
  1240. menu_additem(menu, item, info, _, callback);
  1241. }
  1242. }
  1243.  
  1244. menu_display(client, menu);
  1245. }
  1246.  
  1247. public MenuArmor(client, menu, item)
  1248. {
  1249. if( item == MENU_EXIT )
  1250. {
  1251. menu_destroy(menu);
  1252. ShowMainMenu(client);
  1253. return;
  1254. }
  1255.  
  1256. static _access, info[4], callback;
  1257. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  1258. menu_destroy(menu);
  1259.  
  1260. if( info[0] == '*' )
  1261. {
  1262. static motd[2500];
  1263. new len = formatex(motd, sizeof(motd) - 1, "<body style=^"background-color:#030303; color:#FF8F00^">");
  1264. len += format(motd[len], sizeof(motd) - len - 1, "<p align=^"center^">");
  1265. len += format(motd[len], sizeof(motd) - len - 1, "The Armor ability is the amount of AP that given to you at spawn.<br>");
  1266. len += format(motd[len], sizeof(motd) - len - 1, "<br>");
  1267. len += format(motd[len], sizeof(motd) - len - 1, "<table>");
  1268. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1269. len += format(motd[len], sizeof(motd) - len - 1, "<th></th>");
  1270. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1271. {
  1272. if( g_armor_enabled[i] )
  1273. {
  1274. len += format(motd[len], sizeof(motd) - len - 1, "<th>%s</th>",g_team_names[i]);
  1275. }
  1276. }
  1277. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1278. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1279. len += format(motd[len], sizeof(motd) - len - 1, "<th>Armor Intervals</th>");
  1280. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1281. {
  1282. if( g_armor_enabled[i] )
  1283. {
  1284. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i</td>", (g_armor_maxamount[i] / g_armor_maxlevels[i]));
  1285. }
  1286. }
  1287. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1288. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1289. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Level</th>");
  1290. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1291. {
  1292. if( g_armor_enabled[i] )
  1293. {
  1294. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i</td>", g_armor_maxlevels[i]);
  1295. }
  1296. }
  1297. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1298. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Armor</th>");
  1299. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1300. {
  1301. if( g_armor_enabled[i] )
  1302. {
  1303. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i</td>", g_armor_maxamount[i]);
  1304. }
  1305. }
  1306. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1307. len += format(motd[len], sizeof(motd) - len - 1, "</table>");
  1308. len += format(motd[len], sizeof(motd) - len - 1, "</p>");
  1309. len += format(motd[len], sizeof(motd) - len - 1, "</body>");
  1310.  
  1311. show_motd(client, motd, "XP Armor Info");
  1312. }
  1313. else
  1314. {
  1315. new CsTeams:upgrade = CsTeams:str_to_num(info);
  1316.  
  1317. new level = g_armor_level[client][upgrade] + 1;
  1318. new xp = g_armor_first_xp[upgrade] * (1 << (level - 1));
  1319. new amount = g_armor_maxamount[upgrade] * level / g_armor_maxlevels[upgrade];
  1320.  
  1321. g_xp[client] -= xp;
  1322. g_armor_level[client][upgrade] = level;
  1323.  
  1324. Save(client);
  1325.  
  1326. Print(client, "You bought %s Level %i (%i AP) for %i XP!", g_armor_names[upgrade], level, amount, xp);
  1327. }
  1328.  
  1329. ShowArmorMenu(client);
  1330. }
  1331.  
  1332. public CallbackArmor(client, menu, item)
  1333. {
  1334. static _access, info[4], callback;
  1335. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  1336.  
  1337. if( info[0] == '*' ) return ITEM_ENABLED;
  1338.  
  1339. new CsTeams:upgrade = CsTeams:str_to_num(info);
  1340. if( g_armor_level[client][upgrade] == g_armor_maxlevels[upgrade] )
  1341. {
  1342. return ITEM_DISABLED;
  1343. }
  1344.  
  1345. new xp = g_armor_first_xp[upgrade] * (1 << g_armor_level[client][upgrade]);
  1346. if( g_xp[client] < xp )
  1347. {
  1348. return ITEM_DISABLED;
  1349. }
  1350.  
  1351. return ITEM_ENABLED;
  1352. }
  1353.  
  1354. ShowRespawnMenu(client)
  1355. {
  1356. static title[128];
  1357. formatex(title, sizeof(title) - 1, "[HNS XP by Exolent]^nRespawn Menu^n^nYour XP: \w%i", g_xp[client]);
  1358. new menu = menu_create(title, "MenuRespawn");
  1359. new callback = menu_makecallback("CallbackRespawn");
  1360.  
  1361. //menu_additem(menu, "\yHelp", "*", _, callback);
  1362.  
  1363. static level, xp, percent, item[128], info[4];
  1364. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1365. {
  1366. if( g_respawn_enabled[i] )
  1367. {
  1368. level = g_respawn_level[client][i] + 1;
  1369. percent = g_respawn_max_chance[i] * level / g_respawn_maxlevels[i];
  1370.  
  1371. if( g_respawn_level[client][i] < g_respawn_maxlevels[i] )
  1372. {
  1373. xp = g_respawn_first_xp[i] * (1 << (level - 1));
  1374. formatex(item, sizeof(item) - 1, "%s: \yLevel %i (%i%%) \r[\w%i XP\r]", g_respawn_names[i], level, percent, xp);
  1375. }
  1376. else
  1377. {
  1378. formatex(item, sizeof(item) - 1, "%s: \yLevel %i (%i%%) \r[\wMaxed Out!\r]", g_respawn_names[i], level, percent);
  1379. }
  1380.  
  1381. num_to_str(_:i, info, sizeof(info) - 1);
  1382.  
  1383. menu_additem(menu, item, info, _, callback);
  1384. }
  1385. }
  1386.  
  1387. menu_display(client, menu);
  1388. }
  1389.  
  1390. public MenuRespawn(client, menu, item)
  1391. {
  1392. if( item == MENU_EXIT )
  1393. {
  1394. menu_destroy(menu);
  1395. ShowMainMenu(client);
  1396. return;
  1397. }
  1398.  
  1399. static _access, info[4], callback;
  1400. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  1401. menu_destroy(menu);
  1402.  
  1403. if( info[0] == '*' )
  1404. {
  1405. static motd[2500];
  1406. new len = formatex(motd, sizeof(motd) - 1, "<body style=^"background-color:#030303; color:#FF8F00^">");
  1407. len += format(motd[len], sizeof(motd) - len - 1, "<p align=^"center^">");
  1408. len += format(motd[len], sizeof(motd) - len - 1, "The Respawn ability is chance to be respawned when you die.<br>");
  1409. len += format(motd[len], sizeof(motd) - len - 1, "<br>");
  1410. len += format(motd[len], sizeof(motd) - len - 1, "<table>");
  1411. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1412. len += format(motd[len], sizeof(motd) - len - 1, "<th></th>");
  1413. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1414. {
  1415. if( g_respawn_enabled[i] )
  1416. {
  1417. len += format(motd[len], sizeof(motd) - len - 1, "<th>%s</th>",g_team_names[i]);
  1418. }
  1419. }
  1420. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1421. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1422. len += format(motd[len], sizeof(motd) - len - 1, "<th>Chance Intervals</th>");
  1423. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1424. {
  1425. if( g_respawn_enabled[i] )
  1426. {
  1427. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i%%</td>", (g_respawn_max_chance[i] / g_respawn_maxlevels[i]));
  1428. }
  1429. }
  1430. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1431. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1432. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Level</th>");
  1433. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1434. {
  1435. if( g_respawn_enabled[i] )
  1436. {
  1437. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i</td>", g_respawn_maxlevels[i]);
  1438. }
  1439. }
  1440. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1441. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Chance</th>");
  1442. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1443. {
  1444. if( g_respawn_enabled[i] )
  1445. {
  1446. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i%%</td>", g_respawn_max_chance[i]);
  1447. }
  1448. }
  1449. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1450. len += format(motd[len], sizeof(motd) - len - 1, "</table>");
  1451. len += format(motd[len], sizeof(motd) - len - 1, "</p>");
  1452. len += format(motd[len], sizeof(motd) - len - 1, "</body>");
  1453.  
  1454. show_motd(client, motd, "XP Respawn Info");
  1455. }
  1456. else
  1457. {
  1458. new CsTeams:upgrade = CsTeams:str_to_num(info);
  1459.  
  1460. new level = g_respawn_level[client][upgrade] + 1;
  1461. new xp = g_respawn_first_xp[upgrade] * (1 << (level - 1));
  1462. new percent = g_respawn_max_chance[upgrade] * level / g_respawn_maxlevels[upgrade];
  1463.  
  1464. g_xp[client] -= xp;
  1465. g_respawn_level[client][upgrade] = level;
  1466.  
  1467. Save(client);
  1468.  
  1469. Print(client, "You bought %s Level %i (%i%%) for %i XP!", g_respawn_names[upgrade], level, percent, xp);
  1470. }
  1471.  
  1472. ShowRespawnMenu(client);
  1473. }
  1474.  
  1475. public CallbackRespawn(client, menu, item)
  1476. {
  1477. static _access, info[4], callback;
  1478. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  1479.  
  1480. if( info[0] == '*' ) return ITEM_ENABLED;
  1481.  
  1482. new CsTeams:upgrade = CsTeams:str_to_num(info);
  1483. if( g_respawn_level[client][upgrade] == g_respawn_maxlevels[upgrade] )
  1484. {
  1485. return ITEM_DISABLED;
  1486. }
  1487.  
  1488. new xp = g_respawn_first_xp[upgrade] * (1 << g_respawn_level[client][upgrade]);
  1489. if( g_xp[client] < xp || g_respawn_level[client][upgrade] == g_respawn_maxlevels[upgrade] )
  1490. {
  1491. return ITEM_DISABLED;
  1492. }
  1493.  
  1494. return ITEM_ENABLED;
  1495. }
  1496.  
  1497. ShowNoFallMenu(client)
  1498. {
  1499. static title[128];
  1500. formatex(title, sizeof(title) - 1, "[HNS XP by Exolent]^nFall Damage Menu^n^nYour XP: \w%i", g_xp[client]);
  1501. new menu = menu_create(title, "MenuNoFall");
  1502. new callback = menu_makecallback("CallbackNoFall");
  1503.  
  1504. //menu_additem(menu, "\yHelp", "*", _, callback);
  1505.  
  1506. static level, xp, percent, item[128], info[4];
  1507. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1508. {
  1509. if( g_nofall_enabled[i] )
  1510. {
  1511. level = g_nofall_level[client][i] + 1;
  1512. percent = g_nofall_max_chance[i] * level / g_nofall_maxlevels[i];
  1513.  
  1514. if( g_nofall_level[client][i] < g_nofall_maxlevels[i] )
  1515. {
  1516. xp = g_nofall_first_xp[i] * (1 << (level - 1));
  1517. formatex(item, sizeof(item) - 1, "%s: \yLevel %i (%i%%) \r[\w%i XP\r]", g_nofall_names[i], level, percent, xp);
  1518. }
  1519. else
  1520. {
  1521. formatex(item, sizeof(item) - 1, "%s: \yLevel %i (%i%%) \r[\wMaxed Out!\r]", g_nofall_names[i], level, percent);
  1522. }
  1523.  
  1524. num_to_str(_:i, info, sizeof(info) - 1);
  1525.  
  1526. menu_additem(menu, item, info, _, callback);
  1527. }
  1528. }
  1529.  
  1530. menu_display(client, menu);
  1531. }
  1532.  
  1533. public MenuNoFall(client, menu, item)
  1534. {
  1535. if( item == MENU_EXIT )
  1536. {
  1537. menu_destroy(menu);
  1538. ShowMainMenu(client);
  1539. return;
  1540. }
  1541.  
  1542. static _access, info[4], callback;
  1543. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  1544. menu_destroy(menu);
  1545.  
  1546. if( info[0] == '*' )
  1547. {
  1548. static motd[2500];
  1549. new len = formatex(motd, sizeof(motd) - 1, "<body style=^"background-color:#030303; color:#FF8F00^">");
  1550. len += format(motd[len], sizeof(motd) - len - 1, "<p align=^"center^">");
  1551. len += format(motd[len], sizeof(motd) - len - 1, "The Fall Damage ability reduces the amount of damage inflicted from falling.<br>");
  1552. len += format(motd[len], sizeof(motd) - len - 1, "<br>");
  1553. len += format(motd[len], sizeof(motd) - len - 1, "<table>");
  1554. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1555. len += format(motd[len], sizeof(motd) - len - 1, "<th></th>");
  1556. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1557. {
  1558. if( g_nofall_enabled[i] )
  1559. {
  1560. len += format(motd[len], sizeof(motd) - len - 1, "<th>%s</th>",g_team_names[i]);
  1561. }
  1562. }
  1563. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1564. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1565. len += format(motd[len], sizeof(motd) - len - 1, "<th>Reduction Intervals</th>");
  1566. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1567. {
  1568. if( g_nofall_enabled[i] )
  1569. {
  1570. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i%%</td>", (g_nofall_max_chance[i] / g_nofall_maxlevels[i]));
  1571. }
  1572. }
  1573. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1574. len += format(motd[len], sizeof(motd) - len - 1, "<tr>");
  1575. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Level</th>");
  1576. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1577. {
  1578. if( g_nofall_enabled[i] )
  1579. {
  1580. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i</td>", g_nofall_maxlevels[i]);
  1581. }
  1582. }
  1583. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1584. len += format(motd[len], sizeof(motd) - len - 1, "<th>Max Chance</th>");
  1585. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1586. {
  1587. if( g_nofall_enabled[i] )
  1588. {
  1589. len += format(motd[len], sizeof(motd) - len - 1, "<td>%i%%</td>", g_nofall_max_chance[i]);
  1590. }
  1591. }
  1592. len += format(motd[len], sizeof(motd) - len - 1, "</tr>");
  1593. len += format(motd[len], sizeof(motd) - len - 1, "</table>");
  1594. len += format(motd[len], sizeof(motd) - len - 1, "</p>");
  1595. len += format(motd[len], sizeof(motd) - len - 1, "</body>");
  1596.  
  1597. show_motd(client, motd, "XP Fall Damage Info");
  1598. }
  1599. else
  1600. {
  1601. new CsTeams:upgrade = CsTeams:str_to_num(info);
  1602.  
  1603. new level = g_nofall_level[client][upgrade] + 1;
  1604. new xp = g_nofall_first_xp[upgrade] * (1 << (level - 1));
  1605. new percent = g_nofall_max_chance[upgrade] * level / g_nofall_maxlevels[upgrade];
  1606.  
  1607. g_xp[client] -= xp;
  1608. g_nofall_level[client][upgrade] = level;
  1609.  
  1610. Save(client);
  1611.  
  1612. Print(client, "You bought %s Level %i (%i%%) for %i XP!", g_nofall_names[upgrade], level, percent, xp);
  1613. }
  1614.  
  1615. ShowNoFallMenu(client);
  1616. }
  1617.  
  1618. public CallbackNoFall(client, menu, item)
  1619. {
  1620. static _access, info[4], callback;
  1621. menu_item_getinfo(menu, item, _access, info, sizeof(info) - 1, _, _, callback);
  1622.  
  1623. if( info[0] == '*' ) return ITEM_ENABLED;
  1624.  
  1625. new CsTeams:upgrade = CsTeams:str_to_num(info);
  1626. if( g_nofall_level[client][upgrade] == g_nofall_maxlevels[upgrade] )
  1627. {
  1628. return ITEM_DISABLED;
  1629. }
  1630.  
  1631. new xp = g_nofall_first_xp[upgrade] * (1 << g_nofall_level[client][upgrade]);
  1632. if( g_xp[client] < xp || g_nofall_level[client][upgrade] == g_nofall_maxlevels[upgrade] )
  1633. {
  1634. return ITEM_DISABLED;
  1635. }
  1636.  
  1637. return ITEM_ENABLED;
  1638. }
  1639.  
  1640. ShowPlayerMenu(client)
  1641. {
  1642. new menu = menu_create("Player Info Menu", "MenuPlayer");
  1643.  
  1644. new name[32], authid[35];
  1645. for( new i = 1; i <= g_max_clients; i++ )
  1646. {
  1647. if( !is_user_connected(i) ) continue;
  1648.  
  1649. get_user_name(i, name, sizeof(name) - 1);
  1650. get_user_authid(i, authid, sizeof(authid) - 1);
  1651.  
  1652. menu_additem(menu, name, authid);
  1653. }
  1654.  
  1655. menu_display(client, menu);
  1656. }
  1657.  
  1658. public MenuPlayer(client, menu, item)
  1659. {
  1660. if( item == MENU_EXIT )
  1661. {
  1662. menu_destroy(menu);
  1663. ShowMainMenu(client);
  1664. return;
  1665. }
  1666.  
  1667. static _access, authid[35], callback;
  1668. menu_item_getinfo(menu, item, _access, authid, sizeof(authid) - 1, _, _, callback);
  1669. menu_destroy(menu);
  1670.  
  1671. new player = find_player("c", authid);
  1672. if( !is_user_connected(player) )
  1673. {
  1674. ShowMainMenu(client);
  1675. return;
  1676. }
  1677.  
  1678. new name[32];
  1679. get_user_name(player, name, sizeof(name) - 1);
  1680.  
  1681. static motd[2500];
  1682. new len = copy(motd, sizeof(motd) - 1, "<html>");
  1683. len += format(motd[len], sizeof(motd) - len - 1, "<b><font size=^"4^">Name:</font></b> %s<br><br>", name);
  1684. len += format(motd[len], sizeof(motd) - len - 1, "<b><font size=^"4^">XP:</font></b> %i<br><br>", g_xp[player]);
  1685. if( g_any_nade_enabled )
  1686. {
  1687. len += format(motd[len], sizeof(motd) - len - 1, "<b><font size=^"4^">Grenades Levels:</font></b><br>");
  1688. for( new i = 0; i < Grenades; i++ )
  1689. {
  1690. if( g_nade_enabled[i] )
  1691. {
  1692. len += format(motd[len], sizeof(motd) - len - 1, "<b>%s:</b> %i/%i<br>", g_nade_names[i], g_nade_level[player][i], g_nade_maxlevels[i]);
  1693. }
  1694. }
  1695. }
  1696. if( g_any_health_enabled )
  1697. {
  1698. len += format(motd[len], sizeof(motd) - len - 1, "<br><b><font size=^"4^">Health Levels:</font></b><br>");
  1699. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1700. {
  1701. if( g_health_enabled[i] )
  1702. {
  1703. len += format(motd[len], sizeof(motd) - len - 1, "<b>%s:</b> %i/%i (%i/%i HP)<br>",\
  1704. g_health_names[i], g_health_level[player][i], g_health_maxlevels[i],\
  1705. (g_health_maxamount[i] * g_health_level[player][i] / g_health_maxlevels[i]), g_health_maxamount[i]);
  1706. }
  1707. }
  1708. }
  1709. if( g_any_armor_enabled )
  1710. {
  1711. len += format(motd[len], sizeof(motd) - len - 1, "<br><b><font size=^"4^">Armor Levels:</font></b><br>");
  1712. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1713. {
  1714. if( g_armor_enabled[i] )
  1715. {
  1716. len += format(motd[len], sizeof(motd) - len - 1, "<b>%s:</b> %i/%i (%i/%i AP)<br>",\
  1717. g_armor_names[i], g_armor_level[player][i], g_armor_maxlevels[i],\
  1718. (g_armor_maxamount[i] * g_armor_level[player][i] / g_armor_maxlevels[i]), g_armor_maxamount[i]);
  1719. }
  1720. }
  1721. }
  1722. if( g_any_respawn_enabled )
  1723. {
  1724. len += format(motd[len], sizeof(motd) - len - 1, "<br><b><font size=^"4^">Respawn Levels:</font></b><br>");
  1725. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1726. {
  1727. if( g_respawn_enabled[i] )
  1728. {
  1729. len += format(motd[len], sizeof(motd) - len - 1, "<b>%s:</b> %i/%i (%i/%i %%)<br>",\
  1730. g_respawn_names[i], g_respawn_level[player][i], g_respawn_maxlevels[i],\
  1731. (g_respawn_max_chance[i] * g_respawn_level[player][i] / g_respawn_maxlevels[i]), g_respawn_max_chance[i]);
  1732. }
  1733. }
  1734. }
  1735. if( g_any_nofall_enabled )
  1736. {
  1737. len += format(motd[len], sizeof(motd) - len - 1, "<br><b><font size=^"4^">Fall Damage Levels:</font></b><br>");
  1738. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1739. {
  1740. if( g_nofall_enabled[i] )
  1741. {
  1742. len += format(motd[len], sizeof(motd) - len - 1, "<b>%s:</b> %i/%i (%i/%i %%)<br>",\
  1743. g_nofall_names[i], g_nofall_level[player][i], g_nofall_maxlevels[i],\
  1744. (g_nofall_max_chance[i] * g_nofall_level[player][i] / g_nofall_maxlevels[i]), g_nofall_max_chance[i]);
  1745. }
  1746. }
  1747. }
  1748. len += format(motd[len], sizeof(motd) - len - 1, "</html>");
  1749.  
  1750. show_motd(client, motd, "HNS XP Mod Info");
  1751.  
  1752. ShowPlayerMenu(client);
  1753. }
  1754.  
  1755. IsValidAuthid(authid[])
  1756. {
  1757. return (regex_match_c(authid, g_SteamID_pattern, g_regex_return) > 0);
  1758. }
  1759.  
  1760. IsUserAuthorized(client)
  1761. {
  1762. return g_authid[client][0] != 0;
  1763. }
  1764.  
  1765. Print(client, const msg_fmt[], any:...)
  1766. {
  1767. static message[192];
  1768. new len = formatex(message, sizeof(message) - 1, "%s^x03", MESSAGE_TAG);
  1769. vformat(message[len], sizeof(message) - len - 1, msg_fmt, 3);
  1770.  
  1771. if( client )
  1772. {
  1773. message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, client);
  1774. write_byte(client);
  1775. write_string(message);
  1776. message_end();
  1777. }
  1778. else
  1779. {
  1780. for( new i = g_first_client; i <= g_max_clients; i++ )
  1781. {
  1782. if( is_user_connected(i) )
  1783. {
  1784. message_begin(MSG_ONE_UNRELIABLE, g_msgid_SayText, _, i);
  1785. write_byte(i);
  1786. write_string(message);
  1787. message_end();
  1788. }
  1789. }
  1790. }
  1791. }
  1792.  
  1793. Load(client)
  1794. {
  1795. #if defined USING_SQL
  1796. static query[128];
  1797. formatex(query, sizeof(query) - 1, "SELECT `data` FROM `hns_xp` WHERE `authid` = '%s';", g_authid[client]);
  1798.  
  1799. static data[2];
  1800. data[0] = client;
  1801.  
  1802. SQL_ThreadQuery(g_sql_tuple, "QueryLoadData", query, data, sizeof(data));
  1803. #else
  1804. static data[256], timestamp;
  1805. if( nvault_lookup(g_vault, g_authid[client], data, sizeof(data) - 1, timestamp) )
  1806. {
  1807. ParseLoadData(client, data);
  1808. return;
  1809. }
  1810. else
  1811. {
  1812. NewUser(client);
  1813. }
  1814. #endif
  1815. }
  1816.  
  1817. #if defined USING_SQL
  1818. public QueryLoadData(failstate, Handle:query, error[], errnum, data[], size, Float:queuetime)
  1819. {
  1820. if( failstate == TQUERY_CONNECT_FAILED
  1821. || failstate == TQUERY_QUERY_FAILED )
  1822. {
  1823. set_fail_state(error);
  1824. }
  1825. else
  1826. {
  1827. if( SQL_NumResults(query) )
  1828. {
  1829. static sqldata[256];
  1830. SQL_ReadResult(query, 0, sqldata, sizeof(sqldata) - 1);
  1831. ParseLoadData(data[0], sqldata);
  1832. }
  1833. else
  1834. {
  1835. NewUser(data[0]);
  1836. }
  1837. }
  1838. }
  1839. #endif
  1840.  
  1841. ParseLoadData(client, data[256])
  1842. {
  1843. static num[6];
  1844. strbreak(data, num, sizeof(num) - 1, data, sizeof(data) - 1);
  1845.  
  1846. g_xp[client] = str_to_num(num);
  1847.  
  1848. for( new i = 0; i < Grenades; i++ )
  1849. {
  1850. strbreak(data, num, sizeof(num) - 1, data, sizeof(data) - 1);
  1851. g_nade_level[client][i] = clamp(str_to_num(num), 0, g_nade_maxlevels[i]);
  1852. }
  1853.  
  1854. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1855. {
  1856. strbreak(data, num, sizeof(num) - 1, data, sizeof(data) - 1);
  1857. g_armor_level[client][i] = clamp(str_to_num(num), 0, g_armor_maxlevels[i]);
  1858. }
  1859.  
  1860. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1861. {
  1862. strbreak(data, num, sizeof(num) - 1, data, sizeof(data) - 1);
  1863. g_respawn_level[client][i] = clamp(str_to_num(num), 0, g_respawn_maxlevels[i]);
  1864. }
  1865.  
  1866. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1867. {
  1868. strbreak(data, num, sizeof(num) - 1, data, sizeof(data) - 1);
  1869. g_health_level[client][i] = clamp(str_to_num(num), 0, g_health_maxlevels[i]);
  1870. }
  1871.  
  1872. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1873. {
  1874. strbreak(data, num, sizeof(num) - 1, data, sizeof(data) - 1);
  1875. g_nofall_level[client][i] = clamp(str_to_num(num), 0, g_nofall_maxlevels[i]);
  1876. }
  1877.  
  1878. #if defined USING_SQL
  1879. g_loaded_data[client] = 1;
  1880. #endif
  1881. }
  1882.  
  1883. NewUser(client)
  1884. {
  1885. g_first_time[client] = 1;
  1886.  
  1887. g_xp[client] = ENTRY_XP;
  1888. arrayset(g_nade_level[client], 0, sizeof(g_nade_level[]));
  1889. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1890. {
  1891. g_armor_level[client][i] = 0;
  1892. g_respawn_level[client][i] = 0;
  1893. g_health_level[client][i] = 0;
  1894. g_nofall_level[client][i] = 0;
  1895. }
  1896. }
  1897.  
  1898. Save(client)
  1899. {
  1900. if( !IsUserAuthorized(client) ) return;
  1901.  
  1902. static data[256];
  1903. new len = formatex(data, sizeof(data) - 1, "%i", g_xp[client]);
  1904.  
  1905. for( new i = 0; i < Grenades; i++ )
  1906. {
  1907. len += formatex(data[len], sizeof(data) - len - 1, " %i", g_nade_level[client][i]);
  1908. }
  1909.  
  1910. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1911. {
  1912. len += formatex(data[len], sizeof(data) - len - 1, " %i", g_armor_level[client][i]);
  1913. }
  1914.  
  1915. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1916. {
  1917. len += formatex(data[len], sizeof(data) - len - 1, " %i", g_respawn_level[client][i]);
  1918. }
  1919.  
  1920. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1921. {
  1922. len += formatex(data[len], sizeof(data) - len - 1, " %i", g_health_level[client][i]);
  1923. }
  1924.  
  1925. for( new CsTeams:i = CS_TEAM_T; i <= CS_TEAM_CT; i++ )
  1926. {
  1927. len += formatex(data[len], sizeof(data) - len - 1, " %i", g_nofall_level[client][i]);
  1928. }
  1929.  
  1930. #if defined USING_SQL
  1931. static name[32];
  1932. get_user_name(client, name, sizeof(name) - 1);
  1933.  
  1934. static query[512];
  1935. if( g_loaded_data[client] )
  1936. {
  1937. formatex(query, sizeof(query) - 1, "UPDATE `hns_xp` SET `name` = '%s', `data` = '%s' WHERE `authid` = '%s';", name, data, g_authid[client]);
  1938. }
  1939. else
  1940. {
  1941. formatex(query, sizeof(query) - 1, "INSERT INTO `hns_xp` ( `name`, `authid`, `data` ) VALUES ( '%s', '%s', '%s' );", name, g_authid[client], data);
  1942. }
  1943.  
  1944. SQL_ThreadQuery(g_sql_tuple, "QuerySaveData", query);
  1945. #else
  1946. nvault_set(g_vault, g_authid[client], data);
  1947. #endif
  1948. }
  1949.  
  1950. #if defined USING_SQL
  1951. public QuerySaveData(failstate, Handle:query, error[], errnum, data[], size, Float:queuetime)
  1952. {
  1953. if( failstate == TQUERY_CONNECT_FAILED
  1954. || failstate == TQUERY_QUERY_FAILED )
  1955. {
  1956. set_fail_state(error);
  1957. }
  1958. }
  1959. #endif
  1960. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  1961. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang11274\\ f0\\ fs16 \n\\ par }
  1962. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement