Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string BlackLists::BlackListName = "";
- std::string BlackLists::BlackListActions = "Crash";
- int persist_BlackList::BlackListpersist()
- {
- persist_BlackList::save_location2(BlackLists::BlackListName);
- return 0;
- }
- int arraysize = 0;
- int lastarray = 0;
- int arrayfind = 0;
- bool arraychange = 0;
- int changedarray()
- {
- if (arraychange)
- {
- if (lastarray < arraysize)
- {
- arrayfind = lastarray + 1;
- lastarray = arrayfind;
- arraychange = 0;
- }
- else if (lastarray = arraysize)
- {
- arrayfind = 0;
- lastarray = arrayfind;
- arraychange = 0;
- }
- }
- return 0;
- }
- std::string menuarray = "";
- int intarrayi = 0;
- bool persist_BlackList::boolautolistaction = 0;
- int persist_BlackList::autolistaction()
- {
- if (persist_BlackList::boolautolistaction)
- {
- DWORD ticks = GetTickCount64();
- DWORD milliseconds = ticks % 1000;
- ticks /= 1000;
- DWORD seconds = ticks % 60;
- int getTimer = seconds;
- if (getTimer % 10 == 0)
- {
- auto BlackList_locations = persist_BlackList::list_locations2();
- static std::string selected_BlackList2;
- std::vector<char*> charVeclist(BlackList_locations.size(), nullptr);
- for (int xi = 0; xi < BlackList_locations.size(); xi++) {
- charVeclist[xi] = &BlackList_locations[xi][0];
- arraysize = xi;
- }
- if (arraysize != 0)
- {
- changedarray();
- std::string stringchar = charVeclist[lastarray];
- for (int i = 0; i < 32; i++) {
- intarrayi = i;
- if (stringchar == PLAYER::GET_PLAYER_NAME(i))
- {
- std::string playerlocations = charVeclist[lastarray];
- persist_BlackList::load_location2(playerlocations);
- }
- if (i == intarrayi)
- {
- arraychange = 1;
- }
- }
- }
- }
- }
- return 0;
- }
- int Crash(std::string name)
- {
- for (int i = 0; i < 33; i++) {
- if (name == PLAYER::GET_PLAYER_NAME(i))
- {
- int Handle = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(i);
- Vector3 coords = ENTITY::GET_ENTITY_COORDS(Handle, 0, 0);
- Hash cage = HASH::GET_HASH_KEY("s_chuckwagonawning01b");
- Features::attachobj[Features::nuattach] = OBJECT::CREATE_OBJECT_NO_OFFSET1(cage, coords.x - Features::objectx, coords.y - Features::objecty, coords.z - Features::objectz, 1, 1, 0);
- if (ENTITY::DOES_ENTITY_EXIST(Features::attachobj[Features::nuattach]))
- {
- ENTITY::ATTACH_ENTITY_TO_ENTITY(Features::attachobj[Features::nuattach], PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(Features::Online::selectedPlayer), SKEL_Head, 0, 5.8f, -1.5, 0, 0, 0, 1, 1, 0, 0, 2, 1, 1, 1);
- }
- ENTITY::SET_ENTITY_VISIBLE(Features::attachobj[Features::nuattach], 1);
- ENTITY::SET_ENTITY_ALPHA(Features::attachobj[Features::nuattach], 255, 0);
- NETWORK::NETWORK_REGISTER_ENTITY_AS_NETWORKED(Features::attachobj[Features::nuattach]);
- NETWORK::_NETWORK_SET_ENTITY_INVISIBLE_TO_NETWORK(Features::attachobj[Features::nuattach], false);
- DWORD id2 = NETWORK::OBJ_TO_NET(Features::attachobj[Features::nuattach]);
- if (NETWORK::NETWORK_DOES_NETWORK_ID_EXIST(id2)) {
- ENTITY::_SET_ENTITY_SOMETHING(Features::attachobj[Features::nuattach], true);
- if (NETWORK::NETWORK_GET_ENTITY_IS_NETWORKED(Features::attachobj[Features::nuattach])) {
- NETWORK::SET_NETWORK_ID_EXISTS_ON_ALL_MACHINES(id2, true);
- NETWORK::_NETWORK_CAN_NETWORK_ID_BE_SEEN(id2);
- }
- }
- STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(cage);
- }
- }
- return 0;
- }
- int Freeze(std::string name)
- {
- for (int i = 0; i < 33; i++) {
- if (name == PLAYER::GET_PLAYER_NAME(i))
- {
- Ped vic = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(i);
- TASK::CLEAR_PED_TASKS_IMMEDIATELY(vic, 0, 0);
- TASK::CLEAR_PED_TASKS(vic, 0, 0);
- TASK::CLEAR_PED_SECONDARY_TASK(vic);
- }
- }
- return 0;
- }
- int persist_BlackList::listaction(std::string name, std::string actions)
- {
- if (actions == "Crash")
- {
- Crash(name);
- }
- if (actions == "Freeze")
- {
- Freeze(name);
- }
- return 0;
- }
- void persist_BlackList::save_location2(std::string name)
- {
- attachmentBlackList::BlackListattachment attachment;
- attachment.BlackListname = BlackLists::BlackListName;
- attachment.BlackListactions = BlackLists::BlackListActions;
- save2(name, attachment);
- }
- void persist_BlackList::load_location2(std::string name)
- {
- auto locations = get_locations_json2();
- if (locations[name].is_null())
- return;
- auto model_attachment = locations[name].get<attachmentBlackList::BlackListattachment>();
- BlackLists::BlackListName = model_attachment.BlackListname;
- BlackLists::BlackListActions = model_attachment.BlackListactions;
- listaction(BlackLists::BlackListName, BlackLists::BlackListActions);
- }
- void persist_BlackList::delete_location2(std::string name)
- {
- auto locations = get_locations_json2();
- if (locations[name].is_null())
- return;
- locations.erase(name);
- save_json2(locations);
- }
- std::vector<std::string> persist_BlackList::list_locations2()
- {
- std::vector<std::string> return_value;
- auto json = get_locations_json2();
- for (auto& item : json.items())
- return_value.push_back(item.key());
- return return_value;
- }
- int Menu2::resultpos32 = 0;
- int Menu2::resultpos42 = 0;
- char* listactions[] = {
- (char*)"Crash",
- (char*)"Freeze",
- };
- std::string BlackLists::BlackListnamesaved;
- void BlackLists::savedBlackList()
- {
- persist_BlackList::BlackListpersist();
- }
- void persist_BlackList::do_presentation_layer2()
- {
- Menu::Toggle("BlackList", persist_BlackList::boolautolistaction);
- BlackLists::BlackListName = PLAYER::GET_PLAYER_NAME(Features::Online::selectedPlayer);
- std::string player = "Player " + BlackLists::BlackListName;
- if (Menu::Option((char*)player.c_str()))
- {
- }
- std::string actions = "Actions " + BlackLists::BlackListActions;
- if (Menu::Option((char*)actions.c_str()))
- {
- }
- for (int i = 0; i < ARRAYSIZE(listactions); i++)
- {
- if (Menu::Option(listactions[i]))
- {
- BlackLists::BlackListActions = listactions[i];
- }
- }
- auto BlackList_locations = list_locations2();
- static std::string selected_BlackList2;
- int xi = 0;
- std::vector<char*> charVec2(BlackList_locations.size(), nullptr);
- for (int i = 0; i < BlackList_locations.size(); i++) {
- charVec2[i] = &BlackList_locations[i][0];
- xi = i;
- }
- if (xi != 0)
- {
- if (Menu2::ListVector("List", charVec2, Menu2::resultpos42)) {
- char* result2 = charVec2[Menu2::resultpos42];
- selected_BlackList2 = result2;
- load_location2(selected_BlackList2);
- }
- }
- if (Menu::Option("Save"))
- {
- BlackLists::savedBlackList();
- }
- if (xi != 0)
- {
- if (Menu::Option("Load"))
- {
- if (!selected_BlackList2.empty())
- {
- load_location2(selected_BlackList2);
- selected_BlackList2.clear();
- }
- }
- if (Menu::Option("Delete"))
- {
- if (!selected_BlackList2.empty())
- {
- delete_location2(selected_BlackList2);
- selected_BlackList2.clear();
- }
- }
- }
- }
- void persist_BlackList::save2(std::string name, attachmentBlackList::BlackListattachment attachment)
- {
- auto json = get_locations_json2();
- json[name] = attachment;
- save_json2(json);
- }
- void persist_BlackList::save_json2(nlohmann::json json)
- {
- auto file_path = get_locations_config2();
- std::ofstream file(file_path, std::ios::out | std::ios::trunc);
- file << json.dump(4);
- file.close();
- }
- nlohmann::json persist_BlackList::get_locations_json2()
- {
- auto file_path = get_locations_config2();
- nlohmann::json locations;
- std::ifstream file(file_path);
- if (!file.fail())
- file >> locations;
- return locations;
- }
- void makeBlackListfolder() {
- string BlackListstring = Directory::get_current_dir() + "\\ThunderMenu\\BlackList\\";
- #include <windows.h>
- std::wstring BlackListwstring = functions::s2ws(BlackListstring);
- LPCWSTR BlackListlpcwstr = BlackListwstring.c_str();
- if (CreateDirectoryW(BlackListlpcwstr, NULL))
- {
- // Directory created
- }
- else if (ERROR_ALREADY_EXISTS == GetLastError())
- {
- // Directory already exists
- }
- else
- {
- // Failed for some other reason
- }
- }
- char BlackListchar[255];
- void BlackLists::BlackListfolder()
- {
- ifstream BlackListstream;
- BlackListstream.open(Directory::get_current_dir() + "\\ThunderMenu\\BlackList\\");
- if (BlackListstream) {
- BlackListstream >> BlackListchar;
- }
- if (!BlackListstream) {
- makeBlackListfolder();
- }
- BlackListstream.close();
- }
- std::string persist_BlackList::get_locations_config2()
- {
- BlackLists::BlackListfolder();
- auto file_path = Directory::get_current_dir();
- file_path += "\\ThunderMenu\\BlackList\\";
- file_path += "TheBlackList.json";
- return file_path;
- }
- namespace BlackLists
- {
- extern std::string BlackListName;
- extern void BlackListfolder();
- extern std::string BlackListnamesaved;
- extern void savedBlackList();
- extern std::string BlackListActions;
- }
- class persist_BlackList
- {
- public:
- static bool boolautolistaction;
- static int autolistaction();
- static int listaction(std::string name, std::string actions);
- static void do_presentation_layer2();
- static int BlackListpersist();
- private:
- static void save_location2(std::string name, std::string action);
- static void save_location2(std::string name);
- static void load_location2(std::string name);
- static void delete_location2(std::string name);
- static std::vector<std::string> list_locations2();
- static void save2(std::string name, attachmentBlackList::BlackListattachment attachment);
- static void save_json2(nlohmann::json json);
- static nlohmann::json get_locations_json2();
- static std::string get_locations_config2();
- /*static std::filesystem::path get_locations_config();*/
- };
- extern void makeBlackListfolder();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement