#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();
int time = -1;
void CALLBACK Weather(std::string param)
{
char weatherstring[128];
if (param.empty())
return;
sscanf(param.c_str(), "%d", 0xC81320);
SF->Log("{00FF00}ID погоды был изменен на {FFFFFF}%s", param.c_str());
}
void CALLBACK Time(std::string param)
{
if (param.empty())
return;
time = std::stoi(param);
if (time > 23 || time < 0)
{
time = -1;
SF->Log("{FF0000}Значение должно быть не больше 23 и не мешьше 0.");
return;
}
else
{
SF->Log("{00FF00}Время было изменено на {FFFFFF}%d {00FF00}часов.", time);
}
}
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;
SF->registerConsoleCommand("setweather", Weather);
SF->getSAMP()->registerChatCommand("setweather", Weather);
SF->registerConsoleCommand("settime", Time);
SF->getSAMP()->registerChatCommand("settime", Time);
init = true;
}
if (time > -1)
SF->getCLEO()->callOpcode("00C0: %d 0", time);
}
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;
}