Advertisement
Guest User

Untitled

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