Guest User

Untitled

a guest
Jun 20th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <sourcemod>
  2.  
  3.  
  4. public Plugin:myinfo = {
  5. name = "Custom Mission Changer",
  6. author = "lxndr",
  7. description = "Allows players to choose custom campaign",
  8. version = "1.1"
  9. }
  10.  
  11.  
  12. public OnPluginStart ()
  13. {
  14. RegConsoleCmd ("sm_mission", Command_Mission);
  15. }
  16.  
  17. public Action:Command_Mission (client, args)
  18. {
  19. new Handle:menu = CreateMenu (Menu_MapList);
  20. SetMenuTitle (menu, "Choose campaign");
  21.  
  22. decl String:path[PLATFORM_MAX_PATH];
  23. BuildPath (Path_SM, path, sizeof (path), "configs/missions.cfg");
  24. new Handle:kv = CreateKeyValues ("Custom Missions");
  25. if (FileToKeyValues (kv, path)) {
  26. if (KvGotoFirstSubKey (kv)) {
  27. decl String:id[64], String:title[64];
  28. do {
  29. KvGetSectionName (kv, id, sizeof (id));
  30. KvGetString (kv, "title", title, sizeof (title));
  31. AddMenuItem (menu, id, title);
  32. } while (KvGotoNextKey (kv));
  33. }
  34. DisplayMenu (menu, client, 20);
  35. } else {
  36. LogError ("Failed to load '%s'", path);
  37. }
  38. CloseHandle (kv);
  39.  
  40. return Plugin_Handled;
  41. }
  42.  
  43. public Menu_MapList (Handle:menu, MenuAction:action, client, param)
  44. {
  45. if (action == MenuAction_Select) {
  46. decl String:id[64];
  47. GetMenuItem (menu, param, id, sizeof (id));
  48. FakeClientCommand (client, "callvote ChangeMission %s", id);
  49. } else if (action == MenuAction_End) {
  50. CloseHandle (menu);
  51. }
  52. }
Add Comment
Please, Sign In to add comment