Advertisement
Guest User

Untitled

a guest
Aug 5th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.02 KB | None | 0 0
  1. /**
  2. * -----------------------------------------------------
  3. * File panellib.sp
  4. * Authors David <popoklopsi> Ordnung
  5. * License GPLv3
  6. * Web http://popoklopsi.de
  7. * -----------------------------------------------------
  8. *
  9. * Copyright (C) 2012-2014 David <popoklopsi> Ordnung
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation, either version 3 of the License, or
  14. * any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. */
  24.  
  25.  
  26. // Use semicolons
  27. #pragma semicolon 1
  28.  
  29.  
  30.  
  31.  
  32. // Panels
  33. new Handle:panellib_credits;
  34.  
  35.  
  36.  
  37.  
  38. // Init. Panellib
  39. panellib_Start()
  40. {
  41. decl String:infoString[256];
  42.  
  43.  
  44. Format(g_sInfoF, sizeof(g_sInfoF), g_sInfo);
  45. Format(g_sChangeF, sizeof(g_sChangeF), g_sChange);
  46.  
  47.  
  48.  
  49. // register sinfo and schange and take out "_sm"
  50. RegConsoleCmd(g_sInfo, panellib_InfoPanel);
  51. RegConsoleCmd(g_sChange, panellib_ChangePanel);
  52.  
  53. if (!StrContains(g_sInfo, "sm_"))
  54. {
  55. ReplaceString(g_sInfoF, sizeof(g_sInfoF), "sm_", "!");
  56. }
  57.  
  58.  
  59. if (!StrContains(g_sChange, "sm_"))
  60. {
  61. ReplaceString(g_sChangeF, sizeof(g_sChangeF), "sm_", "!");
  62. }
  63.  
  64. // Register sadmin
  65. if (!StrContains(g_sAdminMenu, "sm_"))
  66. {
  67. RegAdminCmd(g_sAdminMenu, panellib_OpenAdmin, ADMFLAG_CUSTOM6);
  68. }
  69.  
  70.  
  71.  
  72. // Create new Panels
  73. panellib_credits = CreatePanel();
  74.  
  75.  
  76. // Create Stamm Credits
  77. SetPanelTitle(panellib_credits, "Stamm Credits");
  78.  
  79. DrawPanelText(panellib_credits, "-------------------------------------------");
  80. DrawPanelText(panellib_credits, "Author: Popoklopsi");
  81.  
  82. Format(infoString, sizeof(infoString), "Version: %s", g_sPluginVersionUpdate);
  83. DrawPanelText(panellib_credits, infoString);
  84.  
  85. DrawPanelText(panellib_credits, "Stamm Page: https://forums.alliedmods.net/showthread.php?t=142073");
  86. DrawPanelText(panellib_credits, "-------------------------------------------");
  87.  
  88. Format(infoString, sizeof(infoString), "%T", "Back", LANG_SERVER);
  89. DrawPanelItem(panellib_credits, infoString);
  90.  
  91. Format(infoString, sizeof(infoString), "%T", "Close", LANG_SERVER);
  92. DrawPanelItem(panellib_credits, infoString);
  93. }
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. Handle:panellib_createInfoPanel(client)
  102. {
  103. if (clientlib_isValidClient(client))
  104. {
  105. // Create Info Panel
  106. new Handle:panellib_info;
  107.  
  108. // Get points
  109. new restpoints = 0;
  110. new index = g_iPlayerLevel[client];
  111. new points = g_iPlayerPoints[client];
  112. new striptag = GetConVarBool(configlib_StripTag);
  113.  
  114. // Strings
  115. decl String:infoString[512];
  116. decl String:name[MAX_NAME_LENGTH+1];
  117. decl String:vip[32];
  118.  
  119.  
  120. // Format VIP String
  121. Format(vip, sizeof(vip), " %T", "VIP", client);
  122.  
  123.  
  124.  
  125. // Client Name
  126. GetClientName(client, name, sizeof(name));
  127.  
  128.  
  129.  
  130. panellib_info = CreatePanel();
  131.  
  132. // Create Main info Panel
  133. SetPanelTitle(panellib_info, "Stamm by Popoklopsi");
  134.  
  135. // Split Line
  136. DrawPanelText(panellib_info, "-------------------------------------------");
  137.  
  138.  
  139.  
  140. // Now add points text
  141. // If not highest level, calculate rest points
  142. if (index != g_iLevels && index < g_iLevels)
  143. {
  144. restpoints = g_iLevelPoints[index] - g_iPlayerPoints[client];
  145. }
  146.  
  147.  
  148. // Highest level?
  149. if (index != g_iLevels && index < g_iLevels)
  150. {
  151. if (!striptag)
  152. {
  153. Format(infoString, sizeof(infoString), "%T", "NoVIPClientPlain", client, points, restpoints, g_sLevelName[g_iPlayerLevel[client]], vip);
  154. }
  155. else
  156. {
  157. Format(infoString, sizeof(infoString), "%T", "NoVIPClientPlain", client, points, restpoints, g_sLevelName[g_iPlayerLevel[client]], "");
  158. }
  159. }
  160. else
  161. {
  162. if (!striptag)
  163. {
  164. Format(infoString, sizeof(infoString), "%T", "VIPClientPlain", client, points, g_sLevelName[index-1], vip);
  165. }
  166. else
  167. {
  168. Format(infoString, sizeof(infoString), "%T", "VIPClientPlain", client, points, g_sLevelName[index-1], "");
  169. }
  170. }
  171.  
  172.  
  173. // Draw Infos
  174. DrawPanelText(panellib_info, infoString);
  175.  
  176.  
  177. // Split Line
  178. DrawPanelText(panellib_info, "-------------------------------------------");
  179.  
  180.  
  181.  
  182.  
  183. Format(infoString, sizeof(infoString), "%T", "PointInfo", client);
  184. DrawPanelText(panellib_info, infoString);
  185.  
  186.  
  187.  
  188. // Add points information
  189. // Kill
  190. Format(infoString, sizeof(infoString), "1 %T", "Kill", client);
  191.  
  192.  
  193. if (g_iVipType == 1 || g_iVipType == 4 || g_iVipType == 5 || g_iVipType == 7)
  194. {
  195. DrawPanelText(panellib_info, infoString);
  196. }
  197.  
  198.  
  199.  
  200. // Rounds
  201. Format(infoString, sizeof(infoString), "1 %T", "Round", client);
  202.  
  203.  
  204. if (g_iVipType == 2 || g_iVipType == 4 || g_iVipType == 6 || g_iVipType == 7)
  205. {
  206. DrawPanelText(panellib_info, infoString);
  207. }
  208.  
  209.  
  210.  
  211. // Time
  212. Format(infoString, sizeof(infoString), "%i %T", g_iTimePoint, "Minute", client);
  213.  
  214.  
  215. if (g_iVipType == 3 || g_iVipType == 5 || g_iVipType == 6 || g_iVipType == 7)
  216. {
  217. DrawPanelText(panellib_info, infoString);
  218. }
  219.  
  220.  
  221.  
  222. DrawPanelText(panellib_info, "-------------------------------------------");
  223.  
  224. Format(infoString, sizeof(infoString), "%T", "StammFeatures", client);
  225. DrawPanelItem(panellib_info, infoString);
  226.  
  227. Format(infoString, sizeof(infoString), "%T", "StammCMD", client);
  228. DrawPanelItem(panellib_info, infoString);
  229.  
  230. Format(infoString, sizeof(infoString), "%T", "AllLevels", client);
  231. DrawPanelItem(panellib_info, infoString);
  232.  
  233. DrawPanelItem(panellib_info, "Credits");
  234. DrawPanelText(panellib_info, "-------------------------------------------");
  235.  
  236. Format(infoString, sizeof(infoString), "%T", "Close", client);
  237. DrawPanelItem(panellib_info, infoString);
  238.  
  239.  
  240. return panellib_info;
  241. }
  242.  
  243.  
  244.  
  245. // Invalid Player -> Invalid Handle^^
  246. return INVALID_HANDLE;
  247. }
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254. // Open admin menu
  255. public Action:panellib_OpenAdmin(client, args)
  256. {
  257. // Only for valid clients
  258. if (clientlib_isValidClient(client))
  259. {
  260. panellib_CreateUserPanels(client, 4);
  261. }
  262.  
  263. return Plugin_Handled;
  264. }
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. // Open change panel
  272. public Action:panellib_ChangePanel(client, args)
  273. {
  274. panellib_CreateUserPanels(client, 1);
  275.  
  276. return Plugin_Handled;
  277. }
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284. // Intern function to create and send Panels
  285. panellib_CreateUserPanels(client, mode)
  286. {
  287. // Change panel, always up to date
  288. if (mode == 1)
  289. {
  290. // Only valid clients
  291. if (clientlib_isValidClient(client))
  292. {
  293. // Do we found something?
  294. new bool:found = false;
  295.  
  296. new Handle:ChangeMenu = CreateMenu(panellib_ChangePanelHandler);
  297. decl String:MenuItem[100];
  298. decl String:index[10];
  299.  
  300.  
  301. SetMenuExitButton(ChangeMenu, true);
  302. SetMenuTitle(ChangeMenu, "%T", "ChangeFeatures", client);
  303.  
  304.  
  305. // Loop through all features
  306. for (new i=0; i < g_iFeatures; i++)
  307. {
  308. new bool:enabled;
  309.  
  310.  
  311. /* TODO: IMPLEMENT
  312. // Maybe he bought a block
  313. for (new j=0; j < g_FeatureList[i][FEATURE_BLOCKS]; j++)
  314. {
  315. if (GetArrayCell(g_hBoughtBlock[client][i], j) == 1)
  316. {
  317. enabled = true;
  318.  
  319. break;
  320. }
  321. }*/
  322.  
  323.  
  324. // Only enabled features and changeable features
  325. if (g_FeatureList[i][FEATURE_ENABLE] && g_FeatureList[i][FEATURE_CHANGE] && (g_iPlayerLevel[client] >= g_FeatureList[i][FEATURE_LEVEL][0] || enabled))
  326. {
  327. // found something
  328. found = true;
  329.  
  330.  
  331.  
  332. // Text to enable or disable feature
  333. if (g_FeatureList[i][WANT_FEATURE][client])
  334. {
  335. Format(MenuItem, sizeof(MenuItem), "%T", "FeatureOn", client, g_FeatureList[i][FEATURE_NAME]);
  336. }
  337. else
  338. {
  339. Format(MenuItem, sizeof(MenuItem), "%T", "FeatureOff", client, g_FeatureList[i][FEATURE_NAME]);
  340. }
  341.  
  342.  
  343.  
  344. // Save index and add
  345. Format(index, sizeof(index), "%i", i);
  346.  
  347. AddMenuItem(ChangeMenu, index, MenuItem);
  348. }
  349. }
  350.  
  351. if (found)
  352. {
  353. // Now display the menu
  354. DisplayMenu(ChangeMenu, client, 60);
  355. }
  356. else
  357. {
  358. if (!g_bMoreColors)
  359. {
  360. CPrintToChat(client, "%s %t", g_sStammTag, "NoFeatureFound");
  361. }
  362. else
  363. {
  364. MCPrintToChat(client, "%s %t", g_sStammTag, "NoFeatureFound");
  365. }
  366. }
  367. }
  368. }
  369.  
  370.  
  371.  
  372. // Open info handler
  373. if (mode == 3)
  374. {
  375. SendPanelToClient(panellib_createInfoPanel(client), client, panellib_InfoHandler, 40);
  376. }
  377.  
  378.  
  379. // Open Admin menu
  380. if (mode == 4)
  381. {
  382. new Handle:panellib_adminpanel = CreatePanel();
  383. decl String:infoString[256];
  384.  
  385. // Create Admin Menu
  386. Format(infoString, sizeof(infoString), "%T", "AdminMenu", client);
  387. SetPanelTitle(panellib_adminpanel, infoString);
  388.  
  389. DrawPanelText(panellib_adminpanel, "----------------------------------------------------");
  390.  
  391. Format(infoString, sizeof(infoString), "%T", "PointsOfPlayer", client);
  392. DrawPanelItem(panellib_adminpanel, infoString);
  393.  
  394. Format(infoString, sizeof(infoString), "%T", "ResetPlayer", client);
  395. DrawPanelItem(panellib_adminpanel, infoString);
  396.  
  397. Format(infoString, sizeof(infoString), "%T", "HappyHour", client);
  398. DrawPanelItem(panellib_adminpanel, infoString);
  399.  
  400. Format(infoString, sizeof(infoString), "%T", "HappyHourEnd", client);
  401. DrawPanelItem(panellib_adminpanel, infoString);
  402.  
  403. Format(infoString, sizeof(infoString), "%T", "LoadFeature", client);
  404. DrawPanelItem(panellib_adminpanel, infoString);
  405.  
  406. Format(infoString, sizeof(infoString), "%T", "UnloadFeature", client);
  407. DrawPanelItem(panellib_adminpanel, infoString);
  408.  
  409. DrawPanelText(panellib_adminpanel, "----------------------------------------------------");
  410.  
  411. Format(infoString, sizeof(infoString), "%T", "Close", client);
  412. DrawPanelItem(panellib_adminpanel, infoString);
  413.  
  414. SendPanelToClient(panellib_adminpanel, client, panellib_AdminHandler, 40);
  415. }
  416. }
  417.  
  418.  
  419.  
  420.  
  421.  
  422. // Want the info Panel
  423. public Action:panellib_InfoPanel(client, args)
  424. {
  425. // Open it for valid users
  426. if (clientlib_isValidClient(client))
  427. {
  428. panellib_CreateUserPanels(client, 3);
  429. }
  430.  
  431. return Plugin_Handled;
  432. }
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439. // Changed feature state
  440. public panellib_ChangePanelHandler(Handle:menu, MenuAction:action, param1, param2)
  441. {
  442. if (action == MenuAction_Select)
  443. {
  444. if (clientlib_isValidClient(param1))
  445. {
  446. decl String:ChangeChoose[64];
  447. new index;
  448.  
  449.  
  450.  
  451. // Get selected item
  452. GetMenuItem(menu, param2, ChangeChoose, sizeof(ChangeChoose));
  453.  
  454. // Get the index
  455. index = StringToInt(ChangeChoose);
  456.  
  457. // Just set to opposite
  458. g_FeatureList[index][WANT_FEATURE][param1] = !g_FeatureList[index][WANT_FEATURE][param1];
  459.  
  460.  
  461.  
  462. // Only if enabled
  463. if (g_FeatureList[index][FEATURE_ENABLE])
  464. {
  465. // Notice to API
  466. nativelib_ClientChanged(param1, g_FeatureList[index][FEATURE_HANDLE], g_FeatureList[index][WANT_FEATURE][param1] /* TODO: IMPLEMENT ,false */);
  467. }
  468.  
  469.  
  470. //Open it again
  471. panellib_CreateUserPanels(param1, 1);
  472. }
  473. }
  474.  
  475. else if (action == MenuAction_End)
  476. {
  477. // destroy menu
  478. CloseHandle(menu);
  479. }
  480. }
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488. // Want to load a feature
  489. public panellib_FeaturelistLoadHandler(Handle:menu, MenuAction:action, param1, param2)
  490. {
  491. if (action == MenuAction_Select)
  492. {
  493. decl String:choose[12];
  494.  
  495. // Get selected and load it
  496. GetMenuItem(menu, param2, choose, sizeof(choose));
  497.  
  498. featurelib_loadFeature(g_FeatureList[StringToInt(choose)][FEATURE_HANDLE]);
  499.  
  500. panellib_AdminHandler(INVALID_HANDLE, MenuAction_Select, param1, 5);
  501. }
  502.  
  503. else if (action == MenuAction_Cancel)
  504. {
  505. panellib_CreateUserPanels(param1, 4);
  506. }
  507.  
  508. // Stop menu
  509. else if (action == MenuAction_End)
  510. {
  511. CloseHandle(menu);
  512. }
  513. }
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520. // Want to unload a feature
  521. public panellib_FeaturelistUnloadHandler(Handle:menu, MenuAction:action, param1, param2)
  522. {
  523. if (action == MenuAction_Select)
  524. {
  525. decl String:choose[12];
  526.  
  527. // Get item and unload
  528. GetMenuItem(menu, param2, choose, sizeof(choose));
  529.  
  530. featurelib_UnloadFeature(g_FeatureList[StringToInt(choose)][FEATURE_HANDLE]);
  531.  
  532. panellib_AdminHandler(INVALID_HANDLE, MenuAction_Select, param1, 6);
  533. }
  534.  
  535. else if (action == MenuAction_Cancel)
  536. {
  537. panellib_CreateUserPanels(param1, 4);
  538. }
  539.  
  540. // Close
  541. else if (action == MenuAction_End)
  542. {
  543. CloseHandle(menu);
  544. }
  545. }
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553. // Open Info Panel
  554. public panellib_PanelHandler(Handle:menu, MenuAction:action, param1, param2)
  555. {
  556. if (action == MenuAction_Select)
  557. {
  558. if ((param2 == 1 || param2 == 2) && clientlib_isValidClient(param1))
  559. {
  560. SendPanelToClient(panellib_createInfoPanel(param1), param1, panellib_InfoHandler, 40);
  561. }
  562. }
  563. }
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571. // Just a pass panel handler for back button
  572. public panellib_LevelHandler(Handle:menu, MenuAction:action, param1, param2)
  573. {
  574. if (action == MenuAction_Cancel)
  575. {
  576. // Pressed back
  577. if (param2 == MenuCancel_ExitBack && clientlib_isValidClient(param1))
  578. {
  579. // Send info panel again
  580. SendPanelToClient(panellib_createInfoPanel(param1), param1, panellib_InfoHandler, 40);
  581. }
  582. }
  583.  
  584. else if (action == MenuAction_End)
  585. {
  586. // Close
  587. CloseHandle(menu);
  588. }
  589. }
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597. // Add Points to a player
  598. public panellib_PlayerListHandler(Handle:menu, MenuAction:action, param1, param2)
  599. {
  600. if (action == MenuAction_Select)
  601. {
  602. decl String:menuinfo[32];
  603.  
  604. // get player
  605. GetMenuItem(menu, param2, menuinfo, sizeof(menuinfo));
  606.  
  607. new client = StringToInt(menuinfo);
  608.  
  609. // Valid user
  610. if (clientlib_isValidClient(param1) && clientlib_isValidClient(client))
  611. {
  612. // Client should write points to add
  613. g_iPointsNumber[param1] = client;
  614.  
  615.  
  616. if (!g_bMoreColors)
  617. {
  618. CPrintToChat(param1, "%s %t", g_sStammTag, "WritePoints");
  619. CPrintToChat(param1, "%s %t", g_sStammTag, "WritePointsInfo");
  620. }
  621. else
  622. {
  623. MCPrintToChat(param1, "%s %t", g_sStammTag, "WritePoints");
  624. MCPrintToChat(param1, "%s %t", g_sStammTag, "WritePointsInfo");
  625. }
  626. }
  627. }
  628.  
  629. else if (action == MenuAction_Cancel)
  630. {
  631. panellib_CreateUserPanels(param1, 4);
  632. }
  633.  
  634. else if (action == MenuAction_End)
  635. {
  636. // Close
  637. CloseHandle(menu);
  638. }
  639. }
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647. // Delete a player
  648. public panellib_PlayerListHandlerDelete(Handle:menu, MenuAction:action, param1, param2)
  649. {
  650. if (action == MenuAction_Select)
  651. {
  652. decl String:query[256];
  653. decl String:menuinfo[32];
  654. decl String:name[MAX_NAME_LENGTH+1];
  655. decl String:steamid[64];
  656.  
  657.  
  658.  
  659. // get player to delete
  660. GetMenuItem(menu, param2, menuinfo, sizeof(menuinfo));
  661.  
  662. new client = StringToInt(menuinfo);
  663.  
  664.  
  665.  
  666. // Must be valid
  667. if (clientlib_isValidClient(client) && clientlib_isValidClient(param1))
  668. {
  669. // Get the name and steamid
  670. GetClientName(client, name, sizeof(name));
  671. clientlib_getSteamid(client, steamid, sizeof(steamid));
  672.  
  673.  
  674. if (!g_bMoreColors)
  675. {
  676. CPrintToChat(param1, "%s %t", g_sStammTag, "DeletedPoints", name);
  677. }
  678. else
  679. {
  680. MCPrintToChat(param1, "%s %t", g_sStammTag, "DeletedPoints", name);
  681. }
  682.  
  683.  
  684. // Print to deleted client, 3 TIMES :o
  685. for (new i=0; i<3; i++)
  686. {
  687. if (!g_bMoreColors)
  688. {
  689. CPrintToChat(client, "%s %t", g_sStammTag, "YourDeletedPoints");
  690. }
  691. else
  692. {
  693. MCPrintToChat(client, "%s %t", g_sStammTag, "YourDeletedPoints");
  694. }
  695. }
  696.  
  697.  
  698. // Set level and points to zero
  699. g_iPlayerPoints[client] = 0;
  700.  
  701.  
  702. // Update in database
  703. Format(query, sizeof(query), g_sUpdateSetPointsZeroQuery, g_sTableName, steamid);
  704.  
  705. SQL_TQuery(sqllib_db, sqllib_SQLErrorCheckCallback, query);
  706.  
  707.  
  708. // Check with new stats
  709. clientlib_CheckVip(client);
  710. }
  711. }
  712.  
  713. else if (action == MenuAction_Cancel)
  714. {
  715. panellib_CreateUserPanels(param1, 4);
  716. }
  717.  
  718. else if (action == MenuAction_End)
  719. {
  720. // Close
  721. CloseHandle(menu);
  722. }
  723. }
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. // Handle Feature list back button
  731. public panellib_FeatureHandler(Handle:menu, MenuAction:action, param1, param2)
  732. {
  733. if (action == MenuAction_Cancel)
  734. {
  735. // Pressed back
  736. if (param2 == MenuCancel_ExitBack && clientlib_isValidClient(param1))
  737. {
  738. // Proceed here
  739. panellib_InfoHandler(INVALID_HANDLE, MenuAction_Select, param1, 1);
  740. }
  741. }
  742.  
  743. else if (action == MenuAction_End)
  744. {
  745. // close
  746. CloseHandle(menu);
  747. }
  748. }
  749.  
  750.  
  751.  
  752.  
  753.  
  754. // Pressed a command
  755. public panellib_CmdlistHandler(Handle:menu, MenuAction:action, param1, param2)
  756. {
  757. if (action == MenuAction_Select)
  758. {
  759. if (clientlib_isValidClient(param1))
  760. {
  761. decl String:command[64];
  762.  
  763. // Get Command
  764. GetMenuItem(menu, param2, command, sizeof(command));
  765.  
  766.  
  767. FakeClientCommandEx(param1, "say \"%s\"", command);
  768. }
  769. }
  770.  
  771. else if (action == MenuAction_Cancel)
  772. {
  773. // Go back
  774. if (param2 == MenuCancel_ExitBack && clientlib_isValidClient(param1))
  775. {
  776. SendPanelToClient(panellib_createInfoPanel(param1), param1, panellib_InfoHandler, 40);
  777. }
  778. }
  779.  
  780.  
  781. // Close
  782. if (action == MenuAction_End)
  783. {
  784. CloseHandle(menu);
  785. }
  786. }
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793. // Pressed something on the info handler
  794. public panellib_InfoHandler(Handle:menu, MenuAction:action, param1, param2)
  795. {
  796. if (action == MenuAction_Select)
  797. {
  798. if (clientlib_isValidClient(param1))
  799. {
  800. if (param2 == 4)
  801. {
  802. // Credits
  803. SendPanelToClient(panellib_credits, param1, panellib_PanelHandler, 20);
  804. }
  805.  
  806. else if (param2 == 3)
  807. {
  808. // Open level overview
  809. new Handle:panellib_levels = CreateMenu(panellib_LevelHandler);
  810. decl String:infoString[256];
  811.  
  812. // Create Level Overview
  813. Format(infoString, sizeof(infoString), "%T", "AllLevels", param1);
  814.  
  815. SetMenuTitle(panellib_levels, infoString);
  816. SetMenuExitBackButton(panellib_levels, true);
  817. SetMenuExitButton(panellib_levels, true);
  818.  
  819.  
  820. // Add all non privat levels
  821. for (new i=0; i < g_iLevels; i++)
  822. {
  823. Format(infoString, sizeof(infoString), "%s - %i %T", g_sLevelName[i], g_iLevelPoints[i], "Points", param1);
  824. AddMenuItem(panellib_levels, "", infoString, ITEMDRAW_DISABLED);
  825. }
  826.  
  827.  
  828. // Add private levels
  829. for (new i=0; i < g_iPLevels; i++)
  830. {
  831. Format(infoString, sizeof(infoString), "%s - %T %s", g_sLevelName[g_iLevels+i], "Flag", param1, g_sLevelFlag[i]);
  832. AddMenuItem(panellib_levels, "", infoString, ITEMDRAW_DISABLED);
  833. }
  834.  
  835.  
  836. DisplayMenu(panellib_levels, param1, 30);
  837. }
  838.  
  839. else if (param2 == 2)
  840. {
  841. // Open command list menu
  842. new Handle:cmdlist = CreateMenu(panellib_CmdlistHandler);
  843.  
  844.  
  845. decl String:infoString[128];
  846.  
  847.  
  848. SetMenuTitle(cmdlist, "%T", "StammCMD", param1);
  849. SetMenuExitBackButton(cmdlist, true);
  850.  
  851.  
  852. // Notice request
  853. nativelib_RequestCommands(param1);
  854.  
  855.  
  856. // Add all commands
  857. for (new i=0; i < g_iCommands; i++)
  858. {
  859. // Add command
  860. Format(infoString, sizeof(infoString), "%s %s", g_sCommandName[i], g_sCommand[i]);
  861.  
  862. AddMenuItem(cmdlist, g_sCommand[i], infoString);
  863. }
  864.  
  865. // Send
  866. DisplayMenu(cmdlist, param1, 20);
  867. }
  868.  
  869. // Open feature list
  870. else if (param2 == 1)
  871. {
  872. // Found feature?
  873. decl String:featureid[10];
  874. new bool:foundFeature = false;
  875. new Handle:featurelist = CreateMenu(panellib_FeatureListHandler);
  876.  
  877.  
  878.  
  879. // title and exit button
  880. SetMenuTitle(featurelist, "%T", "HaveFeatures", param1);
  881. SetMenuExitBackButton(featurelist, true);
  882.  
  883.  
  884. // Loop through levels
  885. for (new i=0; i < g_iLevels+g_iPLevels; i++)
  886. {
  887. // Found nothing
  888. foundFeature = false;
  889.  
  890. // Loop through features, find one
  891. for (new j=0; j < g_iFeatures && !foundFeature; j++)
  892. {
  893. // Only enabled features
  894. if (!g_FeatureList[j][FEATURE_ENABLE])
  895. {
  896. continue;
  897. }
  898.  
  899. for (new l=0; l < g_FeatureList[j][FEATURE_BLOCKS] && !foundFeature; l++)
  900. {
  901. if (i+1 != g_FeatureList[j][FEATURE_LEVEL][l])
  902. {
  903. continue;
  904. }
  905.  
  906. new Handle:hArray = nativelib_RequestFeature(g_FeatureList[j][FEATURE_HANDLE], param1, l+1);
  907.  
  908.  
  909. if (hArray == INVALID_HANDLE)
  910. {
  911. continue;
  912. }
  913.  
  914.  
  915. if (GetArraySize(hArray) <= 0)
  916. {
  917. CloseHandle(hArray);
  918.  
  919. continue;
  920. }
  921.  
  922.  
  923. CloseHandle(hArray);
  924.  
  925.  
  926. // Add level
  927. Format(featureid, sizeof(featureid), "%i", i+1);
  928.  
  929. AddMenuItem(featurelist, featureid, g_sLevelName[i]);
  930.  
  931.  
  932. // Found Feature
  933. foundFeature = true;
  934. }
  935. }
  936. }
  937.  
  938.  
  939.  
  940. // Send
  941. DisplayMenu(featurelist, param1, MENU_TIME_FOREVER);
  942. }
  943. }
  944. }
  945. }
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952. // Choose a level, now show features for this level
  953. public panellib_FeatureListHandler(Handle:menu, MenuAction:action, param1, param2)
  954. {
  955. // Selected and valid client
  956. if (action == MenuAction_Select && clientlib_isValidClient(param1))
  957. {
  958. decl String:Chooseit[10];
  959. decl String:featuretext[128];
  960. decl String:arrayItem[128];
  961.  
  962. GetMenuItem(menu, param2, Chooseit, sizeof(Chooseit));
  963.  
  964.  
  965.  
  966. // Get level
  967. new id = StringToInt(Chooseit);
  968. new Handle:featurelist = CreateMenu(panellib_FeatureHandler);
  969.  
  970. SetMenuTitle(featurelist, "%T", "HaveFeatures", param1);
  971. SetMenuExitBackButton(featurelist, true);
  972.  
  973.  
  974. // Loop through all features
  975. for (new i=0; i < g_iFeatures; i++)
  976. {
  977. // Only enabled ones
  978. if (g_FeatureList[i][FEATURE_ENABLE])
  979. {
  980. for (new k=0; k < g_FeatureList[i][FEATURE_BLOCKS]; k++)
  981. {
  982. if (g_FeatureList[i][FEATURE_LEVEL][k] != id)
  983. {
  984. continue;
  985. }
  986.  
  987.  
  988. new Handle:hArray = nativelib_RequestFeature(g_FeatureList[i][FEATURE_HANDLE], param1, k+1);
  989.  
  990.  
  991. if (hArray == INVALID_HANDLE)
  992. {
  993. continue;
  994. }
  995.  
  996.  
  997. if (GetArraySize(hArray) <= 0)
  998. {
  999. CloseHandle(hArray);
  1000.  
  1001. continue;
  1002. }
  1003.  
  1004.  
  1005. // Loop through all descriptions on this level
  1006. for (new j=0; j < GetArraySize(hArray); j++)
  1007. {
  1008. GetArrayString(hArray, j, arrayItem, sizeof(arrayItem));
  1009.  
  1010. // Add text
  1011. Format(featuretext, sizeof(featuretext), "%s", arrayItem);
  1012.  
  1013. AddMenuItem(featurelist, "", featuretext, ITEMDRAW_DISABLED);
  1014. }
  1015.  
  1016.  
  1017. CloseHandle(hArray);
  1018. }
  1019. }
  1020. }
  1021.  
  1022.  
  1023.  
  1024. // Display menu
  1025. DisplayMenu(featurelist, param1, MENU_TIME_FOREVER);
  1026. }
  1027.  
  1028. else if (action == MenuAction_Cancel)
  1029. {
  1030. // Go back
  1031. if (param2 == MenuCancel_ExitBack && clientlib_isValidClient(param1))
  1032. {
  1033. SendPanelToClient(panellib_createInfoPanel(param1), param1, panellib_InfoHandler, 40);
  1034. }
  1035. }
  1036.  
  1037.  
  1038. // Close
  1039. if (action == MenuAction_End)
  1040. {
  1041. CloseHandle(menu);
  1042. }
  1043. }
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051. // Admin menu handler
  1052. public panellib_AdminHandler(Handle:menu, MenuAction:action, param1, param2)
  1053. {
  1054. if (action == MenuAction_Select)
  1055. {
  1056. // Valid client
  1057. if (clientlib_isValidClient(param1))
  1058. {
  1059. decl String:Chooseit[128];
  1060.  
  1061. new Handle:playerlist;
  1062. new Handle:featurelist;
  1063.  
  1064. // Choose a player
  1065. Format(Chooseit, sizeof(Chooseit), "%T", "ChoosePlayer", param1);
  1066.  
  1067.  
  1068.  
  1069. // Delete or add points
  1070. if (param2 == 1)
  1071. {
  1072. playerlist = CreateMenu(panellib_PlayerListHandler);
  1073. }
  1074. else if (param2 == 2)
  1075. {
  1076. playerlist = CreateMenu(panellib_PlayerListHandlerDelete);
  1077. }
  1078.  
  1079.  
  1080. // delete or add points
  1081. if (param2 == 1 || param2 == 2)
  1082. {
  1083. decl String:clientname[MAX_NAME_LENGTH + 1];
  1084. decl String:clientString[6];
  1085.  
  1086. SetMenuTitle(playerlist, Chooseit);
  1087.  
  1088. // Client loop
  1089. for (new i = 1; i <= MaxClients; i++)
  1090. {
  1091. // Check valid
  1092. if (clientlib_isValidClient(i) && CanUserTarget(param1, i) && !IsClientInKickQueue(i))
  1093. {
  1094. // Add client
  1095. Format(clientString, sizeof(clientString), "%i", i);
  1096.  
  1097. GetClientName(i, clientname, sizeof(clientname));
  1098.  
  1099. AddMenuItem(playerlist, clientString, clientname);
  1100. }
  1101. }
  1102.  
  1103. // Display
  1104. DisplayMenu(playerlist, param1, 30);
  1105. }
  1106.  
  1107.  
  1108. // Start happy hour
  1109. if (param2 == 3)
  1110. {
  1111. // Only when not running
  1112. if (!g_bHappyHourON)
  1113. {
  1114. otherlib_MakeHappyHour(param1);
  1115. }
  1116.  
  1117. else if (g_bHappyHourON)
  1118. {
  1119. if (!g_bMoreColors)
  1120. {
  1121. CPrintToChat(param1, "%s %t", g_sStammTag, "HappyRunning");
  1122. }
  1123. else
  1124. {
  1125. MCPrintToChat(param1, "%s %t", g_sStammTag, "HappyRunning");
  1126. }
  1127.  
  1128. panellib_CreateUserPanels(param1, 4);
  1129. }
  1130. }
  1131.  
  1132.  
  1133.  
  1134. // stopp happy hour
  1135. if (param2 == 4)
  1136. {
  1137. // Only if running
  1138. if (g_bHappyHourON)
  1139. {
  1140. otherlib_EndHappyHour();
  1141. }
  1142.  
  1143. else if (!g_bHappyHourON)
  1144. {
  1145. if (!g_bMoreColors)
  1146. {
  1147. CPrintToChat(param1, "%s %t", g_sStammTag, "HappyNotRunning");
  1148. }
  1149. else
  1150. {
  1151. MCPrintToChat(param1, "%s %t", g_sStammTag, "HappyNotRunning");
  1152. }
  1153. }
  1154.  
  1155. panellib_CreateUserPanels(param1, 4);
  1156. }
  1157.  
  1158.  
  1159.  
  1160. // Load or unload feature
  1161. if (param2 == 5 || param2 == 6)
  1162. {
  1163. decl String:itemString[12];
  1164.  
  1165. new bool:found = false;
  1166.  
  1167. // Load
  1168. if (param2 == 5)
  1169. {
  1170. featurelist = CreateMenu(panellib_FeaturelistLoadHandler);
  1171. }
  1172.  
  1173. // Unload
  1174. if (param2 == 6)
  1175. {
  1176. featurelist = CreateMenu(panellib_FeaturelistUnloadHandler);
  1177. }
  1178.  
  1179.  
  1180.  
  1181. Format(Chooseit, sizeof(Chooseit), "%T", "ChooseFeature", param1);
  1182. SetMenuTitle(featurelist, Chooseit);
  1183.  
  1184.  
  1185.  
  1186. // Feature loop
  1187. for (new i=0; i < g_iFeatures; i++)
  1188. {
  1189. // Check enable or disabled
  1190. if ((!g_FeatureList[i][FEATURE_ENABLE] && param2 == 5) || (g_FeatureList[i][FEATURE_ENABLE] && param2 == 6))
  1191. {
  1192. // ADD
  1193. Format(itemString, sizeof(itemString), "%i", i);
  1194. AddMenuItem(featurelist, itemString, g_FeatureList[i][FEATURE_NAME]);
  1195.  
  1196.  
  1197. // Check found
  1198. found = true;
  1199. }
  1200. }
  1201.  
  1202.  
  1203.  
  1204. // If found open
  1205. if (found)
  1206. {
  1207. DisplayMenu(featurelist, param1, MENU_TIME_FOREVER);
  1208. }
  1209. else
  1210. {
  1211. if (!g_bMoreColors)
  1212. {
  1213. CPrintToChat(param1, "%s %t", g_sStammTag, "NoFeatureFound");
  1214. }
  1215. else
  1216. {
  1217. MCPrintToChat(param1, "%s %t", g_sStammTag, "NoFeatureFound");
  1218. }
  1219.  
  1220. panellib_CreateUserPanels(param1, 4);
  1221. }
  1222. }
  1223. }
  1224. }
  1225.  
  1226. // Close
  1227. if (action == MenuAction_End)
  1228. {
  1229. CloseHandle(menu);
  1230. }
  1231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement