diff --git a/BigBaseV2/src/features/looped/god_mode.cpp b/BigBaseV2/src/features/looped/god_mode.cpp index b5762227..4b8484ec 100644 --- a/BigBaseV2/src/features/looped/god_mode.cpp +++ b/BigBaseV2/src/features/looped/god_mode.cpp @@ -12,7 +12,7 @@ namespace big { QUEUE_JOB_BEGIN_CLAUSE(= ) { - ENTITY::SET_ENTITY_INVINCIBLE(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(PLAYER::PLAYER_ID()), bGodMode); + ENTITY::SET_ENTITY_INVINCIBLE(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), bGodMode); }QUEUE_JOB_END_CLAUSE bLastGodMode = bGodMode; diff --git a/BigBaseV2/src/features/looped/spectate_player.cpp b/BigBaseV2/src/features/looped/spectate_player.cpp index 7760ce20..a4520661 100644 --- a/BigBaseV2/src/features/looped/spectate_player.cpp +++ b/BigBaseV2/src/features/looped/spectate_player.cpp @@ -5,7 +5,7 @@ namespace big { void features::spectate_player() { - if (g_selectedPlayer == -1 || !g_players[g_selectedPlayer].is_online || !g_temp.spectate_player) + if (g_selectedPlayerId == -1 || !g_selectedPlayer.is_online || !g_temp.spectate_player) { if (g_temp.spectate_player) g_temp.spectate_player = false; @@ -14,6 +14,6 @@ namespace big return; } - g_pointers->m_spectate_player(true, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer)); + g_pointers->m_spectate_player(true, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayerId)); } } \ No newline at end of file diff --git a/BigBaseV2/src/features/looped/update_player_structs.cpp b/BigBaseV2/src/features/looped/update_player_structs.cpp index 0600dac0..b3ff00cd 100644 --- a/BigBaseV2/src/features/looped/update_player_structs.cpp +++ b/BigBaseV2/src/features/looped/update_player_structs.cpp @@ -1,35 +1,51 @@ +#include #include "features.hpp" namespace big { + static bool busy = false; + void features::update_player_structs() { - QUEUE_JOB_BEGIN_CLAUSE(= ) + if (busy) return; + + QUEUE_JOB_BEGIN_CLAUSE() { - for (UINT16 i = 0; i < 32; i++) + busy = true; + player players[32]; + + for (uint8_t i = 0; i < 32; i++) { if (NETWORK::NETWORK_IS_PLAYER_CONNECTED(i)) { - if (!g_players[i].is_online) features::join_message((Player)i); + // if (!g_players[i].is_online) features::join_message((Player)i); - g_players[i].is_online = true; + players[i].id = i; + players[i].is_online = true; int iNetworkHandle[26]; NETWORK::NETWORK_HANDLE_FROM_PLAYER(i, &iNetworkHandle[0], 13); NETWORK::NETWORK_IS_HANDLE_VALID(&iNetworkHandle[0], 13) && NETWORK::NETWORK_IS_FRIEND(&iNetworkHandle[0]); - g_players[i].is_friend = NETWORK::NETWORK_IS_HANDLE_VALID(iNetworkHandle, 13) && NETWORK::NETWORK_IS_FRIEND(iNetworkHandle); + players[i].is_friend = NETWORK::NETWORK_IS_HANDLE_VALID(iNetworkHandle, 13) && NETWORK::NETWORK_IS_FRIEND(iNetworkHandle); - strcpy(g_players[i].name, PLAYER::GET_PLAYER_NAME(i)); + strcpy(players[i].name, PLAYER::GET_PLAYER_NAME(i)); } else { - g_players[i].is_online = false; - g_players[i].is_friend = false; + players[i].is_online = false; + players[i].is_friend = false; } script::get_current()->yield(); } + + std::sort(std::begin(players), std::end(players)); + + for (uint8_t i = 0; i < 32; i++) + g_players[i] = players[i]; + + busy = false; }QUEUE_JOB_END_CLAUSE } } \ No newline at end of file diff --git a/BigBaseV2/src/gui/player_window.cpp b/BigBaseV2/src/gui/player_window.cpp index 3c571e8f..be6fcb05 100644 --- a/BigBaseV2/src/gui/player_window.cpp +++ b/BigBaseV2/src/gui/player_window.cpp @@ -7,24 +7,16 @@ namespace big { void gui::render_player_window() { - if (g_selectedPlayer == -1) return; - - player player = g_players[g_selectedPlayer]; - if (!player.is_online) - { - g_selectedPlayer = -1; - - return; - } + if (g_selectedPlayer.id != g_selectedPlayerId || !g_selectedPlayer.is_online) return; if (ImGui::Begin("Player Options")) { ImGui::Text("Selected player:"); - ImGui::SameLine(); ImGui::TextColored({ 25,180,38,255 }, player.name); + ImGui::SameLine(); ImGui::TextColored({ 25,180,38,255 }, g_selectedPlayer.name); if (ImGui::Button("Close")) { - g_selectedPlayer = -1; + g_selectedPlayerId = -2; } ImGui::Separator(); @@ -38,7 +30,7 @@ namespace big { QUEUE_JOB_BEGIN_CLAUSE() { - features::teleport::teleport_to_player(g_selectedPlayer); + features::teleport::teleport_to_player(g_selectedPlayer.id); }QUEUE_JOB_END_CLAUSE } @@ -46,7 +38,7 @@ namespace big { QUEUE_JOB_BEGIN_CLAUSE() { - features::teleport::teleport_into_player_vehicle(g_selectedPlayer); + features::teleport::teleport_into_player_vehicle(g_selectedPlayer.id); }QUEUE_JOB_END_CLAUSE } @@ -58,7 +50,7 @@ namespace big { if (NETWORK::NETWORK_IS_HOST()) { - NETWORK::NETWORK_SESSION_KICK_PLAYER(g_selectedPlayer); + NETWORK::NETWORK_SESSION_KICK_PLAYER(g_selectedPlayer.id); } else { @@ -69,18 +61,18 @@ namespace big if (ImGui::Button("Kick (Non-Host)")) { - uint64_t args[4] = { 1317868303, (uint64_t)PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer), 0, 0 }; + uint64_t args[4] = { 1317868303, (uint64_t)PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer.id), 0, 0 }; - g_pointers->m_trigger_script_event(1, args, 4, 1 << g_selectedPlayer); + g_pointers->m_trigger_script_event(1, args, 4, 1 << g_selectedPlayer.id); } if (ImGui::Button("Kick from Vehicle")) { QUEUE_JOB_BEGIN_CLAUSE() { - uint64_t args[2] = { -1333236192, (uint64_t)g_selectedPlayer }; + uint64_t args[2] = { -1333236192, (uint64_t)g_selectedPlayer.id }; - g_pointers->m_trigger_script_event(1, args, 2, 1 << g_selectedPlayer); + g_pointers->m_trigger_script_event(1, args, 2, 1 << g_selectedPlayer.id); }QUEUE_JOB_END_CLAUSE } @@ -88,9 +80,9 @@ namespace big { QUEUE_JOB_BEGIN_CLAUSE() { - uint64_t ceokick[4] = { -1648921703, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer), 0, 0 }; + uint64_t ceokick[4] = { -1648921703, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer.id), 0, 0 }; - g_pointers->m_trigger_script_event(1, ceokick, 4, 1 << g_selectedPlayer); + g_pointers->m_trigger_script_event(1, ceokick, 4, 1 << g_selectedPlayer.id); }QUEUE_JOB_END_CLAUSE } @@ -98,9 +90,9 @@ namespace big { QUEUE_JOB_BEGIN_CLAUSE() { - uint64_t ceoban[4] = { -738295409, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer), 1, 5 }; + uint64_t ceoban[4] = { -738295409, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer.id), 1, 5 }; - g_pointers->m_trigger_script_event(1, ceoban, 4, 1 << g_selectedPlayer); + g_pointers->m_trigger_script_event(1, ceoban, 4, 1 << g_selectedPlayer.id); }QUEUE_JOB_END_CLAUSE } @@ -108,9 +100,9 @@ namespace big { QUEUE_JOB_BEGIN_CLAUSE() { - uint64_t args[2] = { -545396442, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer) }; + uint64_t args[2] = { -545396442, PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer.id) }; - g_pointers->m_trigger_script_event(true, args, 2, 1 << g_selectedPlayer); + g_pointers->m_trigger_script_event(true, args, 2, 1 << g_selectedPlayer.id); }QUEUE_JOB_END_CLAUSE } @@ -132,8 +124,8 @@ namespace big { QUEUE_JOB_BEGIN_CLAUSE() { - uint64_t args[9] = { -171207973, g_selectedPlayer, 1, -1, 1, location_ids[g_temp.teleport_location], 0,0,0 }; // 1097312011 - g_pointers->m_trigger_script_event(1, args, 9, 1 << g_selectedPlayer); + uint64_t args[9] = { -171207973, g_selectedPlayer.id, 1, -1, 1, location_ids[g_temp.teleport_location], 0,0,0 }; // 1097312011 + g_pointers->m_trigger_script_event(1, args, 9, 1 << g_selectedPlayer.id); }QUEUE_JOB_END_CLAUSE } @@ -143,7 +135,7 @@ namespace big { QUEUE_JOB_BEGIN_CLAUSE() { - Vector3 coords = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer), true); + Vector3 coords = ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_selectedPlayer.id), true); OBJECT::CREATE_AMBIENT_PICKUP(0x1E9A99F8, coords.x, coords.y, coords.z + 0.5f, 0, rand() % 500 + 2000, (Hash)-1666779307, false, true); STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED((Hash)-1666779307); diff --git a/BigBaseV2/src/gui/user_sidebar.cpp b/BigBaseV2/src/gui/user_sidebar.cpp index 98cd5212..2ef052df 100644 --- a/BigBaseV2/src/gui/user_sidebar.cpp +++ b/BigBaseV2/src/gui/user_sidebar.cpp @@ -14,9 +14,16 @@ namespace big ImGui::TextColored({ 255,255,255,255 }, "YOU:"); - if (ImGui::Button(g_players[g_playerId].name, vecButtonWidth)) + for (uint8_t i = 0; i < 32; i++) { - g_selectedPlayer = g_playerId; + player player = g_players[i]; + + if (player.id == g_playerId) g_currentPlayer = player; + } + if (ImGui::Button(g_currentPlayer.name, vecButtonWidth)) + { + g_selectedPlayer = g_currentPlayer; + g_selectedPlayerId = g_currentPlayer.id; } ImGui::Separator(); @@ -35,7 +42,8 @@ namespace big if (ImGui::Button(player.name, vecButtonWidth)) { - g_selectedPlayer = i; + g_selectedPlayer = player; + g_selectedPlayerId = player.id; } } } @@ -55,11 +63,12 @@ namespace big { player player = g_players[i]; - if (!player.is_friend && player.is_online && i != g_playerId) + if (!player.is_friend && player.is_online && player.id != g_playerId) { if (ImGui::Button(player.name, vecButtonWidth)) { - g_selectedPlayer = i; + g_selectedPlayer = player; + g_selectedPlayerId = player.id; } } } diff --git a/BigBaseV2/src/structs/player.hpp b/BigBaseV2/src/structs/player.hpp index 39579838..776616d8 100644 --- a/BigBaseV2/src/structs/player.hpp +++ b/BigBaseV2/src/structs/player.hpp @@ -4,8 +4,23 @@ namespace big { struct player { + Player id = -1; + char name[64] = ""; bool is_friend = false; bool is_online = false; + + bool operator < (const player& another) const + { + char temp[64], temp2[64]; + + for (uint8_t i = 0; i < 64; i++) + { + temp[i] = tolower(this->name[i]); + temp2[i] = tolower(another.name[i]); + } + + return strcmp(temp, temp2) < 0; + } }; } \ No newline at end of file