44 lines
1.8 KiB
Lua
44 lines
1.8 KiB
Lua
local PLUGIN = PLUGIN
|
|
PLUGIN.name = "Presencer"
|
|
PLUGIN.author = "RefoselTeamWork"
|
|
PLUGIN.desc = "Добавляет Rich Presence в Discord и Steam Presence."
|
|
PLUGIN.DiscordID = "1424715569265115247"
|
|
PLUGIN.RefreshTime = 10
|
|
PLUGIN.DiscordStart = PLUGIN.DiscordStart or -1
|
|
|
|
if (CLIENT) then
|
|
if util.IsBinaryModuleInstalled("gdiscord") then
|
|
require("gdiscord")
|
|
|
|
function DiscordUpdate()
|
|
local rpc_data = {}
|
|
if LocalPlayer():GetCharacter() then
|
|
rpc_data["details"] = "Игрок: " .. LocalPlayer():Nick()
|
|
rpc_data["state"] = "Фракция: " .. (ix.faction.Get( LocalPlayer():GetFaction() ) and ix.faction.Get( LocalPlayer():GetFaction() ).name or "Неизвестна")
|
|
rpc_data["buttonPrimaryLabel"] = "Присоединиться к серверу"
|
|
rpc_data["buttonPrimaryUrl"] = "steam://connect/" .. game.GetIPAddress()
|
|
rpc_data["partySize"] = player.GetCount()
|
|
rpc_data["partyMax"] = game.MaxPlayers()
|
|
rpc_data["largeImageKey"] = "logo"
|
|
rpc_data["largeImageText"] = "Front-Team | Война на Украине"
|
|
rpc_data["startTimestamp"] = PLUGIN.DiscordStart
|
|
end
|
|
DiscordUpdateRPC(rpc_data)
|
|
end
|
|
end
|
|
|
|
if util.IsBinaryModuleInstalled("steamrichpresencer") then
|
|
require("steamrichpresencer")
|
|
steamworks.SetRichPresence("generic", "Сервер Front-Team | Война на Украине")
|
|
end
|
|
|
|
function PLUGIN:Initialize()
|
|
if util.IsBinaryModuleInstalled("gdiscord") then
|
|
PLUGIN.DiscordStart = os.time()
|
|
DiscordRPCInitialize(PLUGIN.DiscordID)
|
|
DiscordUpdate()
|
|
timer.Create("DiscordRPCTimer", PLUGIN.RefreshTime, 0, DiscordUpdate)
|
|
end
|
|
end
|
|
end
|