-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.cpp
More file actions
127 lines (107 loc) · 2.98 KB
/
Copy pathscript.cpp
File metadata and controls
127 lines (107 loc) · 2.98 KB
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
/*
THIS FILE IS A PART OF GTA V SCRIPT HOOK SDK
http://dev-c.com
(C) Alexander Blade 2015
*/
#include "script.h"
#include "utils.h"
#include "keyboard.h"
#include <vector>
#include <chrono>
using namespace std::chrono;
UINT64* currentCheckpoint;
UINT64 oldCheckpoint = 0;
UINT64 desiredCheckpoint = 0;
struct TextDrawInfo {
std::string text;
int red;
int green;
int blue;
milliseconds endTime;
};
typedef std::vector<TextDrawInfo> TextDrawInfoList;
TextDrawInfoList g_TextDrawInfos;
void AddTextDraw(const std::string text, UINT64 displayTimeInMilliSeconds, int red = 255, int green = 255, int blue = 255) {
TextDrawInfo info;
info.text = text;
info.red = red;
info.green = green;
info.blue = blue;
info.endTime = duration_cast<milliseconds>(
system_clock::now().time_since_epoch()
) + milliseconds(displayTimeInMilliSeconds);
g_TextDrawInfos.push_back(info);
}
void update()
{
Player player = PLAYER::PLAYER_ID();
Ped playerPed = PLAYER::PLAYER_PED_ID();
if (*currentCheckpoint != oldCheckpoint) {
// Checkpoint has been changed, reset
desiredCheckpoint = *currentCheckpoint;
}
if (IsKeyJustUp(VK_OEM_MINUS) && desiredCheckpoint > 0) {
desiredCheckpoint--;
AddTextDraw("Selected checkpoint " + std::to_string(desiredCheckpoint) + ". Press \"0\" to apply.", 1200);
}
if (IsKeyJustUp(VK_OEM_PLUS)) {
desiredCheckpoint++;
AddTextDraw("Selected checkpoint " + std::to_string(desiredCheckpoint) + ". Press \"0\" to apply.", 1200);
}
if (IsKeyJustUp(0x30)) { // '0' key
*currentCheckpoint = desiredCheckpoint;
AddTextDraw("Going to checkpoint " + std::to_string(desiredCheckpoint), 3000);
ENTITY::SET_ENTITY_HEALTH(playerPed, 0, 0);
}
oldCheckpoint = *currentCheckpoint;
// Draw text
TextDrawInfoList::iterator it;// Draw it
float x = 0.5;
float y = 0.5;
for(it = g_TextDrawInfos.begin(); it != g_TextDrawInfos.end(); it++){
TextDrawInfo info = *it;
HUD::SET_TEXT_FONT(0);
HUD::SET_TEXT_SCALE(0.4f, 0.4f);
HUD::SET_TEXT_COLOUR(info.red, info.blue, info.green, 255);
HUD::SET_TEXT_CENTRE(true);
HUD::SET_TEXT_DROPSHADOW(3, 0, 0, 0, 255);
HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING");
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(info.text.c_str());
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(x, y, 0);
y += 0.03f;
}
// Remove expired text
it = g_TextDrawInfos.begin();
while (it != g_TextDrawInfos.end()) {
TextDrawInfo info = *it;
auto timeNowMs = duration_cast<milliseconds>(
system_clock::now().time_since_epoch()
);
if (timeNowMs > info.endTime) {
g_TextDrawInfos.erase(it);
it = g_TextDrawInfos.begin();
}
else {
it++;
}
}
}
void main()
{
//Wait for ingame.
while (CAM::IS_SCREEN_FADED_OUT()) {
WAIT(100);
}
AddTextDraw("Checkpoint Changer Mod v1.0 loaded!", 5000, 255, 10, 10);
AddTextDraw("Press \"+\" or \"-\" while on a mission to adjust checkpoint and \"0\" to apply.", 5000);
currentCheckpoint = getGlobalPtr(89999);
while (true)
{
update();
WAIT(0);
}
}
void ScriptMain()
{
main();
}