This repository has been archived by the owner on Sep 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
PluginHelper.cpp
94 lines (65 loc) · 2.75 KB
/
PluginHelper.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
#include "game_sa/CVehicle.h"
#include "PluginHelper.h"
#include "PluginConfig.h"
#include <windows.h>
#include <iostream> // std::cout
#include <fstream> // std::ifstream
#include <string>
#include <chrono>
DWORD PluginHelper::base;
/*void PluginHelper::RegisterMultiplayerHandle() {
base = (DWORD)GetModuleHandle("samp.dll");
if (base) {
DWORD byte;
injector::ReadMemoryRaw((void*)(base + 0xBAC9), &byte, 4, true);
if (byte != 0x50000b96)
PluginConfig::Helper->Multiplayer = false;
}
else
PluginConfig::Helper->Multiplayer = false;
};
void PluginMultiplayer::AddChatMessage(const char* string) {
if (!PluginConfig::Helper->Multiplayer)
return;
if (!PluginConfig::Helper->MultiplayerMessages)
return;
const char* message = std::string("{7E59CA}[AVS]{FFFFFF} " + std::string(string)).c_str();
DWORD* chat = *(DWORD**)(base + 0x2ACA10);
((void(__thiscall*) (void* chatPtr, int messageType, const char* msg, char* prefix, DWORD, DWORD)) (base + 0x67650)) (chat, 4, message, "", 0xFFFFFFF, 0xFFFFFFF);
};
bool PluginMultiplayer::GetMouseState() {
if (!PluginConfig::Helper->Multiplayer)
return false;
DWORD misc = *(DWORD*)(base + 0x2ACA3C);
return *(BYTE*)(misc + 0x61);
};
int PluginMultiplayer::GetVehicleIdentifier(PluginMultiplayer::GetVehiclePool(), CVehicle* vehicle) {
if (!PluginConfig::Helper->Multiplayer)
return -1;
DWORD g_SAMP = *(DWORD*)(PluginHelper::base + 0x2ACA24);
DWORD g_VehiclePool = *(DWORD*)(g_SAMP + 0x3DE);
g_VehiclePool = *(DWORD*)(g_VehiclePool + 0xC);
uint(__thiscall * GetSAMPVehicleIdFromGTAHandle) (void* poolPtr, CVehicle * vehicle) = (uint(__thiscall*) (void* poolPtr, CVehicle * vehicle)) (PluginHelper::base + 0x1e650);
return (int)GetSAMPVehicleIdFromGTAHandle((void*)g_VehiclePool, vehicle);
};*/
bool EndsWith(const std::string& str, const std::string& suffix)
{
return str.size() >= suffix.size() && 0 == str.compare(str.size() - suffix.size(), suffix.size(), suffix);
}
bool StartsWith(const std::string& str, const std::string& prefix)
{
return str.size() >= prefix.size() && 0 == str.compare(0, prefix.size(), prefix);
}
uint64_t timeSinceEpochMillisec() {
using namespace std::chrono;
return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
};
RwTexture* PluginHelper::LoadTextureFromFile(const char* filename) {
RwImage* image = RtPNGImageRead(filename);
RwInt32 width, height, depth, flags;
RwImageFindRasterFormat(image, 4, &width, &height, &depth, &flags);
RwRaster* raster = RwRasterCreate(width, height, depth, flags);
RwRasterSetFromImage(raster, image);
RwImageDestroy(image);
return RwTextureCreate(raster);
};