local ffi = require("ffi")
ffi.cdef([[
typedef struct {
const char* state;
const char* details;
int64_t startTimestamp;
int64_t endTimestamp;
const char* largeImageKey;
const char* largeImageText;
const char* smallImageKey;
const char* smallImageText;
const char* partyId;
int partySize;
int partyMax;
const char* matchSecret;
const char* joinSecret;
const char* spectateSecret;
int8_t instance;
} DiscordRichPresence;
void Discord_Initialize(const char* applicationId,
int handlers,
int autoRegister,
const char* optionalSteamId);
void Discord_UpdatePresence(const DiscordRichPresence* presence);
]])
local drpc = ffi.load("moonloader/lib/discord-rpc.dll")
local rpc = ffi.new("DiscordRichPresence")
function main()
while not isSampAvailable() do wait(0) end
while true do
wait(0)
serverName = sampGetCurrentServerName()
serverIp, serverPort = sampGetCurrentServerAddress()
if string.find(serverName, 'SA-MP') then
rpc.largeImageKey = 'sa_connecting'
rpc.details = 'Connecting to '..serverIp..':'..serverPort
elseif string.find(serverName, 'TRAINING') then
rpc.largeImageKey = 'sa_training'
elseif string.find(serverName, 'TRAINING') then
rpc.largeImageKey = 'sa_gambit'
elseif string.find(serverName, 'HackMySoftware') then
rpc.largeImageKey = 'sa_hms'
end
end
end