This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
YimMenu/BigBaseV2/src/backend/looped/system/update_player_structs.cpp

60 lines
1.2 KiB
C++
Raw Normal View History

2021-05-26 13:17:19 +02:00
#include "backend/looped/looped.hpp"
#include "natives.hpp"
#include "pointers.hpp"
2021-05-26 13:17:19 +02:00
#include "script.hpp"
#include "util/notify.hpp"
2021-05-26 13:17:19 +02:00
namespace big
{
static bool busy = false;
void looped::system_update_players()
{
if (busy) return;
busy = true;
for (Player i = 0; i < 32; i++)
{
CPlayer& player = g.players[i];
if (NETWORK::NETWORK_IS_PLAYER_ACTIVE(i))
2021-05-26 13:17:19 +02:00
{
strcpy(g.players[i].name, PLAYER::GET_PLAYER_NAME(i));
player.net_player = g_pointers->m_get_net_game_player(i);
if (player.is_online)
continue;
2021-05-26 13:17:19 +02:00
player.id = i;
player.is_online = true;
2021-05-26 13:17:19 +02:00
int iNetworkHandle[26];
NETWORK::NETWORK_HANDLE_FROM_PLAYER(i, &iNetworkHandle[0], 13);
bool is_friend = NETWORK::NETWORK_IS_HANDLE_VALID(&iNetworkHandle[0], 13) && NETWORK::NETWORK_IS_FRIEND(&iNetworkHandle[0]);
2021-05-26 13:17:19 +02:00
if (is_friend)
2021-07-23 18:06:33 +02:00
{
player.is_friend = true;
2021-07-23 18:06:33 +02:00
g.friend_count++;
2021-07-23 18:06:33 +02:00
}
else g.player_count++;
2021-05-26 13:17:19 +02:00
notify::player_joined(player);
2021-05-26 13:17:19 +02:00
}
else if (player.is_online)
2021-05-26 13:17:19 +02:00
{
if (player.is_friend) g.friend_count--;
else g.player_count--;
player.is_friend = false;
player.is_online = false;
2021-05-26 13:17:19 +02:00
}
script::get_current()->yield();
}
busy = false;
}
}