-
Notifications
You must be signed in to change notification settings - Fork 0
/
GTA3_SCRIPT_DUBUGGER.cpp
1959 lines (1602 loc) · 65.7 KB
/
GTA3_SCRIPT_DUBUGGER.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//----BY Âîâà Ïåòðîâ aka Ma-ZaHaKa
#pragma once
#include "Windows.h";
#include <iostream>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
//#include <random>
#include "plugin.h"
#include "CCamera.h"
#include "CHud.h"
#include "CMenuManager.h"
#include "CPed.h"
#include "CTheScripts.h"
#include "CStreaming.h"
#include "CPopulation.h"
#include "CModelInfo.h"
#include "CBoat.h"
#include "CWorld.h"
#include "CPlaceable.h"
#include "CMatrix.h"
#include "CVehicle.h"
#include "CAutomobile.h"
#include <extensions\ScriptCommands.h>
#include "CFont.h"
#include "CWanted.h"
#include "CPlayerPed.h"
#include "CTimer.h"
#include "CSprite.h"
#include "CUserDisplay.h"
#include "CCheat.h"
#include "CTimer.h"
#include "CEntity.h"
#include "CWeapon.h"
#include "CWeaponInfo.h"
#include "CAnimManager.h"
#include "ePedModel.h"
#include "eScriptCommands.h"
#include "eVehicleModel.h"
#include "eAnimations.h" // anims enums
#include "eWeaponModel.h"
#include "ScriptDebug.h"
//#include "eVehicleIndex.h"
//#include "CVehicle.cpp" // f12
//#include "CHud.cpp" // f12 only
using namespace plugin;
//using namespace std;
uintptr_t T_VoidPtr2IntPtr(void* _addr) { return reinterpret_cast<uintptr_t>(_addr); }
void* T_IntPtr2VoidPtr(uintptr_t _addr) { return reinterpret_cast<void*>(_addr); }
char* T_constchar2char(const char* constString) { return const_cast<char*>(constString); }
char* T_string2char(std::string constString) { return const_cast<char*>(constString.c_str()); }
std::string T_Pointer2String(void* pointer) { std::stringstream ss; ss << pointer; return "0x" + ss.str(); }
uintptr_t VoidPtr2IntPtr(void* _addr) { return reinterpret_cast<uintptr_t>(_addr); }
void* IntPtr2VoidPtr(uintptr_t _addr) { return reinterpret_cast<void*>(_addr); }
template <typename T> T ReadPtrDanger(void* ptr) { return *(static_cast<T*>(ptr)); } // 0x80000001 ERROR NO CATCHABLE
template <typename T> void WriteDanger(void* ptr, const T& value) { (*(static_cast<T*>(ptr))) = value; }
//PD_WriteDanger<char>(Transpose((void*)0x12345678, 5), 255);
//inline static void* Transpose(void* addr, intptr_t offset, bool deref = false)
static void* Transpose(void* addr, intptr_t offset, bool deref = false)
{
auto res = (void*)((intptr_t)addr + offset);
return deref ? *(void**)res : res;
}
std::string ToUpper(std::string strToConvert)
{
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), std::toupper); //::toupper
return strToConvert;
}
std::string ToLower(std::string strToConvert)
{
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), std::tolower);
return strToConvert;
}
std::string Trim(std::string str)
{
// Find the first non-whitespace character from the beginning.
size_t start = str.find_first_not_of(" \t\n\r\f\v");
if (start == std::string::npos) {
// If the string consists only of whitespace, return an empty string.
return "";
}
// Find the last non-whitespace character from the end.
size_t end = str.find_last_not_of(" \t\n\r\f\v");
// Calculate the length of the trimmed substring.
size_t length = end - start + 1;
// Extract and return the trimmed substring.
return str.substr(start, length);
}
std::string Replace(std::string input, std::string target, std::string replacement)
{
std::string result = input;
size_t startPos = 0;
while ((startPos = result.find(target, startPos)) != std::string::npos)
{
result.replace(startPos, target.length(), replacement);
startPos += replacement.length();
}
return result;
}
void AsciiToUnicode(const char* src, uint16_t* dst) // wchar
{
while ((*dst++ = (unsigned char)*src++) != '\0');
}
std::string intToHexString(int value, bool ox = true)
{
std::ostringstream stream;
if (ox) { stream << "0x"; }
stream << std::hex << value;// << std::dec;
return stream.str();
}
//----------------------------------------SIMPLE---HANDLER
//void MiniButtonsHandler()
//{
// char action1 = 'T';
// int sleep_val = 10;
// int button_delay = 150;
// char shift = VK_SHIFT;
//
// bool tmp_flag = true;
// while (true)
// {
// //if ((GetAsyncKeyState(shift) & 0x8000) && IS_PLAYER_CHAR_IN_VEHICLE) { ReloadPlayerWeapoon(); Sleep(button_delay); } // reload in car
// if ((GetAsyncKeyState(action1) & 0x8000)) { Sleep(button_delay); }
// Sleep(sleep_val);
// }
//}
//
//
//DWORD CALLBACK HandlersEntry(LPVOID)
//{
// //InitConsole();
// MiniButtonsHandler();
// //Patch1();
// return TRUE;
//}
//
//
//void CreateHandlersThread() { CreateThread(NULL, 0, HandlersEntry, NULL, 0, NULL); }
//
//BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
//{
// if (fdwReason == DLL_PROCESS_ATTACH)
// {
// DisableThreadLibraryCalls(hinstDLL);
// CreateHandlersThread();
// //CreateThread(NULL, 0, Entry, NULL, 0, NULL);
// //main();
// }
// return TRUE; // crash if no return;
//}
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
#define DEFAULT_SCREEN_WIDTH (640)
#define DEFAULT_SCREEN_HEIGHT (480)
#define SCREEN_STRETCH_X(a) ((a) * (float) SCREEN_WIDTH / DEFAULT_SCREEN_WIDTH)
#define SCREEN_STRETCH_Y(a) ((a) * (float) SCREEN_HEIGHT / DEFAULT_SCREEN_HEIGHT)
#define DEFAULT_ASPECT_RATIO (4.0f/3.0f)
#define SCREEN_ASPECT_RATIO (DEFAULT_ASPECT_RATIO)
#define DEFAULT_VIEWWINDOW (0.7f)
#define SCREEN_SCALE_AR(a) ((a) * DEFAULT_ASPECT_RATIO / SCREEN_ASPECT_RATIO)
#define SCREEN_SCALE_X(a) SCREEN_SCALE_AR(SCREEN_STRETCH_X(a))
#define SCREEN_SCALE_Y(a) SCREEN_STRETCH_Y(a)
#define SCREEN_SCALE_FROM_RIGHT(a) (SCREEN_WIDTH - SCREEN_SCALE_X(a))
#define SCREEN_SCALE_FROM_BOTTOM(a) (SCREEN_HEIGHT - SCREEN_SCALE_Y(a))
struct tZonePrint
{
char name[12];
CRect rect;
};
tZonePrint ZonePrint[] =
{
{ "suburban", CRect(-1639.4f, 1014.3f, -226.23f, -1347.9f) },
{ "comntop", CRect(-223.52f, 203.62f, 616.79f, -413.6f) },
{ "comnbtm", CRect(-227.24f, -413.6f, 620.51f, -911.84f) },
{ "comse", CRect(200.35f, -911.84f, 620.51f, -1737.3f) },
{ "comsw", CRect(-223.52f, -911.84f, 200.35f, -1737.3f) },
{ "industsw", CRect(744.05f, -473.0f, 1067.5f, -1331.5f) },
{ "industne", CRect(1067.5f, 282.19f, 1915.3f, -473.0f) },
{ "industnw", CRect(744.05f, 324.95f, 1067.5f, -473.0f) },
{ "industse", CRect(1070.3f, -473.0f, 1918.1f, -1331.5f) },
{ "no zone", CRect(0.0f, 0.0f, 0.0f, 0.0f) }
};
enum {
FONT_BANK,
FONT_PAGER,
FONT_HEADING,
#ifdef MORE_LANGUAGES
FONT_JAPANESE,
#endif
MAX_FONTS
};
//------------------------------------------------------------------
HANDLE InitConsole() // with proto
{
AllocConsole();
//SetConsoleOutputCP(866);
setlocale(LC_ALL, "Russian");
SetConsoleOutputCP(1251);
SetConsoleCP(1251);
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN);
return hConsole;
}
//void LeaveConsole(HANDLE hConsole = nullptr)
void LeaveConsole(HANDLE hConsole) // with proto
{
if (hConsole != nullptr) { SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); } // Reset to default color
FreeConsole();
}
bool CheckPointerBoundsRead(void* pointer) // åñòü ëè òàêîé àäðåñ?
{
if (!pointer) { return false; }
MEMORY_BASIC_INFORMATION memInfo;
if (VirtualQuery(pointer, &memInfo, sizeof(memInfo)) == sizeof(memInfo))
{
//if (memInfo.State == MEM_COMMIT && (memInfo.Type == MEM_PRIVATE || memInfo.Type == MEM_MAPPED)) { return true; } // ORIG!!!
//if ((memInfo.State == MEM_COMMIT) && ((memInfo.Protect & PAGE_READWRITE) || (memInfo.Protect & PAGE_READONLY))) { return true; }
//if ((memInfo.State == MEM_COMMIT) && ((memInfo.Protect & PAGE_READWRITE) || (memInfo.Protect & PAGE_READONLY)) && (memInfo.Type == MEM_PRIVATE || memInfo.Type == MEM_MAPPED)) { return true; }
if (memInfo.State == MEM_COMMIT)
{
if (((memInfo.Protect & PAGE_READONLY) ||
(memInfo.Protect & PAGE_EXECUTE_READ) ||
(memInfo.Protect & PAGE_EXECUTE_WRITECOPY) ||
(memInfo.Protect & PAGE_READWRITE) ||
(memInfo.Protect & PAGE_EXECUTE_READWRITE)) && !(memInfo.Protect & PAGE_GUARD)) // PAGE_GUARD 0x80000001 íåëüçÿ ðàçèìåíîâàòü
{
return true;
}
}
}
return false;
}
template <typename T> bool CheckPointerReadByType(void* ptr) // ìîæåò ëè äàííûé òèï òàì ëåæàòü?
{
int SZ = sizeof(T); // unintptr_t x86 4b, x64 8b
for (int byte_offset = 0; byte_offset < SZ; byte_offset++) // ïðîâåðÿåì àäðåñàöèþ êàæäîãî áàéòà äëÿ T òèïà
{
ptr = Transpose(ptr, byte_offset);
if (!CheckPointerBoundsRead(ptr)) { return false; }
}
return true;
}
bool CheckPointerBoundsWrite(void* pointer) // ðîáèò
{
if (!pointer) { return false; }
MEMORY_BASIC_INFORMATION memInfo;
if (VirtualQuery(pointer, &memInfo, sizeof(memInfo)) == sizeof(memInfo))
{
if (memInfo.State == MEM_COMMIT)
{
if (((memInfo.Protect & PAGE_READWRITE) ||
(memInfo.Protect & PAGE_EXECUTE_READWRITE) ||
(memInfo.Protect & PAGE_EXECUTE_WRITECOPY)) && !(memInfo.Protect & PAGE_GUARD))
{
return true;
}
}
}
return false;
}
template <typename T> bool CheckPointerWriteByType(void* ptr) // ìîæåò ëè äàííûé òèï òàì ëåæàòü?
{
int SZ = sizeof(T); // unintptr_t x86 4b, x64 8b
for (int byte_offset = 0; byte_offset < SZ; byte_offset++) // ïðîâåðÿåì àäðåñàöèþ êàæäîãî áàéòà äëÿ T òèïà
{
ptr = Transpose(ptr, byte_offset);
if (!CheckPointerBoundsWrite(ptr)) { return false; }
}
return true;
}
int GetRegionSizeByPointer(void* ptr)
{
MEMORY_BASIC_INFORMATION mbi;
//if (VirtualQuery(ptr, &mbi, sizeof(mbi)) == 0) { } // err handler
VirtualQuery(ptr, &mbi, sizeof(mbi));
return mbi.RegionSize;
}
void* GetRegionBaseByPointer(void* ptr)
{
MEMORY_BASIC_INFORMATION mbi;
//if (VirtualQuery(ptr, &mbi, sizeof(mbi)) == 0) { } // err handler
VirtualQuery(ptr, &mbi, sizeof(mbi));
return mbi.BaseAddress;
}
MEMORY_BASIC_INFORMATION GetRegionInfoByPointer(void* ptr) // if (mbi.BaseAddress == nullptr) {} err
{
MEMORY_BASIC_INFORMATION mbi;
//if (VirtualQuery(ptr, &mbi, sizeof(mbi)) == 0) { } // err handler
VirtualQuery(ptr, &mbi, sizeof(mbi));
return mbi;
}
int CalcJMPE9Offset(void* op_addr, void* dest_ptr) // ñ÷èòàåò îôñåò äëÿ ïðûæêà jmp. ìîæíî -çíà÷åíèÿ, ïðûãàåò ïî îôñåòó ïîñëå ëàñò áàéòà èíñòðóêöèè, E9 00 00 00 00 + offset
{
uintptr_t op_address = (uintptr_t)op_addr;
uintptr_t dest_address = (uintptr_t)dest_ptr;
int offset = (int)(dest_address - (op_address + 1 + sizeof(uintptr_t))); // -16 fffffff0 jump upper
return offset;
}
// ïåðåíîñèò exec áàéòû â íîâóþ ðàñøèðåííóþ îáëàñòü ÷åðåç jmp
// sz patch redirect x86 5bytes 1 + 4
// OrigPtr óêàçàòåëü íà èíñòðóêöèþ äëÿ õóêà
// OrigSzBlock ðàçìåð áàéòîâ äëÿ ïàò÷à
// PatchSzBlock êîë-âî áàéò äëÿ ïàò÷à ïîìèèî íóæíûõ ïàò÷ó mysz+ret+sz(void*)
// OutPatchPtr âûõîäíîé ïàðàìåòð patch sz (íà ñêîïèðîâàííûé îïêîä)
// OutPatchSzBlock âûäåëåííûé ðàçìåð (áîëüøå ÷åì çàïðàøèâàåìûé)
//jmp_patch_in_end_region false jmp ïîñëå íàøåãî áëîêà PatchSzBlock, true â êîíöå ðåãèîíà
//offset îôôñåò ïåðåíîñà êîäà îò íà÷àëà áëîêà
// !!!!!!!!!!!!!!!!!!!!!!!!!OrigSzBlock ìèíèìóì 5 áàéò, íå èñïîëüçîâàòü ïåðåíîñ êîììàíä mov jz jmp òàê êàê îíè ðàáîòà÷ò ÷åðåç îôôñåò ñâîåãî àäðåñà
// !!!!!!!!!!!!!!!!!!!!!!!!!åñëè þçàåøü mov jz jmp íóæíî ïàò÷èòü èõ îôôñåò
bool SetPatchBlock(void* OrigPtr, int OrigSzBlock, int PatchSzBlock, void*& OutPatchPtr, int& OutPatchSzBlock, bool jmp_patch_in_end_region = false, uintptr_t offset = 0) // !! NO MOVE OFFSETS INSTRUCTIONS (jmp, mov) îíè ðàþîòàþò ïî îôôñåòó èç ñâîåãî àäðåñà
{
MEMORY_BASIC_INFORMATION mbi_orig = GetRegionInfoByPointer(OrigPtr);
if (!mbi_orig.RegionSize) { return false; } // cant find base+sz
if (offset < 0) { return false; }
DWORD oldProtect_orig;
bool orig_protect_ch = false; // ôëàã äëÿ âîçâðàòà îðèãèíàëüíûõ ïðàâ áëîêà
char nop = 0x90;
char jmp = 0xE9; // ïðûæîê ñî ñìåùåíèåì 4áàéòà (opcode addr + sz(0xE9) + sz(offset) + *offset(*(start+sz(opcode))))
uintptr_t jmp_sz = (sizeof(char) + sizeof(void*));
uintptr_t need_block_sz = (OrigSzBlock + PatchSzBlock + jmp_sz); // orig opcode + patch + jmp
bool return_orig_protect = true;
//if (!_CheckPointerReadByType<char>(OrigPtr)) { return; } // no readable
if (!CheckPointerBoundsRead(OrigPtr)) { return false; } // no readable mini optimize
//if (!_CheckPointerWriteByType<char>(OrigPtr)) // cant patch
if (!CheckPointerBoundsWrite(OrigPtr)) // cant patch mini optimize
{
//MEMORY_BASIC_INFORMATION mbi = GetRegionInfoByPointer(originalCodeBlock);
//if (!mbi.RegionSize) { return; } // cant find base+sz
orig_protect_ch = true;
VirtualProtect((LPVOID)mbi_orig.BaseAddress, mbi_orig.RegionSize, PAGE_EXECUTE_READWRITE, &oldProtect_orig);
}
//-------MK PATCH BLOCK
// patched_block_sz ÷èñòî äëÿ âûäåëåíèÿ ïàìÿòè, VirtualAlloc äà¸ò áîëüøå ïàìÿòè
//void* patchBlock = VirtualAlloc(nullptr, need_block_sz, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); //(LPVOID) nullptr => random memory
void* patchBlock = VirtualAlloc(nullptr, need_block_sz, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); //(LPVOID) nullptr => random memory
if (patchBlock == nullptr) { return false; } // cant create memblock 4 patch
MEMORY_BASIC_INFORMATION mbi_patched = GetRegionInfoByPointer(patchBlock);
//DWORD oldProtect_patched; // ìîæíî âûøå óñòàíîâèòü PAGE_EXECUTE_READWRITE â VirtualAlloc
///////VirtualProtect(patchBlock, patched_block_sz, PAGE_EXECUTE_READWRITE, &oldProtect_patched); // PAGE_EXECUTE_READ // !!âûäåëÿåòüñÿ áîëüøå ÷åì çàïðàøèâàåì
//VirtualProtect(patchBlock, mbi_patched.RegionSize, PAGE_EXECUTE_READWRITE, &oldProtect_patched); // PAGE_EXECUTE_READ äëÿ alloc PAGE_READWRITE
//----INIT OUT PARAMS
OutPatchPtr = patchBlock; //OutPatchPtr = mbi_patched.BaseAddress;
OutPatchSzBlock = mbi_patched.RegionSize;
// orig block jmp -> patched block(istruction from orig + my instr) jmp -> orig block
//-------------------------PREPEARE--PATCHED--BLOCK
//memset(buffer, 0, sizeof(buffer));
memset(patchBlock, nop, mbi_patched.RegionSize);
//memset(patchBlock, nop, patched_block_sz);
uintptr_t full_block_sz = jmp_patch_in_end_region ? (mbi_patched.RegionSize - jmp_sz) : (need_block_sz - jmp_sz);
if (offset > (full_block_sz - OrigSzBlock)) { offset = 0; } // ìîæíî îôñåòèòü áîëüøå PatchSzBlock åñëè jmp â êîíöå
//if (offset > (full_block_sz - OrigSzBlock)) { VirtualFree(patchBlock, 0, MEM_RELEASE); return false; } // ìîæíî îôñåòèòü áîëüøå PatchSzBlock åñëè jmp â êîíöå
//if (offset > PatchSzBlock) { offset = 0; } // only patch block. additional not used
std::memcpy(Transpose(patchBlock, offset), OrigPtr, OrigSzBlock); // to from sz OrigSzBlock=6
void* ptr_to_orig_jmp = nullptr;
//---JMP IN END BLOCK !! universal
//ptr_to_orig_jmp = Transpose(patchBlock, (mbi_patched.RegionSize - sizeof(char) - sizeof(void*)));
//---JMP AFTER PATCH SZ !! logical
//ptr_to_orig_jmp = Transpose(patchBlock, (OrigSzBlock + PatchSzBlock));
//---JMP AFTER ORIG OPCODE IN PATCHED BLOCK !! no patching space in patched region
//ptr_to_orig_jmp = Transpose(patchBlock, OrigSzBlock);
if (jmp_patch_in_end_region) { ptr_to_orig_jmp = Transpose(patchBlock, (mbi_patched.RegionSize - jmp_sz)); }
else { ptr_to_orig_jmp = Transpose(patchBlock, (OrigSzBlock + PatchSzBlock)); }
WriteDanger<char>(ptr_to_orig_jmp, jmp); // jmp to orig block
int offset1 = CalcJMPE9Offset(ptr_to_orig_jmp, Transpose(OrigPtr, OrigSzBlock));
WriteDanger<int>(Transpose(ptr_to_orig_jmp, sizeof(char)), offset1); // pointer to jump (ret to orig block)
//PD_WriteDanger<uintptr_t>(Transpose(patchBlock, block_sz + 1), PD_VoidPtr2IntPtr(Transpose(originalCodeBlock, block_sz))); // bug !!only offset
//---------------------------PREPEARE--ORIGINAL--BLOCK
memset(OrigPtr, nop, OrigSzBlock); // nop // nop 6, patch 5 bytes
void* ptr_to_patched_jmp = Transpose(OrigPtr, 0);
WriteDanger<char>(ptr_to_patched_jmp, jmp); // jmp
int offset2 = CalcJMPE9Offset(ptr_to_patched_jmp, patchBlock);
WriteDanger<int>(Transpose(ptr_to_patched_jmp, sizeof(char)), offset2); // pointer to jump (ret to orig block)
//PD_WriteDanger<uintptr_t>(Transpose(originalCodeBlock, 1), PD_VoidPtr2IntPtr(patchBlock)); // pointer to jump (jmp 2 patch)
//------------------------ORIG---PROTECT
if (return_orig_protect && orig_protect_ch)
{
DWORD oldProtect_ch;
VirtualProtect((LPVOID)mbi_orig.BaseAddress, mbi_orig.RegionSize, oldProtect_orig, &oldProtect_ch);
}
//------------------------PATCHED--PROTECT
//{ // modify block after func
// DWORD oldProtect_ptch;
// VirtualProtect(patchBlock, patched_block_sz, PAGE_EXECUTE_READ, &oldProtect_ptch); // PAGE_EXECUTE_READWRITE
//}
//std::cout << "ORIG: 0x" << originalCodeBlock << "\n";
//std::cout << "PATCH: 0x" << patchBlock << "\n";
//std::cout << "PATCH SZ BLOCK: " << mbi_patched.RegionSize << "\n";
//VirtualFree(patchBlock, 0, MEM_RELEASE);
return true;
}
void* MkMem(int sz, int protect = PAGE_READWRITE) { return VirtualAlloc(nullptr, sz, MEM_COMMIT, protect); }
void RmMem(void* ptr) { VirtualFree(ptr, 0, MEM_RELEASE); }
//----XMEMORY USAGE
//void* g_mem_block = nullptr;
//void HelperFunc()
//{
// if (!g_mem_block) { return; }
// std::cout << "\n";
// //std::cout << "TestFunc!!!" << "\n";
//
// void* _this = (void*)ReadPtrDanger<uintptr_t>(Transpose(g_mem_block, (0 * sizeof(void*)))); // CPed target
// int method = ReadPtrDanger<int>(Transpose(g_mem_block, (1 * sizeof(void*)))); // eWeaponType
// int pedPiece = ReadPtrDanger<int>(Transpose(g_mem_block, (2 * sizeof(void*)))); // ePedPieceTypes
// //bool willLinger = ReadPtrDanger<char>(Transpose(g_mem_block, (3 * sizeof(void*)))); // not remove el flag ??
//
// if (!_this) { return; }
//
// //std::cout << "_this: " << intToHexString((uintptr_t)_this) << std::endl;
// //std::cout << "method: " << intToHexString(method) << std::endl;
// //std::cout << "pedPiece: " << intToHexString(pedPiece) << std::endl;
// //std::cout << "willLinger: " << intToHexString(willLinger) << std::endl;
//
//
// if ((((method > WEAPONTYPE_BASEBALLBAT) && (method < WEAPONTYPE_ROCKETLAUNCHER)) && (pedPiece == PEDPIECE_HEAD)))
// {
// ((CPed*)_this)->m_fHealth = 0.0f;
// }
//
// //----CLS
// //WriteDanger<int>(Transpose(g_mem_block, (0 * sizeof(void*))), 0x00);
// //WriteDanger<int>(Transpose(g_mem_block, (1 * sizeof(void*))), 0x00);
// //WriteDanger<int>(Transpose(g_mem_block, (2 * sizeof(void*))), 0x00);
// //WriteDanger<int>(Transpose(g_mem_block, (3 * sizeof(void*))), 0x00);
//}
//
//void PatchTest()
//{
// //https://eax.me/assembler-basics/
// //InitConsole();
//
//
// //CPed::InflictDamage
// void* orig_ptr_for_patch_reference = (void*)0x4EACC0; // !jmp !jz !mov NO OFFSETS OPCODES (def patch sz 5bytes)
// int available_sz_patch = 51; // ä¸ðíóòü áàéòû èç îðèãà
// int need_sz_patch = 200; // bytes // äîï áëîê
// int offset = 50; // max need_sz_patch(áóäåò â êîíöå ïåðåä jmp) block(200+51+1+4)
// bool jmp_patch_in_end_region = false;
//
// //---OUT
// void* out_patch_ptr = nullptr;
// int out_patch_sz = 0; // mbi.region_sz
// //bool res = SetPatchBlock(orig_ptr_for_patch_reference, available_sz_patch, need_sz_patch, out_patch_ptr, out_patch_sz, true, offset); // jmp in the end region
// bool res = SetPatchBlock(orig_ptr_for_patch_reference, available_sz_patch, need_sz_patch, out_patch_ptr, out_patch_sz, jmp_patch_in_end_region, offset); // jmp after need_sz_patch
// void* moved_block = Transpose(out_patch_ptr, offset);
// void* jmp = Transpose(moved_block, 46); // 0x4EACEE old // 0xE9 jmp (4b)
// void* retn_false_label_ptr = (void*)0x4EADDA;
//
//
// //----fix jmp offset JMP ÐÀÁÎÒÀÅÒ ÌÎÈÌ ÌÅÒÎÄÎÌ È ×ÅÐÅÇ InsertJump
// //int offset_4_jmp = CalcJMPE9Offset(jmp, retn_false_label_ptr); // ðàáîòàåò òàêæå, InsertJump ýëåãàíòíåå
// //WriteDanger<int>(Transpose(jmp, sizeof(char)), offset_4_jmp); // InsertJump ?
// InsertJump(jmp, retn_false_label_ptr);
// //-----------------END----FIX----MATH
//
//
//
//
// // write patch
// /*; Áàéòû äëÿ çàãðóçêè çíà÷åíèÿ float èç ïàìÿòè ïî àäðåñó 0x12345 â ðåãèñòð eax
// 8b 05 23 01 00 ; mov eax, 0x123
// ; Áàéòû äëÿ ñîõðàíåíèÿ çíà÷åíèÿ float â ðåãèñòðå eax ïî àäðåñó [esp + 14]
// 89 44 24 14 ; mov dword [esp + 14], eax*/
// //mov destination, source
//
//
// void* patch_ptr = Transpose(out_patch_ptr, 0);
// void* buff = MkMem((4 * sizeof(void*))); // bytes // usage 4 * 3
// if (!buff) { return; }
// g_mem_block = buff;
// // _this method pedPiece willLinger
//
//
//
//
// //-----this thiscall â ecx íî êîä èíîãäà ïåðåçàïèñûâàåò åãî â 1, õóêàé íà÷àëî äëÿ ïåðåõâàòà ecx
// //--offset esp
// //!!!÷åðåç esp + 0x50
// // buff = [esp + 0x50] (this CPed target)
// //WriteDanger<char>(Transpose(nop_test_fld, 18), 0x8B); // mov
// //WriteDanger<char>(Transpose(nop_test_fld, 19), 0x44);
// //WriteDanger<char>(Transpose(nop_test_fld, 20), 0x24);
// //WriteDanger<char>(Transpose(nop_test_fld, 21), 0x50); // offset
// ////----mov ptr, eax
// //WriteDanger<char>(Transpose(nop_test_fld, 22), 0xA3); // mov ptr eax
// //WriteDanger<uintptr_t>(Transpose(nop_test_fld, 23), (uintptr_t)Transpose(buff, (2 * sizeof(void*))));
//
// //--ecx => ptr (ìóñîð 1)
// // 0x89 0x0D PO IN TE RR çàãðóçèò ecx â àäðåñ !!!!
// // 0x8B 0x0D PO IN TE RR çàãðóçèò èç àäðåñà â ecx
// //WriteDanger<char>(Transpose(nop_test_fld, 18), 0x89); // mov ptr ecx // 89 0D ?? mov [0AB70000], ecx
// //WriteDanger<char>(Transpose(nop_test_fld, 19), 0x0D);
// //WriteDanger<uintptr_t>(Transpose(nop_test_fld, 20), (uintptr_t)Transpose(buff, (2 * sizeof(void*))));
//
// // êîïèðóåì ebp â ïåðâûé áëîê, this pointer
// //--÷åðåç ebp, thiscall þçàåò ecx â íà÷àëå, ôóíêöèÿ çàòèðàåò
// // buff = ebp (this CPed target) // untested [esp + 0x50] ///BASE 004EA420
// WriteDanger<char>(Transpose(patch_ptr, 0), 0x89); // mov ptr, ebp
// WriteDanger<char>(Transpose(patch_ptr, 1), 0x2D);
// WriteDanger<uintptr_t>(Transpose(patch_ptr, 2), (uintptr_t)Transpose(buff, (0 * sizeof(void*))));
//
//
//
// // êîïèðóåì [esp + 0x38] ÷åðåç eax âî âòîðîé áëîê, method
// // buff = [esp + 0x38] (method)
// //!!!!!!!!!!!!!!!!!!!!!!!!!!!
// //mov eax, [esp + 0x38] 8B 44 54 38
// //mov [àäðåñ_ïàìÿòè], eax áåç îôñåòà A3 PO IN TE RR
//
// //---mov eax [esp + 0x38]
// WriteDanger<char>(Transpose(patch_ptr, 6), 0x8B); // work mov 2 eax
// WriteDanger<char>(Transpose(patch_ptr, 7), 0x44); // mov esp + offset to eax
// WriteDanger<char>(Transpose(patch_ptr, 8), 0x24);
// WriteDanger<char>(Transpose(patch_ptr, 9), 0x38); // offset
//
// //----mov ptr, eax
// WriteDanger<char>(Transpose(patch_ptr, 10), 0xA3); // mov ptr eax load eax to pointer
// WriteDanger<uintptr_t>(Transpose(patch_ptr, 11), (uintptr_t)Transpose(buff, (1 * sizeof(void*))));
//
//
//
//
// // êîïèðóåì [esp + 0x40] ÷åðåç eax â òðåòèé áëîê, pedpice
// // buff = [esp + 0x40] (pedpice)
// WriteDanger<char>(Transpose(patch_ptr, 15), 0x8B); // mov
// WriteDanger<char>(Transpose(patch_ptr, 16), 0x44); // mov esp + offset to eax
// WriteDanger<char>(Transpose(patch_ptr, 17), 0x24);
// WriteDanger<char>(Transpose(patch_ptr, 18), 0x40); // offset
//
// //----mov ptr, eax
// WriteDanger<char>(Transpose(patch_ptr, 19), 0xA3); // mov ptr eax load eax to pointer
// WriteDanger<uintptr_t>(Transpose(patch_ptr, 20), (uintptr_t)Transpose(buff, (2 * sizeof(void*))));
//
//
//
//
// //---------------------------------------------------------------------fix offsets (willLinger) íå èñïîëüçóåòüñÿ
// //// buff = [esp + 0x0C] (willLinger) èëè ÷àñòü òåëà
// //WriteDanger<char>(Transpose(nop_test_fld, 24), 0x8B); // mov
// //WriteDanger<char>(Transpose(nop_test_fld, 25), 0x44);
// //WriteDanger<char>(Transpose(nop_test_fld, 26), 0x24);
// //WriteDanger<char>(Transpose(nop_test_fld, 27), 0x0C); // offset
//
// ////----mov ptr, eax
// //WriteDanger<char>(Transpose(nop_test_fld, 28), 0xA3); // mov ptr eax
// //WriteDanger<uintptr_t>(Transpose(nop_test_fld, 29), (uintptr_t)Transpose(buff, (3 * sizeof(void*)))); // char !!!
//
// ////---î÷èñòêà áàéòà íà áàéò áîëüøå
// //WriteDanger<char>(Transpose(nop_test_fld, 33), 0xC7); // mov [aab000C], 00 00 00 00
// ////WriteDanger<char>(Transpose(nop_test_fld, 33), 0xC6); // mov [aab000C], 00
// //WriteDanger<char>(Transpose(nop_test_fld, 34), 0x05);
// //WriteDanger<uintptr_t>(Transpose(nop_test_fld, 35), (uintptr_t)Transpose(buff, (3 * sizeof(void*)) + 1)); // char !!!
// //WriteDanger<int>(Transpose(nop_test_fld, 39), 0x00);
// //// write buff * (3*szof()) + 1 3 zero
//
//
// //---------âûçûâàåì call myfunc áåç àðãóìåíòîâ
// WriteDanger<char>(Transpose(patch_ptr, 24), 0xE8); // call
// InsertCall(Transpose(patch_ptr, 24), HelperFunc);
// //WriteDanger<int>(Transpose(patch_ptr, 25), CalcJMPE9Offset(Transpose(patch_ptr, 24), HelperFunc)); // call func
//
//}
void PatchTest()
{
void* orig_ptr_for_patch_reference = (void*)0x4EACC0; // !jmp !jz !mov NO OFFSETS OPCODES (def patch sz 5bytes)
int available_sz_patch = 51;
int need_sz_patch = 200; // bytes
int offset = need_sz_patch; // max need_sz_patch(áóäåò â êîíöå ïåðåä jmp) block(200+51+1+4)
bool jmp_patch_in_end_region = false;
//---OUT
void* out_patch_ptr = nullptr;
int out_patch_sz = 0; // mbi.region_sz
//bool res = SetPatchBlock(orig_ptr_for_patch_reference, available_sz_patch, need_sz_patch, out_patch_ptr, out_patch_sz, true, offset); // jmp in the end region
bool res = SetPatchBlock(orig_ptr_for_patch_reference, available_sz_patch, need_sz_patch, out_patch_ptr, out_patch_sz, jmp_patch_in_end_region, offset); // jmp after need_sz_patch
//std::cout << "ORIG: 0x" << orig_ptr_for_patch_reference << "\n";
//std::cout << "PATCH: 0x" << out_patch_ptr << "\n";
//std::cout << "PATCH SZ BLOCK: " << out_patch_sz << "\n";
}
//---GAME--HELPERS-------------------------------
void PrintPlayerCoords()
{
CPlayerPed* player = FindPlayerPed();
if (!player) { return; }
float x_offset = -30.0f;
float y_offset = -30.0f;
char str[200];
//uint16_t ustr[200];
//CVector pos = FindPlayerCoors(); // crash
CVector pos = player->GetPosition();
int32_t ZoneId = ARRAY_SIZE(ZonePrint) - 1; // no zone //10
//int32_t ZoneId = 10;
for (int32_t i = 0; i < ARRAY_SIZE(ZonePrint) - 1; i++)
{
if (pos.x > ZonePrint[i].rect.left
&& pos.x < ZonePrint[i].rect.right
&& pos.y > ZonePrint[i].rect.bottom
&& pos.y < ZonePrint[i].rect.top)
{
ZoneId = i;
}
}
sprintf(str, "X:%5.1f, Y:%5.1f, Z:%5.1f, %s", pos.x, pos.y, pos.z, ZonePrint[ZoneId].name);
//AsciiToUnicode(str, ustr);
CFont::SetPropOff();
CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(1.2f)); // ìåíüøå
//CFont::SetScale(SCREEN_SCALE_X(0.7f), SCREEN_SCALE_Y(1.5f)); // orig
//CFont::SetScale(0.7f, 1.5f); // bug
CFont::SetCentreOff();
CFont::SetRightJustifyOff();
CFont::SetJustifyOff();
CFont::SetBackGroundOnlyTextOff();
CFont::SetWrapx(SCREEN_STRETCH_X(DEFAULT_SCREEN_WIDTH));
//CFont::SetWrapx(SCREEN_WIDTH); // my custom
//CFont::SetWrapx(DEFAULT_SCREEN_WIDTH); // bug
CFont::SetFontStyle(FONT_HEADING);
//----BLACK
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_X(40.0f + 2.0f) + x_offset, SCREEN_SCALE_Y(40.0f + 2.0f) + y_offset, str);
//CFont::PrintString(40.0f + 2.0f, 40.0f + 2.0f, str); // bug
//---ORANGE
CFont::SetColor(CRGBA(255, 108, 0, 255));
CFont::PrintString(SCREEN_SCALE_X(40.0f) + x_offset, SCREEN_SCALE_Y(40.0f) + y_offset, str);
//CFont::PrintString(40.0f, 40.0f, str); // bug
}
//CPlayerPed* player = FindPlayerPed();
//if (!player) { return; }
//for (CPed* ped : CPools::ms_pPedPool)
//{
// if (!ped || ped == player || !ped->m_fHealth) continue;
//
// Wallhack(ped);
//}
void Wallhack(CPed* ped)
{
CVector position = ped->GetPosition();
RwV3d pos = { position.x + 0.1f, position.y, position.z + 0.9f };
RwV3d coords;
float w, h;
if (!CSprite::CalcScreenCoors(pos, &coords, &w, &h, true)) { /*std::cout << "ERROR PED!! " << "\n";*/ return; }
//CFont::SetOrientation(ALIGN_LEFT);
CFont::SetColor(color::White);
CFont::SetDropShadowPosition(1);
CFont::SetBackgroundOff();
//CFont::SetBackground(false, false);
CFont::SetWrapx(SCREEN_WIDTH);
CFont::SetScale(1.0, 2.0);
//CFont::SetFontStyle(1); //?
//CFont::SetFontStyle(FONT_SUBTITLES);
CFont::SetPropOn();
//CFont::SetProportional(true);
//std::string text = "Skin ID: " + std::to_string(ped->m_nModelIndex) + "~n~";
//std::string text = "123 " + std::to_string(ped->m_nModelIndex) + "";
std::string text = "DESPAIR";
//text.append(std::format("Position: {:.2f}, {:.2f}, {:.2f}~n~", pos.x, pos.y, pos.z));
//text.append(std::format("Health: {:.2f}~n~", ped->m_fHealth));
//text.append(std::format("Armor: {:.2f}~n~", ped->m_fArmour));
//text.append(std::format("Weapon: {}~n~", GetActivePedWeapon(ped)));
//text.append(std::format("In Vehicle: {}~n~", IsPedInCar(ped)));
CFont::PrintString(coords.x, coords.y, (char*)text.c_str());
//std::cout << "PED!! " << "\n";
}
void
KillPlayer()
{
CPlayerPed* player = FindPlayerPed();
if (!player) { return; }
Command<eScriptCommands::COMMAND_SET_CHAR_HEALTH>(player, 0);
}
void
KillPed(CPed* pPed)
{
CPlayerPed* player = FindPlayerPed();
if (player && pPed == player) { Command<eScriptCommands::COMMAND_SET_CHAR_HEALTH>(player, 0); return; } // with anim
//COMMAND_SET_CHAR_HEALTH
pPed->m_fHealth = 0.0f; // ??
// if in car
pPed->SetDead();
if (!pPed->IsPlayer()) { pPed->FlagToDestroyWhenNextProcessed(); }
// else
//pPed->SetDie(); // last argument = 13 (default? TODO)
}
void
KillPedPool(int mode) // 0 player, 1 all, 2 in car, 3 walking
{
if ((mode < 0) || (mode > 4)) { return; }
CPlayerPed* player = FindPlayerPed();
if (!player) { std::cout << "!player" << "\n"; return; }
if (mode == 0) { KillPed(player); }
int cnt = 0;
//CPools::ms_pPedPool->Clear(); // kill player
//CPools::ms_pPedPool->Flush();
//return;
for (CPed* pPed : CPools::ms_pPedPool)
{
if (!pPed || pPed == player || !pPed->m_fHealth) { continue; }
++cnt;
if (mode == 1) // all kill
{
// not continue skip;
}
else if (mode == 2) // only drivers
{
if (!pPed->m_bInVehicle) { continue; }
}
else // only walking peds
{
if (pPed->m_bInVehicle) { continue; }
}
KillPed(pPed);
////COMMAND_SET_CHAR_HEALTH
//pPed->m_fHealth = 0.0f; // ??
//// if in car
//pPed->SetDead();
//if (!pPed->IsPlayer()) { pPed->FlagToDestroyWhenNextProcessed(); }
//// else
////pPed->SetDie(); // last argument = 13 (default? TODO)
//std::cout << pPed->IsPedInControl() << "\n";
}
std::cout << "killed: " << cnt << "\n";
}
void
KillVehiclePool(int mode = 0)
{
CPlayerPed* player = FindPlayerPed();
if (!player) { std::cout << "!player" << "\n"; return; }
float min_nofire_health = 251.0f;
float fire_health = 100.0f;
/*CVehicle* vehicle = FindPlayerVehicle();
if (vehicle)
{
if ((vehicle->m_fHealth > sethealth) && !car_flag)
{
vehicle->m_fHealth = sethealth;
//Command<eScriptCommands::COMMAND_SET_CAR_HEALTH>(vehicle, 252);
//Command<eScriptCommands::COMMAND_SET_6_PHONE_MESSAGES>("123");
car_flag = true;
}
}*/
int cnt = 0;
for (CVehicle* vehicle : CPools::ms_pVehiclePool)
{
if (!vehicle || (!vehicle->m_fHealth)) { continue; }
if ((mode != 1) && (vehicle->m_pDriver == player)) { continue; } // mode0 !player, mode1 all
//Command<eScriptCommands::COMMAND_SET_CAR_HEALTH>(vehicle, (int)fire_health);
vehicle->m_fHealth = fire_health; // !! äîðàáîòàòü, ãîðÿò ïðè ïðèêîñíîâåíèè
++cnt;
}
std::cout << "damaged cnt: " << cnt << "\n";
}
void DisplayPagerMsg(std::string msg) { CUserDisplay::Pager.AddMessage(T_constchar2char(msg.c_str()), 140, 2, 0); }
int NormalizeStars(int _input) { return _input % 7; } // îãðàíè÷åíèå äî 7
bool SetWanted(int _wnt)
{
if ((_wnt < 0) || (_wnt > 6)) { return false; }
CPlayerPed* playerPed = FindPlayerPed();
if (playerPed)
{
CWanted* wanted = playerPed->m_pWanted;
if (!wanted) return false;
wanted->SetMaximumWantedLevel(6);
//CWanted::SetMaximumWantedLevel(6); //??
//playerPed->SetWantedLevelNoDrop(_wnt);
playerPed->SetWantedLevel(_wnt);
return true;
}
return false;
}
bool Cheat(std::string cheat, bool player_check = true)
{
if (cheat.length() != 0)
{
CPlayerPed* playerPed = FindPlayerPed();
if (player_check && (!playerPed)) { return false; } // !player
std::string text = ToUpper(cheat);
if (text == "GUNSGUNSGUNS") { WeaponCheat(); } // Âñå îðóæèå
else if (text == "IFIWEREARICHMAN") { MoneyCheat(); } // Ïîëó÷èòü äåíüãè
else if (text == "TORTOISE") { ArmourCheat(); } // Ïîëíàÿ áðîíÿ
else if (text == "GESUNDHEIT") { HealthCheat(); } // Ïîëíîå çäîðîâüå
else if (text == "MOREPOLICEPLEASE") { WantedLevelUpCheat(); } // Ïîâûñèòü óðîâåíü ðîçûñêà
else if (text == "NOPOLICEPLEASE") { WantedLevelDownCheat(); } // Óáðàòü óðîâåíü ðîçûñêà
else if (text == "GIVEUSATANK") { TankCheat(); } // Ïîëó÷èòü òàíê
else if (text == "BANGBANGBANG") { BlowUpCarsCheat(); } // Âçîðâàòü âñå ìàøèíû
else if (text == "ITSALLGOINGMAAAD") { MayhemCheat(); } // Áåçóìíûå ïåøåõîäû
else if (text == "NOBODYLIKESME") { EverybodyAttacksPlayerCheat(); } // Ïåøåõîäû àòàêóþò èãðîêà
else if (text == "WEAPONSFORALL") { WeaponsForAllCheat(); } // Ïåøåõîäû äåðóòñÿ + îðóæèå
else if (text == "TIMEFLIESWHENYOU") { FastWeatherCheat(); } // Óñêîðèòü âðåìÿ ïîãîäû
else if (text == "SKINCANCERFORME") { SunnyWeatherCheat(); } // ßñíàÿ ïîãîäà
else if (text == "ILIKESSCOTLAND") { CloudyWeatherCheat(); } // Ïàñìóðíàÿ ïîãîäà
else if (text == "ILOVESCOTLAND") { RainyWeatherCheat(); } // Äîæäëèâàÿ ïîãîäà
else if (text == "PEASOUP") { FoggyWeatherCheat(); } // Òóìàííàÿ ïîãîäà
else if (text == "MADWEATHER") { FastTimeCheat(); } // Óñêîðèòü èãðîâûå ÷àñû
else if (text == "BOOOOORING") { SlowTimeCheat(); } // Çàìåäëåíèå
else if (text == "ILIKEDRESSINGUP") { ChangePlayerCheat(); } // Ñìåíèòü ìîäåëü èãðîêà íà ñëó÷àéíóþ
else if (text == "ANICESETOFWHEELS") { OnlyRenderWheelsCheat(); } // Íåâèäèìûå ìàøèíû, âèäíû òîëüêî êîë¸ñà
else if (text == "CORNERSLIKEMAD") { StrongGripCheat(); } // Óëó÷øåííîå óïðàâëåíèå ìàøèíàìè
else if (text == "CHITTYCHITTYBB") { ChittyChittyBangBangCheat(); } // Ìàøèíû ëåòàþò
else if (text == "NASTYLIMBSCHEAT") { NastyLimbsCheat(); } // Êðîâàâûé ðåæèì
//else if (text == "TEST") { }
else { return false; } // NOT FOUND
}
else { return false; } // empty string
return true;
}
//MK PED
//CPed* newPed = nullptr;
//
//CPed* playa = FindPlayerPed();
//if (playa) {
// CVector pedPos = playa->TransformFromObjectSpace(CVector(0.0f, 3.0f, 0.0f));
// if (newPed == nullptr) {
// //newPed = ÑreateChar(PEDTYPE_CIVMALE, MODEL_B_MAN3, pedPos);
// newPed = ÑreateChar(PEDTYPE_GANG2, MODEL_NULL, pedPos);
// }
//}
//---DS