Skip to content

Commit 2909d68

Browse files
committed
Disable logs completely when EnableLogger is 0, More GTA SA Version support (EXPERIMENTAL) & Cleanup codes
1 parent 7aa98b8 commit 2909d68

File tree

5 files changed

+90
-175
lines changed

5 files changed

+90
-175
lines changed

README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ Memory Addresses taken from [GTAMods](https://gtamods.com/wiki/Category:Memory_A
1111

1212
# Version
1313
- GTA III 1.0
14-
- GTA San Andreas 1.0 Hoodlum
15-
- GTA San Andreas 1.0 Compact
14+
- GTA San Andreas 1.0 US Hoodlum
15+
- GTA San Andreas 1.0 US Compact
16+
- GTA San Andreas 1.0 EU
17+
- GTA San Andreas 1.01 US
18+
- GTA San Andreas 1.01 EU
19+
- GTA San Andreas Steam R2
20+
- GTA San Andreas Steam R2-LV
1621
- GTA Vice City 1.0
1722

1823
# Screenshots
1924
![iii](https://github.com/Huga22118/GTA-Discord-RPC/blob/main/iii.png)
2025

21-
![sa_hoodlum](https://github.com/Huga22118/GTA-Discord-RPC/blob/main/sa_hoodlum.png)
22-
23-
![sa_compact](https://github.com/Huga22118/GTA-Discord-RPC/blob/main/sa_compact.png)
26+
![sa](https://github.com/Huga22118/GTA-Discord-RPC/blob/main/sa.png)
2427

2528
![vc](https://github.com/Huga22118/GTA-Discord-RPC/blob/main/vc.png)
2629

sa_hoodlum.png sa.png

File renamed without changes.

sa_compact.png

-13.5 KB
Binary file not shown.

src/dllmain.cpp

+47-27
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,16 @@ bool Game::IniBool(CIniReader ini, std::string section, std::string key)
1616
bool b = ini.ReadInteger(section, key, 0) == 1;
1717
if (b == true)
1818
{
19-
LOGGER << key << " = true" << std::endl;
2019
return true;
2120
}
2221
else
2322
{
24-
LOGGER << key << " = false" << std::endl;
2523
return false;
2624
}
2725
}
2826

2927
void Game::Init()
3028
{
31-
static char sBufferz[1024];
32-
sprintf(sBufferz, "%s is compatible with this plugin.\n", GetGameVersionName());
33-
LOGGER << sBufferz << std::endl;
34-
3529
CIniReader ini("Discord_" GAME ".ini");
3630
DCStatus = IniBool(ini, "Discord", "DiscordStatus");
3731
ShowDetectedIni = IniBool(ini, "Discord", "ShowDetectedINIMsg");
@@ -49,6 +43,20 @@ void Game::Init()
4943
Message("Discord_%s.ini Detected!", GAME);
5044
}
5145

46+
if (ShowLOG)
47+
{
48+
static char sBufferz[1024];
49+
sprintf(sBufferz, "GTA Trilogy Discord RPC\nv4.1\n");
50+
LOGGER << sBufferz << std::endl;
51+
}
52+
53+
if (ShowLOG)
54+
{
55+
static char sBufferz[1024];
56+
sprintf(sBufferz, "%s Detected.\n", GetGameVersionName());
57+
LOGGER << sBufferz << std::endl;
58+
}
59+
5260
rpc->Update();
5361
}
5462

@@ -57,7 +65,7 @@ void Game::Update()
5765
if (ShowLOG)
5866
{
5967
LOGGER << std::endl;
60-
Logger("Starting Discord RPC Plugins.");
68+
Logger("Trying to start Events::initRwEvent.");
6169
}
6270

6371
Events::initRwEvent += []
@@ -75,7 +83,7 @@ void Game::Update()
7583

7684
if (ShowLOG)
7785
{
78-
Logger("Discord Module Initialized!");
86+
Logger("Events::initRwEvent Started!");
7987
}
8088

8189
if (DCStatus)
@@ -86,7 +94,10 @@ void Game::Update()
8694
details = "Game: III";
8795
}
8896
#elif GTASA
89-
if (GetGameVersion() == GAME_10US_HOODLUM || GetGameVersion() == GAME_10US_COMPACT)
97+
if (GetGameVersion() == GAME_10US_HOODLUM || GetGameVersion() == GAME_10US_COMPACT ||
98+
GetGameVersion() == GAME_10EU || GetGameVersion() == GAME_11US ||
99+
GetGameVersion() == GAME_11EU || GetGameVersion() == GAME_STEAM ||
100+
GetGameVersion() == GAME_STEAM_LV)
90101
{
91102
details = "Game: San Andreas";
92103
}
@@ -102,13 +113,14 @@ void Game::Update()
102113
state = "Version: 1.0 EN";
103114
}
104115
#elif GTASA
105-
if (GetGameVersion() == GAME_10US_HOODLUM)
106-
{
107-
state = "Version: 1.0 US Hoodlum";
108-
}
109-
else if (GetGameVersion() == GAME_10US_COMPACT)
116+
if (GetGameVersion() == GAME_10US_HOODLUM || GetGameVersion() == GAME_10US_COMPACT ||
117+
GetGameVersion() == GAME_10EU || GetGameVersion() == GAME_11US ||
118+
GetGameVersion() == GAME_11EU || GetGameVersion() == GAME_STEAM ||
119+
GetGameVersion() == GAME_STEAM_LV)
110120
{
111-
state = "Version: 1.0 US Compact";
121+
static char sBufferz[1024];
122+
sprintf(sBufferz, "Version: %s", GetGameVersionNames());
123+
state = sBufferz;
112124
}
113125
#elif GTAVC
114126
if (GetGameVersion() == GAME_10EN)
@@ -148,44 +160,52 @@ BOOL APIENTRY DllMain(HINSTANCE hDllHandle, DWORD reason, LPVOID lpReserved)
148160
#ifdef GTASA
149161
if (GetModuleHandleA("SAMP.dll") || GetModuleHandleA("SAMP.asi"))
150162
{
151-
if (GetGameVersion() != GAME_10US_HOODLUM || GetGameVersion() != GAME_10US_COMPACT)
163+
if (GetGameVersion() != GAME_10US_HOODLUM || GetGameVersion() != GAME_10US_COMPACT ||
164+
GetGameVersion() != GAME_10EU || GetGameVersion() != GAME_11US ||
165+
GetGameVersion() != GAME_11EU || GetGameVersion() != GAME_STEAM ||
166+
GetGameVersion() != GAME_STEAM_LV)
152167
{
153-
static char sBufferz[1024];
168+
/* static char sBufferz[1024];
154169
sprintf(sBufferz, "GTA Trilogy Discord RPC\nv4.0 \n\nSA-MP Detected and this plugin are incompatible with this version \n- %s", GetGameVersionName());
155-
LOGGER << sBufferz << "\n" << std::endl;
170+
LOGGER << sBufferz << "\n" << std::endl;*/
156171

157172
Error("SA-MP Detected and this plugin are incompatible with this version \n- %s", GetGameVersionName());
158173
IfSampExist = true;
159174
}
160175
else
161176
{
162-
static char sBufferz[1024];
177+
/* static char sBufferz[1024];
163178
sprintf(sBufferz, "GTA Trilogy Discord RPC\nv4.0 \n\nSA-MP Detected! Ignoring Plugin.");
164-
LOGGER << sBufferz << std::endl;
179+
LOGGER << sBufferz << std::endl;*/
165180

166181
Error("SA-MP Detected!");
167182
IfSampExist = true;
168183
}
169184
}
170185
else
171186
{
172-
if (GetGameVersion() == GAME_10US_HOODLUM || GetGameVersion() == GAME_10US_COMPACT)
187+
if (GetGameVersion() == GAME_10US_HOODLUM || GetGameVersion() == GAME_10US_COMPACT ||
188+
GetGameVersion() == GAME_10EU || GetGameVersion() == GAME_11US ||
189+
GetGameVersion() == GAME_11EU || GetGameVersion() == GAME_STEAM ||
190+
GetGameVersion() == GAME_STEAM_LV)
173191
{
174-
static char sBufferz[1024];
192+
/* static char sBufferz[1024];
175193
sprintf(sBufferz, "GTA Trilogy Discord RPC\nv4.0\n");
176-
LOGGER << sBufferz << std::endl;
194+
LOGGER << sBufferz << std::endl;*/
177195

178196
rpc->Init();
179197
IfSampExist = false;
180198
}
181199
else
182200
{
183-
static char sBufferz[1024];
201+
/* static char sBufferz[1024];
184202
sprintf(sBufferz, "GTA Trilogy Discord RPC\nv4.0 \n\nERROR: This plugin does not work with %s version.", GetGameVersionName());
185-
LOGGER << sBufferz << std::endl;
203+
LOGGER << sBufferz << std::endl;*/
186204

187-
Error("This game version is not supported by %s plugin.\nThis plugin supports these game versions:\n- %s \n- %s",
188-
plugin::paths::GetPluginFileNameA(), GetGameVersionName(GAME_10US_HOODLUM), GetGameVersionName(GAME_10US_COMPACT));
205+
Error("This game version is not supported by %s plugin.\nThis plugin supports these game versions:\n- %s \n- %s \n- %s \n- %s \n- %s \n- %s \n- %s",
206+
plugin::paths::GetPluginFileNameA(), GetGameVersionName(GAME_10US_HOODLUM), GetGameVersionName(GAME_10US_COMPACT),
207+
GetGameVersionName(GAME_10EU), GetGameVersionName(GAME_11US), GetGameVersionName(GAME_11EU), GetGameVersionName(GAME_STEAM),
208+
GetGameVersionName(GAME_STEAM_LV));
189209
IfSampExist = false;
190210
}
191211
}

src/dllmain.h

+35-143
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <ctime>
88
#include <iostream>
99
#include <windows.h>
10+
#include <GameVersion.h>
1011

1112
static const char* APPLICATION_ID = "946628098693144626";
1213

@@ -59,156 +60,47 @@ class Game
5960

6061
};
6162

62-
const std::string weaponNames[] =
63-
{
63+
inline char const* GetGameVersionNames(int gameVersionId) {
64+
switch (gameVersionId) {
6465
#ifdef GTASA
65-
{ "Fist" },
66-
{ "Brass Knuckles" },
67-
{ "Golf Club" },
68-
{ "Night Stick" },
69-
{ "Knife" },
70-
{ "Bat" },
71-
{ "Shovel" },
72-
{ "Pool Cue" },
73-
{ "Katana" },
74-
{ "Chainsaw" },
75-
{ "Purple Dildo" },
76-
{ "Dildo" },
77-
{ "Vibrator" },
78-
{ "Silver Vibrator" },
79-
{ "Flowers" },
80-
{ "Cane" },
81-
{ "Grenade" },
82-
{ "Teargas" },
83-
{ "Molotov" },
84-
{ " " }, // Unused
85-
{ " " }, // Unused
86-
{ " " }, // Unused
87-
{ "Colt 45" },
88-
{ "Silenced Pistol" },
89-
{ "Desert Eagle" },
90-
{ "Shotgun" },
91-
{ "Sawnoff-Shotgun" },
92-
{ "Combat Shotgun" },
93-
{ "Uzi" },
94-
{ "MP5" },
95-
{ "AK-47" },
96-
{ "M4" },
97-
{ "Tec-9" },
98-
{ "Country Rifle" },
99-
{ "Sniper Rifle" },
100-
{ "Rocket Launcher" },
101-
{ "Heat-Seeking RPG" },
102-
{ "Flamethrower" },
103-
{ "Minigun" },
104-
{ "Satchel Charges" },
105-
{ "Detonator" },
106-
{ "Spray Can" },
107-
{ "Fire Extinguisher" },
108-
{ "Camera" },
109-
{ "Night Vision" },
110-
{ "Thermal Goggles" },
111-
{ "Parachute" },
112-
{ "Fake Pistol" }
66+
case GAME_10US_COMPACT:
67+
return "1.0 US Compact";
68+
case GAME_10US_HOODLUM:
69+
return "1.0 US Hoodlum";
70+
case GAME_10EU:
71+
return "1.0 EU";
72+
case GAME_11US:
73+
return "1.01 US";
74+
case GAME_11EU:
75+
return "1.01 EU";
76+
case GAME_STEAM:
77+
return "Steam";
78+
case GAME_STEAM_LV:
79+
return "Steam LV";
11380
#endif
114-
11581
#ifdef GTAVC
116-
{ "Fist" },
117-
{ "Brass Knuckle"},
118-
{ "Screwdriver" },
119-
{ "Golf Club" },
120-
{ "Nightstick" },
121-
{ "Knife" },
122-
{ "Baseball" },
123-
{ "Hammer" },
124-
{ "Cleaver" },
125-
{ "Machete" },
126-
{ "Katana" },
127-
{ "Chainsaw" },
128-
{ "Grenade" },
129-
{ "Remote Grenade" },
130-
{ "Teargas" },
131-
{ "Molotov" },
132-
{ " " }, // Rocket
133-
{ "Colt 45" },
134-
{ "Python" },
135-
{ "Shotgun" },
136-
{ "Spas-12 Shotgun" },
137-
{ "Stubby Shotgun" },
138-
{ "Tec-9" },
139-
{ "Uzi" },
140-
{ "Silenced Ingram" },
141-
{ "MP5" },
142-
{ "M4" },
143-
{ "Kruger" },
144-
{ "Sniper-Rifle" },
145-
{ "Laser Scope" },
146-
{ "Rocket Launcher" },
147-
{ "Flame Thrower" },
148-
{ "M60" },
149-
{ "Minigun" },
150-
{ "Detonator" },
151-
{ " " }, // Helicannon
152-
{ "Camera" }
82+
case GAME_10EN:
83+
return "1.0 EN";
84+
case GAME_11EN:
85+
return "1.1 EN";
86+
case GAME_STEAM:
87+
return "Steam";
15388
#endif
154-
15589
#ifdef GTA3
156-
{ " " } // unused because we cannot find the weapon memory addresses for this one
90+
case GAME_10EN:
91+
return "1.0 EN";
92+
case GAME_11EN:
93+
return "1.1 EN";
94+
case GAME_STEAM:
95+
return "Steam";
15796
#endif
97+
}
98+
return "Unknown";
99+
}
158100

159-
};
160-
161-
#ifdef GTASA
162-
const std::string weaponIcons[] =
101+
inline char const* GetGameVersionNames()
163102
{
164-
{ "fist" },
165-
{ "brassknuckleicon" },
166-
{ "golfclubicon" },
167-
{ "nitestickicon" },
168-
{ "knifecuricon" },
169-
{ "baticon" },
170-
{ "shovelicon" },
171-
{ "poolcueicon" },
172-
{ "katanaicon" },
173-
{ "chnsawicon" },
174-
{ "dildo1icon" },
175-
{ "dildo2icon" },
176-
{ "vibe1icon" },
177-
{ "vibe2icon" },
178-
{ "flowericon" },
179-
{ "caneicon" },
180-
{ "grenadeicon" },
181-
{ "teargasicon" },
182-
{ "molotovicon" },
183-
{ " " },
184-
{ " " },
185-
{ " " },
186-
{ "colt45icon" },
187-
{ "silencedicon" },
188-
{ "desert_eagleicon" },
189-
{ "chromegunicon" },
190-
{ "sawnofficon" },
191-
{ "shotgspaicon" },
192-
{ "micro_uziicon" },
193-
{ "mp5lngicon" },
194-
{ "ak47icon" },
195-
{ "m4icon" },
196-
{ "tec9icon" },
197-
{ "cuntgunicon" },
198-
{ "snipericon" },
199-
{ "rocketlaicon" },
200-
{ "heatseekicon" },
201-
{ "flameicon" },
202-
{ "minigunicon" },
203-
{ "satchelicon" },
204-
{ "bombicon" },
205-
{ "spraycanicon" },
206-
{ "fire_exicon" },
207-
{ "cameraicon" },
208-
{ "gogglesicon" },
209-
{ "gogglesicon" },
210-
{ "paraicon" },
211-
};
212-
#endif
103+
return GetGameVersionNames(plugin::GetGameVersion());
104+
}
213105

214106
extern Game* rpc;

0 commit comments

Comments
 (0)