local ffi = require("ffi") or error("ffi not found")
local js = panorama['open']()
local LobbyAPI = js['LobbyAPI']
local FirendsApi = js['FriendsListAPI']
local PartyListAPI = js['PartyListAPI']
local GetClipboardTextCount = vtable_bind("vgui2.dll", "VGUI_System010", 7, "int(__thiscall*)(void*)")
local GetClipboardText = vtable_bind("vgui2.dll", "VGUI_System010", 11, "int(__thiscall*)(void*, int, const char*, int)")
--client.dll 51 A1 ? ? ? ? 85 C0 75 ? A1 ? ? ? ? 68 90 00 00 00 returns singleton
local getFriendsListApiAddress = client.find_signature("client.dll", "\x51\xA1\xCC\xCC\xCC\xCC\x85\xC0\x75\xCC\xA1\xCC\xCC\xCC\xCC\x68\x90\x00\x00\x00") or error("getFriendsListApiAddress not found")
local friendsListSingleton = ffi.cast("void*(__stdcall*)()", getFriendsListApiAddress)()
--client.dll 55 8B EC 83 E4 F8 83 EC 1C 53 56 57 8B F1 FF 15 invite func
local inviteXuidAddress = client.find_signature("client.dll", "\x55\x8B\xEC\x83\xE4\xF8\x83\xEC\x1C\x53\x56\x57\x8B\xF1\xFF\x15") or error("inviteXuidAddress not found")
local inviteXuid = ffi.cast("void(__thiscall*)(void*, uint64_t)", inviteXuidAddress)
local newCharArray = ffi.typeof("char[?]")
local spam_Enabled = ui.new_checkbox("MISC", "Miscellaneous", "Enable invitespam")
local spam_TargetXuid = ui.new_textbox("MISC", "Miscellaneous", "Invitespam steamid")
LobbyAPI.CreateSession()
PartyListAPI.SessionCommand('MakeOnline', '')
local function GetSteamIDFromClipboard()
local textLength = GetClipboardTextCount()
local function IsNumeric(str)
return tonumber(str) ~= nil
end
if textLength > 0 then
local text = newCharArray(textLength)
GetClipboardText(0, text, textLength)
text = ffi.string(text, textLength - 1)
-- if its not a number, parse it
if not IsNumeric(text) then
local result = string.match(text, "steamcommunity.com/profiles/(%d+)")
if result then
ui.set(spam_TargetXuid, result)
return
end
print("[InviteNoCooldown] Invalid steamid in clipboard")
-- check if it is a friend code
if string.len(text) == 10 then
if string.sub(text, 6, 6) == "-" then
local xuid = FirendsApi.GetXuidFromFriendCode(text)
print(xuid)
ui.set(spam_TargetXuid, xuid)
return
end
end
--[[steamId = string.match(text, "steamcommunity.com/id/(.*)")
if steamId then
-- remove the trailing / if exists
if steamId:sub(-1) == "/" then
steamId = steamId:sub(1, -2)
end
print(steamId)
end]]
else
-- check if it starts with 765611
if text:sub(1, 7) == "7656119" then
ui.set(spam_TargetXuid, text)
return
end
end
end
end
local spam_ImportFromClipboard = ui.new_button("Misc", "Miscellaneous", "Import from clipboard", function()
GetSteamIDFromClipboard()
end)
local xuidBase = ffi.new("uint64_t", 76561100000000000LL)
local function invite()
local targetXuidStr = ui.get(spam_TargetXuid)
local targetXuid = tonumber(targetXuidStr:sub(7, #targetXuidStr))
if targetXuid ~= nil and #targetXuidStr == 17 then
inviteXuid(friendsListSingleton, xuidBase + ffi.new("uint64_t", targetXuid))
end
end
ui.set_callback(spam_Enabled, function(state)
local handle_event = ui.get(state) and client.set_event_callback or client.unset_event_callback
if not LobbyAPI.IsSessionActive() then
LobbyAPI.CreateSession()
PartyListAPI.SessionCommand('MakeOnline', '')
else
PartyListAPI.SessionCommand('MakeOnline', '')
end
handle_event("paint_ui", invite)
end)