#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>
#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"
SAMPFUNCS *SF = new SAMPFUNCS();
DWORD carid;
void wait() {
SF->getSAMP()->sendEnterVehicle(carid, 1);
BitStream bs;
bs.ResetWritePointer();
bs.Write(carid); // обязательно DWORD
bs.Write((BYTE)1);
SF->getRakNet()->emulateRecvRPC(ScriptRPCEnumeration::RPC_ScrPutPlayerInVehicle, &bs);
Sleep(500);
BitStream vk;
bs.ResetWritePointer();
SF->getRakNet()->emulateRecvRPC(ScriptRPCEnumeration::RPC_ScrRemovePlayerFromVehicle, &vk);
Sleep(500);
SF->getSAMP()->sendRequestSpawn();
SF->getSAMP()->getPlayers()->pLocalPlayer->Spawn();
}
void CALLBACK cmd(std::string) {
for (carid = 1; carid <= 2000; carid++) {
if (SF->getSAMP()->getVehicles()->iIsListed[carid] != 1) continue;
if (SF->getSAMP()->getVehicles()->iIsListed2[carid] != 1) continue;
if (SF->getSAMP()->getVehicles()->pSAMP_Vehicle[carid] == NULL) continue;
if (SF->getSAMP()->getVehicles()->pSAMP_Vehicle[carid]->pGTA_Vehicle == NULL) continue;
if (SF->getSAMP()->getVehicles()->pSAMP_Vehicle[carid]->pGTA_Vehicle->door_status == 0) {
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)wait, 0, 0, 0);
}
}
void CALLBACK mainloop()
{
static bool init = false;
if (!init) {
if (GAME == nullptr || GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME ||!SF->getSAMP()->IsInitialized() ) return;
SF->getSAMP()->registerChatCommand("uncf", cmd);
init = true;
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
switch (dwReasonForCall)
{
case DLL_PROCESS_ATTACH: SF->initPlugin(mainloop, hModule); break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}