16
Программирование / Re: lualoader как modloader, только для GTA vc на основе SDK Plugin DK
« : Ноябрь 11, 2019, 10:11:45 am »Цитировать
как работает скриптовая команда Command<COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_STRING>(0,"R_TIME", 1);Посмотрел как устроен опкод и класс COnscreenTimer. Пример работы с таймерами:
Код: C++
- #include "plugin.h"
- #include "extensions\KeyCheck.h"
- #include "CUserDisplay.h"
- int &var_$3402 = *(int *)0x8247A8;
- using namespace plugin;
- class Test {
- public:
- static int timer;
- enum eTimerState { STATE_ADD, STATE_CLEAR };
- static eTimerState m_currentState;
- Test() {
- Events::drawingEvent += [] {
- gamefont::Print({
- Format("id %d", CUserDisplay::OnscnTimer.m_aClocks[0].m_nVarId),
- Format("direction %d", CUserDisplay::OnscnTimer.m_aClocks[0].m_nTimerDirection),
- Format("enabled %d", CUserDisplay::OnscnTimer.m_aClocks[0].m_bEnabled),
- Format("text %s", CUserDisplay::OnscnTimer.m_aClocks[0].m_acDisplayedText),
- Format("key %s", &CUserDisplay::OnscnTimer.m_aClocks[0].m_acDescriptionTextKey),
- Format("var $3402 %d", var_$3402)
- }, 10, 10, 1, FONT_DEFAULT, 0.75f, 0.75f, color::White);
- KeyCheck::Update();
- switch (m_currentState) {
- case STATE_ADD:
- if (!CUserDisplay::OnscnTimer.m_aClocks[0].m_bEnabled) {
- if (KeyCheck::CheckWithDelay('M', 1000)) {
- var_$3402 = 120000; //in CLEO $3402 = 120000
- CUserDisplay::OnscnTimer.AddClock(timer, "R_TIME", 1); //03C3: set_timer_with_text_to $3402 type 1 text 'R_TIME'
- m_currentState = STATE_CLEAR;
- }
- if (KeyCheck::CheckWithDelay('U', 1000)) {
- CUserDisplay::OnscnTimer.AddClock(timer, "R_TIME", 0); //03C3: set_timer_with_text_to $3402 type 0 text 'R_TIME'
- m_currentState = STATE_CLEAR;
- }
- }
- break;
- case STATE_CLEAR:
- if (KeyCheck::CheckWithDelay('N', 1000) || var_$3402 > 121000 || var_$3402 < 1) {
- CUserDisplay::OnscnTimer.ClearClock(timer); //014F: stop_timer $3402
- var_$3402 = 0; //$3402 = 0
- m_currentState = STATE_ADD;
- }
- break;
- }
- };
- }
- } test;
- int Test::timer = 13608;
- Test::eTimerState Test::m_currentState = STATE_ADD;