Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- int iNum = 0;
- char sCharMap[64];
- char sDataFilePath[PLATFORM_MAX_PATH];
- public OnPluginStart()
- {
- RegAdminCmd("sm_boxmenu", BoxRedactor, ADMFLAG_ROOT)
- BuildPath(Path_SM, sDataFilePath, sizeof(sDataFilePath), "data/box_position.ini");
- if (!FileExists(sDataFilePath))
- {
- new Handle:open_path = OpenFile(sDataFilePath, "w");
- WriteFileLine(open_path, "");
- CloseHandle(open_path);
- PrintToServer("Error Code: WSP-EC-01A");
- }
- }
- public OnMapStart()
- {
- iNum = 0;
- GetCurrentMap(sCharMap, sizeof(sCharMap));
- KeyValues kv = new KeyValues("PosionsFake");
- KvRewind(kv);
- if (kv.ImportFromFile(sDataFilePath))
- {
- if (KvJumpToKey(kv, sCharMap, true))
- {
- KeyValuesToFile(kv, sDataFilePath);
- decl Float:fPos[3], String:sBuffer[32];
- while(KvGotoNextKey(kv))
- {
- FormatEx(sBuffer, sizeof(sBuffer), "crate %i", iNum++);
- KvGetVector(kv, sBuffer, fPos);
- if(IsVectorEmpty(fPos))
- {
- break;
- }
- ++iNum;
- }
- }
- }
- }
- bool:IsVectorEmpty(const Float:fPos[3])
- {
- for (new i = 0; i < 3; ++i)
- {
- if(fPos[i])
- {
- return false;
- }
- }
- return true;
- }
- public Action:BoxRedactor(client, args)
- {
- DisplayBoxMenu(client)
- }
- public MenuBox(Handle:menu, MenuAction:action, client, symbol)
- {
- if (action == MenuAction_Select)
- {
- if(symbol == 0)
- {
- DisplayAddBox(client);
- }
- else if(symbol == 1)
- {
- }
- }
- else if (action == MenuAction_End)
- {
- CloseHandle(menu);
- }
- }
- DisplayBoxMenu(client)
- {
- new Handle:menu = CreateMenu(MenuBox);
- SetMenuTitle(menu, "Редактор ящиков:");
- AddMenuItem(menu, "0", "Добавить ящик");
- AddMenuItem(menu, "1", "Убрать");
- DisplayMenu(menu, client, MENU_TIME_FOREVER);
- }
- DisplayAddBox(client)
- {
- new Handle:menu = CreateMenu(MenuAddBox);
- SetMenuTitle(menu, "Добавление ящика:");
- AddMenuItem(menu, "0", "По вашему местоположению.");
- AddMenuItem(menu, "1", "Место, куда направлен ваш прицел.");
- DisplayMenu(menu, client, MENU_TIME_FOREVER);
- }
- public MenuAddBox(Handle:menu, MenuAction:action, client, symbol)
- {
- if (action == MenuAction_Select)
- {
- if(symbol == 0)
- {
- float vPos[3]
- GetClientAbsOrigin(client, vPos);
- KeyValues kv = new KeyValues("PosionsFake");
- if (kv.ImportFromFile(sDataFilePath))
- {
- KvRewind(kv);
- if (KvJumpToKey(kv, sCharMap, true))
- {
- char sBuffer[32];
- FormatEx(sBuffer, sizeof(sBuffer), "crate %i", iNum);
- KvSetVector(kv, sBuffer, vPos)
- DisplayAddBox(client);
- KeyValuesToFile(kv, sDataFilePath);
- }
- }
- }
- else if(symbol == 1)
- {
- }
- }
- else if (action == MenuAction_End)
- {
- CloseHandle(menu);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment