Since I'm too lazy to write documentation on the things I found, I'll just leave this code here for reference. If you need help on how to implement this in your DLL, this is not the place and I can't be bothered to help doing that. My aim is to share the functions/variables I've found (specifically for SA-MP 0.3.7 R4) and hopefully people contribute whatever they found. If you don't like my codingstyle, don't be an asshat but just tell me what's wrong and how to improve it.
I've got a request as well. Anyone can share where to find info for the scoreboard, like player names/id/score? I'm asking specifically for 0.3.7 R4. Thank you!
I've got a request as well. Anyone can share where to find info for the scoreboard, like player names/id/score? I'm asking specifically for 0.3.7 R4. Thank you!
C++:
#include <vector>
#include <string>
#include <windows.h>
uintptr_t sampModuleBase = 0;
bool initialized = false;
void Initialize()
{
sampModuleBase = (uintptr_t)GetModuleHandle("samp.dll");
if(sampModuleBase != 0)
initialized = true;
}
uintptr_t ReadPointerChain(uintptr_t base_address, std::vector<unsigned int> offsets)
{
uintptr_t address = base_address;
for(size_t i = 0; i < offsets.size(); i++)
{
address = *(uintptr_t*)address;
address += offsets[i];
}
return address;
}
bool IsChatOpen()
{
if(!initialized) return false;
bool open = *(bool*)ReadPointerChain(sampModuleBase + 0x26E9FC, {0x14E0});
return open;
}
bool IsDialogOpen()
{
if(!initialized) return false;
bool open = *(bool*)ReadPointerChain(sampModuleBase + 0x0026EAA8, {0x13});
return open;
}
bool IsScoreboardOpen()
{
if(!initialized) return false;
bool open = *(bool*)ReadPointerChain(sampModuleBase + 0x26E9C4, {0x0});
return open;
}
void SendLocalMessage(const std::string& message)
{
if(!initialized) return;
DWORD chatpointer = sampModuleBase + (0x26E9FC - 4);
DWORD chatInfo = *(DWORD*)chatpointer;
void* cInfo = (void*)chatInfo;
char* msg = &message[0];
reinterpret_cast<void(__cdecl*)(void*, char*)>(sampModuleBase + 0x680B0)(cInfo, msg);
}
void SendChatMessage(const std::string& message)
{
if(!initialized) return;
char* msg = &message[0];
reinterpret_cast<void(__cdecl*)(char*, bool)>(sampModuleBase + 0x5A00)(msg, false);
}
void SendCommand(const std::string& command)
{
if(!initialized) return;
char* msg = &command[0];
reinterpret_cast<void(__cdecl*)(char*, bool)>(sampModuleBase + 0x698C0)(msg, false);
}
std::string GetLastReceivedChatText()
{
if(!initialized) return std::string("");
DWORD offset = 0x132 + (99 * 0xFC) + 0x20;
char* msg = (char*)ReadPointerChain(sampModuleBase + 0x26E9F8, {offset});
return std::string(msg);
}
std::string GetLastReceivedChatSender()
{
if(!initialized) return std::string("");
DWORD offset = 0x132 + (99 * 0xFC) + 4;
char* msg = (char*)ReadPointerChain(sampModuleBase + 0x26E9F8, {offset});
return std::string(msg);
}
std::string GetChatLogPath()
{
if(!initialized) return std::string("");
char* msg = (char*)ReadPointerChain(sampModuleBase + 0x26E9F8, {0x011});
return std::string(msg);
}
Last edited: