Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- public Plugin:myinfo = {
- name = "Custom Mission Changer",
- author = "lxndr",
- description = "Allows players to choose custom campaign",
- version = "1.1"
- }
- public OnPluginStart ()
- {
- RegConsoleCmd ("sm_mission", Command_Mission);
- }
- public Action:Command_Mission (client, args)
- {
- new Handle:menu = CreateMenu (Menu_MapList);
- SetMenuTitle (menu, "Choose campaign");
- decl String:path[PLATFORM_MAX_PATH];
- BuildPath (Path_SM, path, sizeof (path), "configs/missions.cfg");
- new Handle:kv = CreateKeyValues ("Custom Missions");
- if (FileToKeyValues (kv, path)) {
- if (KvGotoFirstSubKey (kv)) {
- decl String:id[64], String:title[64];
- do {
- KvGetSectionName (kv, id, sizeof (id));
- KvGetString (kv, "title", title, sizeof (title));
- AddMenuItem (menu, id, title);
- } while (KvGotoNextKey (kv));
- }
- DisplayMenu (menu, client, 20);
- } else {
- LogError ("Failed to load '%s'", path);
- }
- CloseHandle (kv);
- return Plugin_Handled;
- }
- public Menu_MapList (Handle:menu, MenuAction:action, client, param)
- {
- if (action == MenuAction_Select) {
- decl String:id[64];
- GetMenuItem (menu, param, id, sizeof (id));
- FakeClientCommand (client, "callvote ChangeMission %s", id);
- } else if (action == MenuAction_End) {
- CloseHandle (menu);
- }
- }
Add Comment
Please, Sign In to add comment