void send_key(byte key)
{
if (SF->getSAMP()->getPlayers()->pLocalPlayer->pSAMP_Actor->pGTA_Ped->state == 50)
{
if (SF->getSAMP()->getPlayers()->pLocalPlayer->pSAMP_Actor->pGTA_Ped->vehicle->passengers[0] == SF->getSAMP()->getPlayers()->pLocalPlayer->pSAMP_Actor->pGTA_Ped)
{
do
{
stInCarData sync = SF->getSAMP()->getPlayers()->pLocalPlayer->inCarData;
sync.byteCurrentWeapon = key;
BitStream bs;
bs.Write((BYTE)ID_VEHICLE_SYNC);
bs.Write((PCHAR)&sync, sizeof(stInCarData));
SF->getRakNet()->SendPacket(&bs);
SF->getSAMP()->getChat()->AddChatMessage(-1, "[INCAR DATA] Отправлена кнопка: %d", key);
key = !key;
} while (!key);
}
else do
{
stPassengerData sync = SF->getSAMP()->getPlayers()->pLocalPlayer->passengerData;
sync.byteCurrentWeapon = key;
BitStream bs;
bs.Write((BYTE)ID_PASSENGER_SYNC);
bs.Write((PCHAR)&sync, sizeof(stPassengerData));
SF->getRakNet()->SendPacket(&bs);
SF->getSAMP()->getChat()->AddChatMessage(-1, "[PASSENGER DATA] Отправлена кнопка: %d", key);
key = !key;
} while (!key);
}
else do
{
stOnFootData sync = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData;
sync.byteCurrentWeapon = key;
BitStream bs;
bs.Write((BYTE)ID_PLAYER_SYNC);
bs.Write((PCHAR)&sync, sizeof(stOnFootData));
SF->getRakNet()->SendPacket(&bs);
SF->getSAMP()->getChat()->AddChatMessage(-1, "[ONFOOT DATA] Отправлена кнопка: %d", key);
key = !key;
} while (!key);
}
void CALLBACK mainloop()
{
static bool init = false;
if (!init)
{
if (GAME == nullptr)
return;
if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
return;
if (!SF->getSAMP()->IsInitialized())
return;
init = true;
}
if (SF->getGame()->isKeyPressed(49)) send_key(128); // 128 - N
}