Advertisement
v0VExxx

PM xd

Dec 4th, 2012
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.81 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fun>
  3. #include <nvault_util>
  4. #include <cstrike>
  5. #include <engine>
  6. #include <fakemeta>
  7. #include <hamsandwich>
  8. #include <dhudmessage>
  9.  
  10. #pragma semicolon 1
  11.  
  12. #define PLUGIN_VERSION "0.2.2"
  13. #define IsPlayer(%1) (1 <= %1 <= g_iMaxPlayers)
  14. #define MAXPLAYERS 32
  15.  
  16. native pm_get_user_maxhealth(id);
  17. native give_vipaccess(id);
  18. native take_vipaccess(id);
  19.  
  20. enum (+= 1631)
  21. {
  22. TASK_RESPAWN = 5616,
  23. TASK_GIVEITEMS
  24. };
  25.  
  26. enum _:UPGRADES
  27. {
  28. Health,
  29. Armor,
  30. Respawn,
  31. FallDamage,
  32. Damage,
  33. NoPainShock
  34. };
  35.  
  36. enum _:ITEMINFO
  37. {
  38. Name[20],
  39. Levels,
  40. MaxValue,
  41. Prefix[5]
  42. };
  43.  
  44. new const ItemInfo[UPGRADES][ITEMINFO] =
  45. {
  46. { "Extra Health", 5, 100, " HP" },
  47. { "Armor", 5, 100, " AP" },
  48. { "Respawn Chance", 5, 10, "%" },
  49. { "Fall Damage Reducer", 5, 15, "%" },
  50. { "Extra Damage", 5, 10, "%" },
  51. { "No Pain Shock", 1, 1, "" }
  52. };
  53.  
  54. new const g_iItemPrice[UPGRADES][] =
  55. {
  56. { 60, 70, 80, 90, 100 },
  57. { 60, 70, 80, 90, 100 },
  58. { 150, 160, 170, 180, 200 },
  59. { 70, 80, 90, 100, 110 },
  60. { 125, 125, 125, 125, 125 },
  61. { 750 }
  62. };
  63.  
  64. new g_iItemLevel[MAXPLAYERS + 1][UPGRADES][CsTeams];
  65. new g_iPoints[MAXPLAYERS + 1];
  66. new g_iPointsTotal[MAXPLAYERS + 1];
  67. new g_iTarget[MAXPLAYERS + 1];
  68.  
  69. new g_iMaxPlayers;
  70. new g_iVault;
  71. new g_iVault_Name;
  72.  
  73. new bool:g_bAlive[MAXPLAYERS + 1];
  74. new bool:g_bRespawned[MAXPLAYERS + 1];
  75. new bool:g_bUsedRank[MAXPLAYERS + 1];
  76.  
  77. const TOPRANKS = 10;
  78. new g_szTopNames[TOPRANKS + 1][32];
  79. new g_iTopPoints[TOPRANKS + 1];
  80. new g_iTopAuth[TOPRANKS + 1][35];
  81. new g_iTopThree[3][35];
  82.  
  83. enum _:PCVARS
  84. {
  85. KILLXP,
  86. SURVIVE,
  87. SUICIDE,
  88. PLAYERREQ,
  89. KILLED
  90. };
  91.  
  92. new g_pCvar[PCVARS];
  93. new c_Survive;
  94.  
  95. new FirstClient;
  96. new MaxClients;
  97.  
  98. new const g_szMenuCommands[][] =
  99. {
  100. "/pm",
  101. "/point"
  102. };
  103.  
  104. public plugin_init()
  105. {
  106. register_plugin("HNS PointMod", PLUGIN_VERSION, "Biffmeizter");
  107.  
  108. register_event("DeathMsg", "eventDeath", "a");
  109. register_event("HLTV", "eventNewRound", "a", "1=0", "2=0");
  110.  
  111. register_logevent("eventRoundEnd", 2, "1=Round_End");
  112.  
  113. new szFunction[] = "TeamMenu", szCommand[24];
  114. for( new i = 0; i < sizeof(g_szMenuCommands); i++ )
  115. {
  116. formatex(szCommand, charsmax(szCommand), "say %s", g_szMenuCommands[i]);
  117. register_clcmd(szCommand, szFunction);
  118.  
  119. formatex(szCommand, charsmax(szCommand), "say_team %s", g_szMenuCommands[i]);
  120. register_clcmd(szCommand, szFunction);
  121. }
  122.  
  123. register_clcmd("say /rank", "CmdHideRank");
  124. register_clcmd("say_team /rank", "CmdHideRank");
  125. register_clcmd("say /top", "CmdMOTDTop");
  126. register_clcmd("say_team /top", "CmdMOTDTop");
  127. register_clcmd("say /top10", "CmdMOTDTop");
  128. register_clcmd("say_team /top10", "CmdMOTDTop");
  129. register_clcmd("say /top15", "CmdMOTDTop");
  130. register_clcmd("say_team /top15", "CmdMOTDTop");
  131.  
  132. register_clcmd("_________DonatePointValue", "CmdDonatePoints");
  133.  
  134. register_concmd("pm_give", "CmdGive", ADMIN_IMMUNITY, "<Nick, #Userid, Auth> <Points>");
  135. register_concmd("pm_remove", "CmdTake", ADMIN_IMMUNITY, "<Nick, #Userid, Auth> <Points>");
  136. register_concmd("pm_resetperson", "CmdResetPerson", ADMIN_IMMUNITY, "<Nick, #Userid, Auth>");
  137. register_concmd("pm_reset", "CmdReset");
  138.  
  139. g_pCvar[KILLXP] = register_cvar("hnspm_killpoints", "2");
  140. g_pCvar[SURVIVE] = register_cvar("hnspm_survivepoints", "5");
  141. g_pCvar[SUICIDE] = register_cvar("hnspm_suicidepoints", "2");
  142. g_pCvar[KILLED] = register_cvar("hnspm_killedpoints", "1");
  143. g_pCvar[PLAYERREQ] = register_cvar("hnspm_minplayers", "4");
  144.  
  145. c_Survive = register_cvar ( "pm_points_survive", "5" );
  146.  
  147. g_iMaxPlayers = get_maxplayers();
  148.  
  149. FirstClient = 1;
  150. MaxClients = get_maxplayers();
  151.  
  152. g_iVault = nvault_open("HNSPointModNew");
  153. g_iVault_Name = nvault_open("HNSPointMod_NamesNew");
  154.  
  155. register_forward(FM_Think, "FwdThink", false);
  156.  
  157. register_think("entTask", "CmdUpdatePoints");
  158.  
  159. RegisterHam(Ham_TakeDamage, "player", "FwdPlayerTakeDamage");
  160. RegisterHam(Ham_TakeDamage, "player", "FwdPlayerTakeDamage_Post", true);
  161. RegisterHam(Ham_Killed, "player", "FwdPlayerKilled");
  162. RegisterHam(Ham_Spawn, "player", "FwdPlayerSpawn_Post", true);
  163.  
  164. CreateTopTen(); // Load Top
  165. }
  166.  
  167. public plugin_natives()
  168. {
  169. register_native("pm_set_user_points", "_set_user_points");
  170. register_native("pm_get_user_points", "_get_user_points");
  171. register_native("pm_get_user_maxhealth", "_get_user_maxhealth");
  172. register_native("pm_add_user_points", "_add_user_points");
  173. register_native("pm_get_user_totalpoints", "_get_user_totalpoints");
  174. }
  175.  
  176. public _get_user_points(id)
  177. {
  178. id = get_param(1);
  179. return g_iPoints[id];
  180. }
  181.  
  182. public _get_user_totalpoints(id)
  183. {
  184. id = get_param(1);
  185. return g_iPointsTotal[id];
  186. }
  187.  
  188. public _set_user_points(id, iPoints)
  189. {
  190. id = get_param(1);
  191. iPoints = get_param(2);
  192. g_iPoints[id] = iPoints;
  193. g_iPointsTotal[id] = iPoints;
  194. SaveData(id);
  195. }
  196.  
  197. public _add_user_points(id, iPoints)
  198. {
  199. id = get_param(1);
  200. iPoints = get_param(2);
  201. g_iPoints[id] += iPoints;
  202. g_iPointsTotal[id] += iPoints;
  203. SaveData(id);
  204. }
  205.  
  206. public _get_user_maxhealth(id)
  207. {
  208. new id = get_param(1);
  209. new iHealth;
  210.  
  211. if( IsPlayer(id) )
  212. {
  213. new CsTeams:iTeam;
  214. iTeam = cs_get_user_team(id);
  215. iHealth = (100 + (ItemInfo[Health][MaxValue] / ItemInfo[Health][Levels] * g_iItemLevel[id][Health][iTeam]));
  216. }
  217.  
  218. return iHealth;
  219. }
  220.  
  221. public eventRoundEnd()
  222. {
  223. if( get_playersnum() < get_pcvar_num(g_pCvar[PLAYERREQ]) )
  224. {
  225. return PLUGIN_HANDLED;
  226. }
  227.  
  228. new survive = get_pcvar_num( c_Survive );
  229. for( new iPlayer = FirstClient; iPlayer <= MaxClients; iPlayer++ )
  230. {
  231. if( is_user_alive(iPlayer) && cs_get_user_team(iPlayer) == CS_TEAM_T )
  232. {
  233. g_iPoints[iPlayer] += survive;
  234. g_iPointsTotal[iPlayer] += survive;
  235.  
  236. Print(iPlayer, "^3You gained^4 %i Points^3 for^4 surviving the round!", survive);
  237.  
  238. set_hudmessage(0, 126, 255, 0.70, 0.84, 0, 6.0, 5.0, 0.25, 0.25, 2);
  239. show_hudmessage(iPlayer, "You got %i points for surviving the round!", survive);
  240. }
  241. }
  242.  
  243. return PLUGIN_HANDLED;
  244. }
  245.  
  246. public client_connect(id)
  247. {
  248. if( IsPlayer(id) )
  249. {
  250. LoadData(id);
  251.  
  252. new szAuth[35];
  253. get_user_authid(id, szAuth, charsmax(szAuth));
  254.  
  255. if( equal(szAuth, g_iTopThree[0]) || equal(szAuth, g_iTopThree[1]) || equal(szAuth, g_iTopThree[2]) )
  256. {
  257. give_vipaccess(id);
  258. }
  259. else
  260. {
  261. take_vipaccess(id);
  262. }
  263. }
  264. }
  265.  
  266. public client_disconnect(id)
  267. {
  268. if( IsPlayer(id) )
  269. {
  270. SaveData(id);
  271. }
  272. }
  273.  
  274. public eventNewRound()
  275. {
  276. new iEnt = -1;
  277. while( (iEnt = find_ent_by_class(iEnt, "entTask")) )
  278. {
  279. remove_entity(iEnt);
  280. }
  281.  
  282. iEnt = create_entity("info_target");
  283. if( iEnt )
  284. {
  285. entity_set_string(iEnt, EV_SZ_classname, "entTask");
  286. entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 0.5);
  287. }
  288. }
  289.  
  290. public eventDeath()
  291. {
  292. if( get_playersnum() < get_pcvar_num(g_pCvar[PLAYERREQ]) )
  293. {
  294. return PLUGIN_HANDLED;
  295. }
  296.  
  297. new iKiller = read_data(1);
  298. new iVictim = read_data(2);
  299. new iHS = read_data(3);
  300.  
  301. new CsTeams:iTeam;
  302. if( IsPlayer(iKiller) )
  303. {
  304. iTeam = cs_get_user_team(iKiller);
  305. }
  306.  
  307. if( IsPlayer(iKiller) && IsPlayer(iVictim) )
  308. {
  309. if( iTeam != cs_get_user_team(iVictim) )
  310. {
  311. new iKillPoints;
  312. if( !iHS )
  313. {
  314. iKillPoints = get_pcvar_num(g_pCvar[KILLXP]);
  315. }
  316. else
  317. {
  318. iKillPoints = (get_pcvar_num(g_pCvar[KILLXP]) + 2);
  319. }
  320.  
  321. g_iPoints[iKiller] += iKillPoints;
  322. g_iPointsTotal[iKiller] += iKillPoints;
  323.  
  324. new szName[32];
  325. get_user_name(iVictim, szName, charsmax(szName));
  326. Print(iKiller, "You gained^x04 %i Point%s^x03 for killing^x01 %s^x03%s !", iKillPoints, iKillPoints > 1 ? "s" : "", szName, iHS ? " with a^x01 Headshot^x03" : "");
  327.  
  328. set_hudmessage(0, 126, 255, 0.70, 0.84, 0, 6.0, 5.0, 0.25, 0.25, 2);
  329. show_hudmessage(iKiller, "You got %i points for making a kill!", iKillPoints);
  330.  
  331. new iKilled = get_pcvar_num(g_pCvar[KILLED]);
  332.  
  333. g_iPoints[iVictim] -= iKilled;
  334. g_iPointsTotal[iKiller] -= iKilled;
  335.  
  336. Print(iVictim, "You lost^x04 %i Point%s^x03 for getting killed !", iKilled, iKilled > 1 ? "s" : "");
  337.  
  338. set_hudmessage(228, 0, 0, 0.70, 0.84, 0, 6.0, 5.0, 0.25, 0.25, 2);
  339. show_hudmessage(iVictim, "You lost %i points for getting killed!", iKilled);
  340. }
  341. }
  342.  
  343. if( iKiller == iVictim )
  344. {
  345. if( iTeam == CS_TEAM_T )
  346. {
  347. new iPoints = get_pcvar_num(g_pCvar[SUICIDE]);
  348. g_iPoints[iKiller] -= iPoints;
  349. g_iPointsTotal[iKiller] -= iPoints;
  350. Print(iKiller, "You lost^x04 %i Point%s^x03 for suiciding !", iPoints, iPoints > 1 ? "s" : "");
  351.  
  352. set_hudmessage(228, 0, 0, 0.70, 0.84, 0, 6.0, 5.0, 0.25, 0.25, 2);
  353. show_hudmessage(iVictim, "You lost %i points for making a suicide!", iPoints);
  354. }
  355. }
  356.  
  357. if( g_iPoints[iVictim] < 0 )
  358. {
  359. g_iPoints[iVictim] = 0;
  360. }
  361.  
  362. if( g_iPointsTotal[iVictim] < 0 )
  363. {
  364. g_iPointsTotal[iVictim] = 0;
  365. }
  366.  
  367. g_bAlive[iVictim] = false;
  368.  
  369. SaveData(iKiller);
  370. SaveData(iVictim);
  371.  
  372. return PLUGIN_HANDLED;
  373. }
  374.  
  375. public TeamMenu(id)
  376. {
  377. new szTitle[128];
  378. formatex(szTitle, charsmax(szTitle), "\r[PM] \wPointMod by \ybiffmeizter^n\y- Main Menu");
  379. new iMenu = menu_create(szTitle, "handleTeamMenu", 0);
  380.  
  381. new szPoints[20];
  382. formatex(szPoints, charsmax(szPoints), "Points: \r%i", g_iPoints[id]);
  383. menu_additem(iMenu, "\yTotal Top", "1");
  384. menu_additem(iMenu, "Player Info", "2");
  385. menu_addblank(iMenu, 0);
  386. menu_additem(iMenu, "Terrorist Shop", "3");
  387. menu_additem(iMenu, "Counter-Terrorist Shop", "4");
  388. menu_addblank(iMenu, 0);
  389. menu_additem(iMenu, "Donate Points", "5");
  390. menu_addblank(iMenu);
  391. menu_addtext(iMenu, szPoints, 0);
  392. menu_addblank(iMenu);
  393.  
  394. menu_setprop(iMenu, MPROP_EXITNAME, "Close");
  395. menu_display(id, iMenu);
  396.  
  397. return PLUGIN_HANDLED;
  398. }
  399.  
  400. public handleTeamMenu(id, iMenu, iItem)
  401. {
  402. if( iItem == MENU_EXIT )
  403. {
  404. menu_destroy(iMenu);
  405. return PLUGIN_HANDLED;
  406. }
  407.  
  408. new iAccess, iCallback;
  409. new szData[3];
  410. menu_item_getinfo(iMenu, iItem, iAccess, szData, charsmax(szData), _, _, iCallback);
  411.  
  412. new iKey = str_to_num(szData);
  413. switch( iKey )
  414. {
  415. case 1:
  416. {
  417. CmdMOTDTop(id);
  418. TeamMenu(id);
  419. }
  420. case 2: CmdPlayerInfo(id);
  421. case 3: MainMenu(id, CS_TEAM_T);
  422. case 4: MainMenu(id, CS_TEAM_CT);
  423. case 5: DonateMenu(id);
  424. }
  425.  
  426. return PLUGIN_HANDLED;
  427. }
  428.  
  429. public MainMenu(id, CsTeams:TYPE)
  430. {
  431. new szTitle[128];
  432. formatex(szTitle, charsmax(szTitle), "\r[PM] \wPointMod by \ybiffmeizter^n\y- %sTerrorist Shop\r", TYPE == CS_TEAM_T ? "" : "Counter-");
  433. new iMenu;
  434.  
  435. new iCallback;
  436. if( TYPE == CS_TEAM_T )
  437. {
  438. iCallback = menu_makecallback("callbackMainMenu_T");
  439. iMenu = menu_create(szTitle, "handleMainMenu_T", 0);
  440. }
  441. else
  442. {
  443. iCallback = menu_makecallback("callbackMainMenu_CT");
  444. iMenu = menu_create(szTitle, "handleMainMenu_CT", 0);
  445. }
  446.  
  447. static szItem[128], iValue, iPrice;
  448.  
  449. new iKey[3];
  450. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  451. {
  452. num_to_str(iItem, iKey, charsmax(iKey));
  453. iValue = (ItemInfo[iItem][MaxValue] / ItemInfo[iItem][Levels] * (g_iItemLevel[id][iItem][TYPE] + 1));
  454. iPrice = g_iItemPrice[iItem][g_iItemLevel[id][iItem][TYPE]];
  455.  
  456. if( g_iItemLevel[id][iItem][TYPE] >= ItemInfo[iItem][Levels] )
  457. {
  458. switch( iItem )
  459. {
  460. case NoPainShock: formatex(szItem, charsmax(szItem), "\d%s: \yYes!", ItemInfo[iItem][Name]);
  461. default: formatex(szItem, charsmax(szItem), "\d%s: \wMax Level! \r(\w%s%i%s\r)", ItemInfo[iItem][Name], iItem == Damage ? "+" : "", ItemInfo[iItem][MaxValue], ItemInfo[iItem][Prefix]);
  462. }
  463. }
  464. else if( g_iPoints[id] < iPrice )
  465. {
  466. switch( iItem )
  467. {
  468. case NoPainShock: formatex(szItem, charsmax(szItem), "\d%s: \y%i Points", ItemInfo[iItem][Name], iPrice);
  469. default: formatex(szItem, charsmax(szItem), "\d%s: \wLevel %i \r(\w%s%i%s\r) \y%i Points", ItemInfo[iItem][Name], g_iItemLevel[id][iItem][TYPE] + 1, iItem == Damage ? "+" : "", iValue, ItemInfo[iItem][Prefix], iPrice);
  470. }
  471. }
  472. else
  473. {
  474. switch( iItem )
  475. {
  476. case NoPainShock: formatex(szItem, charsmax(szItem), "\w%s: \y%i Points", ItemInfo[iItem][Name], iPrice);
  477. default: formatex(szItem, charsmax(szItem), "\w%s: Level %i \r(\w%s%i%s\r) \y%i Points", ItemInfo[iItem][Name], g_iItemLevel[id][iItem][TYPE] + 1, iItem == Damage ? "+" : "", iValue, ItemInfo[iItem][Prefix], iPrice);
  478. }
  479. }
  480.  
  481. menu_additem(iMenu, szItem, iKey, _, iCallback);
  482. }
  483.  
  484. menu_setprop(iMenu, MPROP_EXITNAME, "Back");
  485. menu_display(id, iMenu);
  486. }
  487.  
  488. public callbackMainMenu_T(id, iMenu, iItem)
  489. {
  490. new iAccess, iCallback;
  491. new szData[3];
  492. menu_item_getinfo(iMenu, iItem, iAccess, szData, charsmax(szData), _, _, iCallback);
  493.  
  494. new iItem = str_to_num(szData);
  495.  
  496. if( g_iItemLevel[id][iItem][CS_TEAM_T] >= ItemInfo[iItem][Levels] )
  497. {
  498. return ITEM_DISABLED;
  499. }
  500. else if( g_iPoints[id] < g_iItemPrice[iItem][g_iItemLevel[id][iItem][CS_TEAM_T]] )
  501. {
  502. return ITEM_DISABLED;
  503. }
  504.  
  505. return ITEM_ENABLED;
  506. }
  507.  
  508. public callbackMainMenu_CT(id, iMenu, iItem)
  509. {
  510. new iAccess, iCallback;
  511. new szData[3];
  512. menu_item_getinfo(iMenu, iItem, iAccess, szData, charsmax(szData), _, _, iCallback);
  513.  
  514. new iItem = str_to_num(szData);
  515.  
  516. if( g_iItemLevel[id][iItem][CS_TEAM_CT] >= ItemInfo[iItem][Levels] )
  517. {
  518. return ITEM_DISABLED;
  519. }
  520. else if( g_iPoints[id] < g_iItemPrice[iItem][g_iItemLevel[id][iItem][CS_TEAM_CT]] )
  521. {
  522. return ITEM_DISABLED;
  523. }
  524.  
  525. return ITEM_ENABLED;
  526. }
  527.  
  528. public handleMainMenu_T(id, iMenu, iItem)
  529. {
  530. if( iItem == MENU_EXIT )
  531. {
  532. menu_destroy(iMenu);
  533. TeamMenu(id);
  534. return PLUGIN_HANDLED;
  535. }
  536.  
  537. new iAccess, iCallback;
  538. new szData[3];
  539. menu_item_getinfo(iMenu, iItem, iAccess, szData, charsmax(szData), _, _, iCallback);
  540.  
  541. new iItem = str_to_num(szData);
  542.  
  543. new iPrice = g_iItemPrice[iItem][g_iItemLevel[id][iItem][CS_TEAM_T]];
  544.  
  545. g_iPoints[id] -= iPrice;
  546. g_iItemLevel[id][iItem][CS_TEAM_T]++;
  547.  
  548. Print(id, "You bought^x01 %s Level: %i^x03 !", ItemInfo[iItem][Name], g_iItemLevel[id][iItem][CS_TEAM_T]);
  549. MainMenu(id, CS_TEAM_T);
  550.  
  551. SaveData(id);
  552.  
  553. return PLUGIN_HANDLED;
  554. }
  555.  
  556. public handleMainMenu_CT(id, iMenu, iItem)
  557. {
  558. if( iItem == MENU_EXIT )
  559. {
  560. menu_destroy(iMenu);
  561. TeamMenu(id);
  562. return PLUGIN_HANDLED;
  563. }
  564.  
  565. new iAccess, iCallback;
  566. new szData[3];
  567. menu_item_getinfo(iMenu, iItem, iAccess, szData, charsmax(szData), _, _, iCallback);
  568.  
  569. new iItem = str_to_num(szData);
  570.  
  571. new iPrice = g_iItemPrice[iItem][g_iItemLevel[id][iItem][CS_TEAM_CT]];
  572.  
  573. g_iPoints[id] -= iPrice;
  574. g_iItemLevel[id][iItem][CS_TEAM_CT]++;
  575.  
  576. Print(id, "You bought^x01 %s Level: %i^x03 !", ItemInfo[iItem][Name], g_iItemLevel[id][iItem][CS_TEAM_CT]);
  577. MainMenu(id, CS_TEAM_CT);
  578.  
  579. SaveData(id);
  580.  
  581. return PLUGIN_HANDLED;
  582. }
  583.  
  584. public DonateMenu(id)
  585. {
  586. new iMenu = menu_create("\r[PM] \wPointMod by \ybiffmeizter^n\y- Donate Menu\r", "handleDonateMenu");
  587.  
  588. new iPlayers[32], szName[32], szKey[3], iNum, iPlayer;
  589. get_players(iPlayers, iNum);
  590.  
  591. for( new i; i < iNum; i++ )
  592. {
  593. iPlayer = iPlayers[i];
  594.  
  595. num_to_str(iPlayer, szKey, charsmax(szKey));
  596. get_user_name(iPlayer, szName, charsmax(szName));
  597.  
  598. menu_additem(iMenu, szName, szKey);
  599. }
  600.  
  601. menu_setprop(iMenu, MPROP_EXITNAME, "Back");
  602. menu_display(id, iMenu, 0);
  603. }
  604.  
  605. public handleDonateMenu(id, iMenu, iItem)
  606. {
  607. if( iItem == MENU_EXIT )
  608. {
  609. menu_destroy(iMenu);
  610. TeamMenu(id);
  611. return PLUGIN_HANDLED;
  612. }
  613.  
  614. new szData[6], iAccess, iCallback;
  615. menu_item_getinfo(iMenu, iItem, iAccess, szData, charsmax(szData), _, _, iCallback);
  616.  
  617. g_iTarget[id] = str_to_num(szData);
  618. new szName[32];
  619. get_user_name(g_iTarget[id], szName, charsmax(szName));
  620.  
  621. Print(id, "You choosed:^x01 %s^x03 !", szName);
  622.  
  623. Print(id, "Type the amount of Points:");
  624. client_cmd(id, "messagemode _________DonatePointValue");
  625. client_cmd(id, "spk fvox/blip");
  626. return PLUGIN_HANDLED;
  627. }
  628.  
  629. public CmdDonatePoints(id)
  630. {
  631. new szArg[5];
  632. read_argv(1, szArg, charsmax(szArg));
  633.  
  634. if( !strlen(szArg) )
  635. {
  636. Print(id, "You need to type a value !");
  637. client_cmd(id, "messagemode _________DonatePointValue");
  638. client_cmd(id, "spk fvox/blip");
  639. return PLUGIN_HANDLED;
  640. }
  641.  
  642. new iValue = str_to_num(szArg);
  643.  
  644. if( iValue <= 0 )
  645. {
  646. Print(id, "You need to type a value over 0 !");
  647. client_cmd(id, "messagemode _________DonatePointValue");
  648. client_cmd(id, "spk fvox/blip");
  649. return PLUGIN_HANDLED;
  650. }
  651. else if( iValue > g_iPoints[id] )
  652. {
  653. Print(id, "You only have^x01 %i Points^x03 !", g_iPoints[id]);
  654. client_cmd(id, "messagemode _________DonatePointValue");
  655. client_cmd(id, "spk fvox/blip");
  656. return PLUGIN_HANDLED;
  657. }
  658.  
  659. new iTarget = g_iTarget[id];
  660.  
  661. if( !iTarget )
  662. {
  663. Print(id, "Invalid Target !");
  664. return PLUGIN_HANDLED;
  665. }
  666.  
  667. if( iTarget == id )
  668. {
  669. Print(id, "You can't give points to yourself!");
  670. return PLUGIN_HANDLED;
  671. }
  672.  
  673. g_iPoints[id] -= iValue;
  674. g_iPointsTotal[id] -= iValue;
  675.  
  676. g_iPoints[iTarget] += iValue;
  677. g_iPointsTotal[iTarget] += iValue;
  678.  
  679. new szName[2][32];
  680. get_user_name(iTarget, szName[0], charsmax(szName[]));
  681. get_user_name(id, szName[1], charsmax(szName[]));
  682.  
  683. Print(id, "You donated^x01 %i Points^x03 to^x01 %s !", iValue, szName[0]);
  684. Print(iTarget, "^x01%s^x03 donated^x01 %i Points^x03 to you !", szName[1], iValue);
  685.  
  686. log_amx("Pointmod Donate Info: %s donated %i points to %s", szName[1], iValue, szName[0]);
  687.  
  688. return PLUGIN_HANDLED;
  689. }
  690.  
  691. public GivePlayerItems(id)
  692. {
  693. id -= TASK_GIVEITEMS;
  694. if( !g_bAlive[id] || !IsPlayer(id) )
  695. {
  696. return PLUGIN_CONTINUE;
  697. }
  698.  
  699. new iValue = pm_get_user_maxhealth(id);
  700. if( iValue > 100 )
  701. {
  702. set_user_health(id, iValue);
  703. }
  704.  
  705. iValue = ItemInfo[Armor][MaxValue] / ItemInfo[Armor][Levels] * g_iItemLevel[id][Armor][cs_get_user_team(id)];
  706. if( iValue == 0 )
  707. {
  708. cs_set_user_armor(id, iValue, CS_ARMOR_NONE);
  709. }
  710. else if( iValue < 100 )
  711. {
  712. cs_set_user_armor(id, iValue, CS_ARMOR_KEVLAR);
  713. }
  714. else
  715. {
  716. cs_set_user_armor(id, iValue, CS_ARMOR_VESTHELM);
  717. }
  718.  
  719. return PLUGIN_HANDLED;
  720. }
  721.  
  722. public FwdPlayerKilled(id)
  723. {
  724. new CsTeams:iTeam = cs_get_user_team(id);
  725. new iRespawnChance = (ItemInfo[Respawn][MaxValue] / ItemInfo[Respawn][Levels] * g_iItemLevel[id][Respawn][iTeam]);
  726.  
  727. if( IsPlayer(id) )
  728. {
  729. if( g_bRespawned[id] == false )
  730. {
  731. if( random_num(1, 100) <= iRespawnChance )
  732. {
  733. g_bRespawned[id] = true;
  734.  
  735. set_task(1.0, "taskRespawnPlayer", (id + TASK_RESPAWN));
  736.  
  737. new szName[32];
  738. get_user_name(id, szName, charsmax(szName));
  739.  
  740. new iPlayers[32], iNum, iPlayer;
  741. get_players(iPlayers, iNum);
  742.  
  743. for( new i = 0; i < iNum; i++ )
  744. {
  745. iPlayer = iPlayers[i];
  746.  
  747. if( iPlayer != id )
  748. {
  749. Print(iPlayer, "^x01%s^x03 got respawned !^x04 (%i%%)", szName, iRespawnChance);
  750. }
  751. else
  752. {
  753. Print(id, "You got respawned !^x04 (%i%%)", iRespawnChance);
  754. }
  755. }
  756. }
  757. }
  758. }
  759. }
  760.  
  761. public FwdPlayerSpawn_Post(id)
  762. {
  763. if( is_user_alive(id) )
  764. {
  765. g_bAlive[id] = true;
  766. set_task(1.0, "GivePlayerItems", id + TASK_GIVEITEMS);
  767. }
  768. }
  769.  
  770. public taskRespawnPlayer(id)
  771. {
  772. ExecuteHamB(Ham_CS_RoundRespawn, (id - TASK_RESPAWN));
  773. }
  774.  
  775. public FwdPlayerTakeDamage(id, iInflictor, idAttacker, Float:fDamage, iBits)
  776. {
  777. if( iBits & DMG_FALL )
  778. {
  779. new iDamage = ItemInfo[FallDamage][MaxValue] / ItemInfo[FallDamage][Levels] * g_iItemLevel[id][FallDamage][cs_get_user_team(id)];
  780. SetHamParamFloat(4, fDamage * (1.0 - (float(iDamage) / 100.0)));
  781. }
  782. else
  783. {
  784. if( IsPlayer(idAttacker) )
  785. {
  786. if( fDamage > 0 )
  787. {
  788. new iDamage = ItemInfo[Damage][MaxValue] / ItemInfo[Damage][Levels] * g_iItemLevel[idAttacker][Damage][cs_get_user_team(id)];
  789. SetHamParamFloat(4, fDamage * (1.0 + (float(iDamage) / 100.0)));
  790. }
  791. }
  792. }
  793.  
  794. return HAM_IGNORED;
  795. }
  796.  
  797. public FwdPlayerTakeDamage_Post(id, iInflictor, idAttacker, Float:fDamage, iBits)
  798. {
  799. new CsTeams:iTeam;
  800. iTeam = cs_get_user_team(id);
  801. if( g_iItemLevel[id][NoPainShock][iTeam] > 0 )
  802. {
  803. set_pdata_float(id, 108, 1.0);
  804. }
  805. }
  806.  
  807. public CmdShowPoints(id)
  808. {
  809. if( get_playersnum() < get_pcvar_num(g_pCvar[PLAYERREQ]) )
  810. {
  811. set_hudmessage(110, 110, 110, -1.0, 0.88, 0, 6.0, 5.02, 0.0, 0.0, -1);
  812. show_hudmessage(id, "There are less than %i players.^nYou won't get any Points !", get_pcvar_num(g_pCvar[PLAYERREQ]));
  813. }
  814.  
  815. /*
  816. if( is_user_alive(id) )
  817. {
  818. set_dhudmessage(90, 90, 90, 0.8, 0.88, 0, 6.0, 10.02, 0.0, 0.0, -1);
  819. show_dhudmessage(id, "Points: %i", g_iPoints[id]);
  820.  
  821. set_task(10.0, "CmdShowPoints", id);
  822. }
  823. */
  824. }
  825.  
  826. public CmdHideRank(id)
  827. {
  828.  
  829. if( g_bUsedRank[id] )
  830. {
  831. Print(id, "Do not use this command to often !");
  832. }
  833.  
  834. CmdRank(id);
  835. g_bUsedRank[id] = true;
  836. return PLUGIN_HANDLED;
  837. }
  838.  
  839. public CmdRank(id)
  840. {
  841. new Array:aNames, Array:aAuths, Array:aXPs;
  842. new iTotal = SortTopPlayers(aNames, aAuths, aXPs);
  843.  
  844. new szAuth[35];
  845. get_user_authid(id, szAuth, charsmax(szAuth));
  846.  
  847. new szAuth2[35], i;
  848. for( i = 0; i < iTotal; i++ )
  849. {
  850. ArrayGetString(aAuths, i, szAuth2, charsmax(szAuth2));
  851.  
  852. if( equal(szAuth, szAuth2) )
  853. {
  854. new szData[256], szXP[11];
  855. nvault_get(g_iVault, szAuth2, szData, charsmax(szData));
  856. parse(szData, szXP, charsmax(szXP));
  857. Print(id, "Your rank is^x01 %i^x03 of^x01 %i^x03 with^x04 %i points", (i + 1), iTotal, str_to_num(szXP));
  858. break;
  859. }
  860. }
  861.  
  862. ArrayDestroy(aNames);
  863. ArrayDestroy(aAuths);
  864. ArrayDestroy(aXPs);
  865. }
  866.  
  867. public CreateTopTen()
  868. {
  869. new Array:aNames, Array:aAuths, Array:aXPs;
  870. new iTotal = SortTopPlayers(aNames, aAuths, aXPs);
  871.  
  872. new szName[156], szAuth[156];
  873. for( new i = 0; i < TOPRANKS; i++ )
  874. {
  875. if( i < iTotal )
  876. {
  877. ArrayGetString(aNames, i, szName, charsmax(szName));
  878. ArrayGetString(aAuths, i, szAuth, charsmax(szAuth));
  879. replace_all(szName, charsmax(szName), "&", "&amp;");
  880. replace_all(szName, charsmax(szName), "<", "&lt;");
  881. replace_all(szName, charsmax(szName), ">", "&gt;");
  882. formatex(g_szTopNames[i + 1], charsmax(g_szTopNames[]), "%s", szName);
  883. formatex(g_iTopAuth[i + 1], charsmax(g_iTopAuth[]), "%s", szAuth);
  884.  
  885. g_iTopPoints[i + 1] = ArrayGetCell(aXPs, i);
  886.  
  887. if( i < 3 )
  888. {
  889. formatex(g_iTopThree[i], charsmax(g_iTopThree[]), "%s", szAuth);
  890. }
  891. }
  892. }
  893.  
  894. ArrayDestroy(aNames);
  895. ArrayDestroy(aAuths);
  896. ArrayDestroy(aXPs);
  897.  
  898. return PLUGIN_HANDLED;
  899. }
  900.  
  901. public CmdMOTDTop(id)
  902. {
  903. new szMOTD[2368], iLen;
  904.  
  905. iLen = formatex(szMOTD[iLen], charsmax(szMOTD)-iLen,"<STYLE>body{background:#212121;color:#d1d1d1;font-family:Arial}table{width:100%%;font-size:11px}</STYLE><table cellpadding=1 cellspacing=1 border=0>");
  906. iLen += formatex(szMOTD[iLen], charsmax(szMOTD)-iLen, "<tr bgcolor=#333333><th width=5%%><align=left font color=white> Rank <th width=10%%> Nick <th width=10%%> Steamid <th width=10%%> Total points");
  907.  
  908. for( new i = 0; i < TOPRANKS; i++ )
  909. {
  910. if( i == 0 || i == 2 || i == 4 || i == 6 || i == 8 )
  911. {
  912. iLen += formatex(szMOTD[iLen], charsmax(szMOTD)-iLen, "<tr align=left%s><td align=left><font color=white> %i. <td> %s <td> %s <td> %i", " bgcolor=#2b5b95", (i + 1), g_szTopNames[i + 1], g_iTopAuth[i + 1], g_iTopPoints[i + 1]);
  913. }
  914. else
  915. {
  916. iLen += formatex(szMOTD[iLen], charsmax(szMOTD)-iLen, "<tr align=left%s><td align=left><font color=white> %i. <td> %s <td> %s <td> %i", " bgcolor=#333333", (i + 1), g_szTopNames[i + 1], g_iTopAuth[i + 1], g_iTopPoints[i + 1]);
  917. }
  918. }
  919.  
  920. iLen += formatex(szMOTD[iLen], charsmax(szMOTD)-iLen, "</table></body>");
  921.  
  922. show_motd(id, szMOTD, "HNS PointMod by dinnk.");
  923.  
  924. return PLUGIN_HANDLED;
  925. }
  926.  
  927. public CmdPlayerInfo(id)
  928. {
  929. new iMenu = menu_create("\r[PM] \wPointMod by \ybiffmeizter^n\y- Player Menu\w:\r", "handlePlayerMenu");
  930.  
  931. new iPlayers[32], iNum, iPlayer, szName[32], szKey[3];
  932. get_players(iPlayers, iNum);
  933.  
  934. for( new i; i < iNum; i++ )
  935. {
  936. iPlayer = iPlayers[i];
  937. get_user_name(iPlayer, szName, charsmax(szName));
  938. num_to_str(iPlayer, szKey, charsmax(szKey));
  939. menu_additem(iMenu, szName, szKey);
  940. }
  941.  
  942. menu_setprop(iMenu, MPROP_EXITNAME, "Back");
  943. menu_display(id, iMenu, 0);
  944. }
  945.  
  946. public handlePlayerMenu(id, iMenu, iItem)
  947. {
  948. if( iItem == MENU_EXIT )
  949. {
  950. menu_destroy(iMenu);
  951. TeamMenu(id);
  952. return PLUGIN_HANDLED;
  953. }
  954.  
  955. new szData[6], iAccess, iCallback;
  956. menu_item_getinfo(iMenu, iItem, iAccess, szData, charsmax(szData), _, _, iCallback);
  957.  
  958. new i = str_to_num(szData);
  959. new szAuth[35], szName[32];
  960. get_user_authid(i, szAuth, charsmax(szAuth));
  961. get_user_name(i, szName, charsmax(szName));
  962.  
  963. static szMotd[2500];
  964. new iLen = formatex(szMotd, charsmax(szMotd), "<html>");
  965. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "<body style=^"background-color:#030303; color:#FFFFFF^">");
  966. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "<p align=^"center^">");
  967. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "<h2><b>Player Info</b></h2>");
  968. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "<p align=^"left^">");
  969. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "Name: %s<br>", szName);
  970. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "Auth: %s<br>", szAuth);
  971. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "Points: %i<br>", g_iPoints[i]);
  972. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "Total Points: %i<br><br>", g_iPointsTotal[i]);
  973.  
  974. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "<br><h2><b>Terrorist Levels:</b></h2>");
  975. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  976. {
  977. if( ItemInfo[iItem][Levels] != 1 )
  978. {
  979. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "%s - Level: %i/%i<br>", ItemInfo[iItem][Name], g_iItemLevel[i][iItem][CS_TEAM_T], ItemInfo[iItem][Levels]);
  980. }
  981. }
  982. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  983. {
  984. if( ItemInfo[iItem][Levels] == 1 )
  985. {
  986. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "%s: %s<br>", ItemInfo[iItem][Name], g_iItemLevel[i][iItem][CS_TEAM_T] > 0 ? "Yes" : "No");
  987. }
  988. }
  989. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "<br><h2><b>Counter-Terrorist Levels:</b></h2>");
  990. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  991. {
  992. if( ItemInfo[iItem][Levels] != 1 )
  993. {
  994. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "%s - Level: %i/%i<br>", ItemInfo[iItem][Name], g_iItemLevel[i][iItem][CS_TEAM_CT], ItemInfo[iItem][Levels]);
  995. }
  996. }
  997. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  998. {
  999. if( ItemInfo[iItem][Levels] == 1 )
  1000. {
  1001. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "%s: %s<br>", ItemInfo[iItem][Name], g_iItemLevel[i][iItem][CS_TEAM_CT] > 0 ? "Yes" : "No");
  1002. }
  1003. }
  1004.  
  1005. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "</p>");
  1006. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "</body>");
  1007. iLen += formatex(szMotd[iLen], charsmax(szMotd) - iLen, "</html>");
  1008.  
  1009. show_motd(id, szMotd, "");
  1010. CmdPlayerInfo(id);
  1011. menu_destroy(iMenu);
  1012. return PLUGIN_HANDLED;
  1013. }
  1014.  
  1015. public CmdGive(id)
  1016. {
  1017. if( !access(id, ADMIN_IMMUNITY) )
  1018. {
  1019. console_print(id, "You don't have access!");
  1020. return PLUGIN_HANDLED;
  1021. }
  1022.  
  1023. new szArg[35];
  1024. read_argv(1, szArg, charsmax(szArg));
  1025.  
  1026. new iPlayer = cmd_target(id, szArg, CMDTARGET_NO_BOTS);
  1027. if( !iPlayer )
  1028. {
  1029. return PLUGIN_HANDLED;
  1030. }
  1031.  
  1032. read_argv(2, szArg, charsmax(szArg));
  1033. new iPoints = str_to_num(szArg);
  1034.  
  1035. if( iPoints <= 0 )
  1036. {
  1037. console_print(id, "Not enough points!");
  1038. if( iPoints < 0 )
  1039. {
  1040. console_print(id, "Use pm_removepoints instead !");
  1041. }
  1042. return PLUGIN_HANDLED;
  1043. }
  1044.  
  1045. if( iPoints > 999 )
  1046. {
  1047. console_print(id, "Too much points!");
  1048. return PLUGIN_HANDLED;
  1049. }
  1050.  
  1051. g_iPoints[iPlayer] += iPoints;
  1052. g_iPointsTotal[iPlayer] += iPoints;
  1053.  
  1054. new szName[2][32], szAuth[2][35];
  1055. get_user_name(id, szName[0], charsmax(szName[]));
  1056. get_user_name(iPlayer, szName[1], charsmax(szName[]));
  1057. get_user_authid(id, szAuth[0], charsmax(szAuth[]));
  1058. get_user_authid(iPlayer, szAuth[1], charsmax(szAuth[]));
  1059.  
  1060. Print(0, "^x01%s^x03 gave^x01 %i Point%s^x03 to^x01 %s^x03 !", szName[0], iPoints, iPoints > 1 ? "s" : "", szName[1]);
  1061. log_amx("ADMIN: %s (%s) gave points to %s (%s) Amount: %i Points", szName[0], szAuth[0], szName[1], szAuth[1], iPoints);
  1062.  
  1063. SaveData(iPlayer);
  1064. return PLUGIN_HANDLED;
  1065. }
  1066.  
  1067. public CmdTake(id)
  1068. {
  1069. if( !access(id, ADMIN_IMMUNITY) )
  1070. {
  1071. console_print(id, "You don't have access!");
  1072. return PLUGIN_HANDLED;
  1073. }
  1074.  
  1075. new szArg[35];
  1076. read_argv(1, szArg, charsmax(szArg));
  1077.  
  1078. new iPlayer = cmd_target(id, szArg, CMDTARGET_NO_BOTS);
  1079. if( !iPlayer )
  1080. {
  1081. return PLUGIN_HANDLED;
  1082. }
  1083.  
  1084. read_argv(2, szArg, charsmax(szArg));
  1085. new iPoints = str_to_num(szArg);
  1086.  
  1087. if( iPoints <= 0 )
  1088. {
  1089. return PLUGIN_HANDLED;
  1090. }
  1091.  
  1092. if( iPoints >= g_iPoints[iPlayer] )
  1093. {
  1094. console_print(id, "Too much points (User has: %i) !", g_iPoints[iPlayer]);
  1095. return PLUGIN_HANDLED;
  1096. }
  1097.  
  1098. g_iPoints[iPlayer] -= iPoints;
  1099. g_iPointsTotal[iPlayer] -= iPoints;
  1100.  
  1101. new szName[2][32], szAuth[2][35];
  1102. get_user_authid(id, szAuth[0], charsmax(szAuth[]));
  1103. get_user_authid(iPlayer, szAuth[1], charsmax(szAuth[]));
  1104. get_user_name(id, szName[0], charsmax(szName[]));
  1105. get_user_name(iPlayer, szName[1], charsmax(szName[]));
  1106.  
  1107. Print(0, "^x01%s^x03 removed^x01 %i Point%s^x03 from^x01 %s^x03 !", szName[0], iPoints, iPoints > 1 ? "s" : "", szName[1]);
  1108.  
  1109. log_amx("ADMIN: %s (%s) removed points from: %s (%s) Amount: %i Points", szName[0], szAuth[0], szName[1], szAuth[1], iPoints);
  1110.  
  1111. SaveData(iPlayer);
  1112.  
  1113. return PLUGIN_HANDLED;
  1114. }
  1115.  
  1116. public CmdReset(id)
  1117. {
  1118. if( !access(id, ADMIN_IMMUNITY) )
  1119. {
  1120. console_print(id, "You don't have access!");
  1121. return PLUGIN_HANDLED;
  1122. }
  1123.  
  1124. nvault_prune(g_iVault, 0, get_systime());
  1125. nvault_prune(g_iVault_Name, 0, get_systime());
  1126.  
  1127. new iPlayers[32], iNum, iPlayer;
  1128. get_players(iPlayers, iNum);
  1129.  
  1130. for( new i = 0; i < iNum; i++ )
  1131. {
  1132. iPlayer = iPlayers[i];
  1133. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  1134. {
  1135. g_iItemLevel[iPlayer][iItem][CS_TEAM_T] = 0;
  1136. g_iItemLevel[iPlayer][iItem][CS_TEAM_CT] = 0;
  1137. }
  1138.  
  1139. g_iPoints[iPlayer] = 0;
  1140. g_iPointsTotal[iPlayer] = 0;
  1141. }
  1142.  
  1143. server_cmd("restart");
  1144.  
  1145. return PLUGIN_CONTINUE;
  1146. }
  1147.  
  1148. public CmdResetPerson(id)
  1149. {
  1150. if( !access(id, ADMIN_IMMUNITY) )
  1151. {
  1152. console_print(id, "You don't have access!");
  1153. return PLUGIN_HANDLED;
  1154. }
  1155.  
  1156. new szArg[32];
  1157. read_argv(1, szArg, charsmax(szArg));
  1158.  
  1159. if( containi(szArg, "STEAM_") != -1 )
  1160. {
  1161. new szData[256], iTimestamp;
  1162. if( nvault_lookup(g_iVault, szArg, szData, charsmax(szData), iTimestamp) )
  1163. {
  1164. new iLen = formatex(szData, charsmax(szData), "0 0");
  1165.  
  1166. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  1167. {
  1168. iLen += formatex(szData[iLen], charsmax(szData) - iLen, " 0");
  1169. iLen += formatex(szData[iLen], charsmax(szData) - iLen, " 0");
  1170. }
  1171.  
  1172. nvault_set(g_iVault, szArg, szData);
  1173. }
  1174. }
  1175. else
  1176. {
  1177. new iPlayer = cmd_target(id, szArg, CMDTARGET_NO_BOTS);
  1178. if( !iPlayer )
  1179. {
  1180. return PLUGIN_HANDLED;
  1181. }
  1182.  
  1183. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  1184. {
  1185. g_iItemLevel[iPlayer][iItem][CS_TEAM_T] = 0;
  1186. g_iItemLevel[iPlayer][iItem][CS_TEAM_CT] = 0;
  1187. }
  1188.  
  1189. g_iPoints[iPlayer] = 0;
  1190. g_iPointsTotal[iPlayer] = 0;
  1191.  
  1192. SaveData(iPlayer);
  1193. }
  1194.  
  1195. return PLUGIN_HANDLED;
  1196. }
  1197.  
  1198. SortTopPlayers(&Array:aNames, &Array:aSteamIDs, &Array:aXPs)
  1199. {
  1200. aNames = ArrayCreate(32);
  1201. aSteamIDs = ArrayCreate(35);
  1202. aXPs = ArrayCreate(1);
  1203.  
  1204. new hVault = nvault_util_open("HNSPointModNew");
  1205. new iCount = nvault_util_count(hVault);
  1206. new iPos;
  1207. new szSteamID[35], szXP[11], iTimeStamp, szName[32];
  1208.  
  1209. for( new i = 0; i < iCount; i++ )
  1210. {
  1211. iPos = nvault_util_read(hVault, iPos, szSteamID, charsmax(szSteamID), szXP, charsmax(szXP), iTimeStamp);
  1212.  
  1213. nvault_get(g_iVault_Name, szSteamID, szName, charsmax(szName));
  1214.  
  1215. ArrayPushString(aNames, szName);
  1216. ArrayPushString(aSteamIDs, szSteamID);
  1217. ArrayPushCell(aXPs, str_to_num(szXP));
  1218. }
  1219.  
  1220. nvault_util_close(hVault);
  1221.  
  1222. new iXP;
  1223. for( new i = 0, j; i < (iCount - 1); i++ )
  1224. {
  1225. iXP = ArrayGetCell(aXPs, i);
  1226.  
  1227. for( j = i + 1; j < iCount; j++ )
  1228. {
  1229. if( iXP < ArrayGetCell(aXPs, j) )
  1230. {
  1231. ArraySwap(aNames, i, j);
  1232. ArraySwap(aSteamIDs, i, j);
  1233. ArraySwap(aXPs, i, j);
  1234.  
  1235. i--;
  1236.  
  1237. break;
  1238. }
  1239. }
  1240. }
  1241.  
  1242. return iCount;
  1243. }
  1244.  
  1245. public SaveData(id)
  1246. {
  1247. static szData[256];
  1248. new szAuth[35];
  1249. get_user_authid(id, szAuth, charsmax(szAuth));
  1250.  
  1251. new iLen = formatex(szData, charsmax(szData), "%i %i", g_iPointsTotal[id], g_iPoints[id]);
  1252.  
  1253. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  1254. {
  1255. iLen += formatex(szData[iLen], charsmax(szData) - iLen, " %i", g_iItemLevel[id][iItem][CS_TEAM_T]);
  1256. iLen += formatex(szData[iLen], charsmax(szData) - iLen, " %i", g_iItemLevel[id][iItem][CS_TEAM_CT]);
  1257. }
  1258.  
  1259. nvault_set(g_iVault, szAuth, szData);
  1260.  
  1261. new szName[32], szNameTemp[32];
  1262. get_user_name(id, szName, charsmax(szName));
  1263. formatex(szNameTemp, charsmax(szNameTemp), "%s", szName);
  1264.  
  1265. nvault_set(g_iVault_Name, szAuth, szNameTemp);
  1266. }
  1267.  
  1268. public LoadData(id)
  1269. {
  1270. static szData[256];
  1271. new szAuth[35], iTimestamp;
  1272. get_user_authid(id, szAuth, charsmax(szAuth));
  1273. if( nvault_lookup(g_iVault, szAuth, szData, charsmax(szData), iTimestamp) )
  1274. {
  1275. ParseLoadData(id, szData);
  1276. }
  1277. else
  1278. {
  1279. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  1280. {
  1281. g_iItemLevel[id][iItem][CS_TEAM_T] = 0;
  1282. g_iItemLevel[id][iItem][CS_TEAM_CT] = 0;
  1283. }
  1284.  
  1285. g_iPoints[id] = 0;
  1286. g_iPointsTotal[id] = 0;
  1287. }
  1288. }
  1289.  
  1290. ParseLoadData(id, szData[256])
  1291. {
  1292. static szNum[11];
  1293. strbreak(szData, szNum, charsmax(szNum), szData, charsmax(szData));
  1294. g_iPointsTotal[id] = str_to_num(szNum);
  1295. strbreak(szData, szNum, charsmax(szNum), szData, charsmax(szData));
  1296. g_iPoints[id] = str_to_num(szNum);
  1297.  
  1298. for( new iItem = 0; iItem < UPGRADES; iItem++ )
  1299. {
  1300. strbreak(szData, szNum, charsmax(szNum), szData, charsmax(szData));
  1301. g_iItemLevel[id][iItem][CS_TEAM_T] = str_to_num(szNum);
  1302. strbreak(szData, szNum, charsmax(szNum), szData, charsmax(szData));
  1303. g_iItemLevel[id][iItem][CS_TEAM_CT] = str_to_num(szNum);
  1304. }
  1305. }
  1306.  
  1307. Print(id, const szMsg[], any:...)
  1308. {
  1309. static i;
  1310. i = id ? id : get_Player();
  1311.  
  1312. if( !i )
  1313. {
  1314. return;
  1315. }
  1316.  
  1317. new szMessage[256];
  1318. new iLen = formatex(szMessage, charsmax(szMessage), "^x04[Point Mod]^x03 ");
  1319. vformat(szMessage[iLen], charsmax(szMessage) - iLen, szMsg, 3);
  1320. szMessage[192] = '^0';
  1321.  
  1322. static g_iMsgSayText;
  1323. if( !g_iMsgSayText )
  1324. {
  1325. g_iMsgSayText = get_user_msgid("SayText");
  1326. }
  1327.  
  1328. new const szTeams[][] =
  1329. {
  1330. "",
  1331. "TERRORIST",
  1332. "CT",
  1333. "SPECTATOR"
  1334. };
  1335.  
  1336. new CsTeams:iTeam = cs_get_user_team(i);
  1337.  
  1338. team_Info(i, id, szTeams[0]);
  1339.  
  1340. message_begin(id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iMsgSayText, _, id);
  1341. write_byte(i);
  1342. write_string(szMessage);
  1343. message_end();
  1344.  
  1345. team_Info(i, id, szTeams[_:iTeam]);
  1346. }
  1347.  
  1348. team_Info(iReceiver, iSender, szTeam[])
  1349. {
  1350. static g_iMsgTeamInfo;
  1351. if( !g_iMsgTeamInfo )
  1352. {
  1353. g_iMsgTeamInfo = get_user_msgid("TeamInfo");
  1354. }
  1355.  
  1356. message_begin(iSender ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iMsgTeamInfo, _, iSender);
  1357. write_byte(iReceiver);
  1358. write_string(szTeam);
  1359. message_end();
  1360. }
  1361.  
  1362. get_Player()
  1363. {
  1364. for( new id = 1; id <= get_maxplayers(); id++ )
  1365. {
  1366. return id;
  1367. }
  1368.  
  1369. return 0;
  1370. }
  1371.  
  1372. public CmdUpdatePoints(iEnt)
  1373. {
  1374. entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 5.0);
  1375. new iPlayers[32], iNum, id;
  1376. get_players(iPlayers, iNum);
  1377.  
  1378. for( new i = 0; i < iNum; i++ )
  1379. {
  1380. id = iPlayers[i];
  1381.  
  1382. if( g_bAlive[id] )
  1383. {
  1384. CmdShowPoints(id);
  1385. }
  1386. }
  1387. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement