SourceMod 僵尸插件:创建并显示菜单 日期: 2024-12-20 标签: 常规 {"title": "#include \n#include \n \nTopMenu TMenu = null;\nTopMenuObject Menu1;\n \npublic Plugin myinfo =\n{\n\tname = "ZombiePlugin",\n\tauthor = "xxk",\n\tdescription = "ZombiePlugin",\n\tversion = "1.0",\n\turl = "http://www.sourcemod.net/"\n};\n \n \n void ZombieMenuProc(TopMenu topmenu, TopMenuAction action, TopMenuObject topobj_id, int param, char[] buffer, int maxlength)\n{\n\t/switch(action)\n\t{\n\t\tcase TopMenuAction_DisplayOption:;\n\t\tcase TopMenuAction_DisplayTitle:;\n\t\tcase TopMenuAction_SelectOption:;\n\t\tcase TopMenuAction_DrawOption:;\n\t\tcase TopMenuAction_RemoveObject:;\n\t}/\n}\n \n\npublic void OnPluginStart()\n{\n\tLoadTranslations("ZombieMenu.phrases");\n\tRegConsoleCmd("zmenu", ZombieMenu);\n}\n\n\npublic void OnAllPluginsLoaded()\n{\n\tTMenu = new TopMenu(ZombieMenuProc);\n\tMenu1 = TMenu.AddItem("AA",ZombieMenuProc,TMenu,"sm_admin");\n//\tTMenu2 = TMenu.AddItem("bb",ZombieMenuProc,TMenu);\n\tif(Menu1 == INVALID_TOPMENUOBJECT)\n\t\tPrintToServer("Menu Load Fail!");\n}\n\n\npublic bool OnClientConnect(int client, char[] rejectmsg, int maxlen)\n{\n\tif(GetClientCount()>=MaxClients)\n\t{\n\t\tstrcopy(rejectmsg,maxlen,"服务器拒绝了你的连接!");\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n\npublic void OnClientConnected(int client) //当客户端成功连接时\n{\n\tchar name[255];\n\tif(GetClientName(client,name,255))\n\t{\n\t\tif(IsClientReplay(client))\n\t\t{\n\t\t\tPrintToChatAll("%s 已经连接服务器!",name);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tPrintToChatAll("%s 已经连接服务器!",name);\n\t\t}\n\t}\n\t\n}\n\n\npublic void OnClientDisconnect(int client) //当客户端断开连接时\n{\n\n}\n\n \npublic int ZombieMenuHandle(Menu menu, MenuAction action, int param1, int param2)\n{\n\t/* If an option was selected, tell the client about the item. /\n\tif (action == MenuAction_Select)\n\t{\n\t\tchar info[32];\n\t\tbool found = menu.GetItem(param2, info, sizeof(info));\n\t\tPrintToConsole(param1, "You selected item: %d (found? %d info: %s)", param2, found, info);\n\t}\n\t/ If the menu was cancelled, print a message to the server about it. /\n\telse if (action == MenuAction_Cancel)\n\t{\n\t\tPrintToServer("Client %d's menu was cancelled. Reason: %d", param1, param2);\n\t}\n\t/ If the menu has ended, destroy it */\n\telse if (action == MenuAction_End)\n\t{\n\t\tdelete menu;\n\t}\n\treturn 0;\n}\n\n \npublic Action ZombieMenu(int client, int args)\n{\n\tif(!TMenu.Display(client,TopMenuPosition_Center))\n\t\tReplyToCommand(client,"[K] 菜单显示失败!");\n\treturn Plugin_Handled;\n}\n\n\npublic void OnConfigsExecuted()\n{\n\tchar path[PLATFORM_MAX_PATH];\n\tchar Err[255];\n\tBuildPath(Path_SM, path, sizeof(path), "cfg/ZombieMenu.cfg");\n\tTMenu.LoadConfig(path,Err,255);\n} 原文地址: https://www.cveoy.top/t/topic/oJq8 著作权归作者所有。请勿转载和采集! 免费AI点我,无需注册和登录