Модератор раздела "Создание скриптов для читов"
-
Автор темы
- #1
для синхронизации используется github
после создания файла (в моём случае players.json) напишите туда {}
вот как оно будет записывать данные
ну и сам код
и вот как в табе
после создания файла (в моём случае players.json) напишите туда {}
вот как оно будет записывать данные
JSON:
{"76561199759832711":true}
code_language.lua:
--@description: shared logo
--@author: uwukson4800
local http = require 'gamesense/http'
local base64 = require 'gamesense/base64'
local menu = {
scoreboard = ui.new_checkbox('MISC', 'Miscellaneous', 'shared icon')
}
local DEBUG_LEVEL = 0
local GITHUB_TOKEN = ""
local REPO_OWNER = ""
local REPO_NAME = ""
local FILE_PATH = "players.json"
local scoreboard_images = panorama.loadstring([[
var panel = null;
var name_panels = {};
var target_players = {};
var _Update = function(players) {
_Destroy();
target_players = players || {};
let scoreboard = $.GetContextPanel().FindChildTraverse("ScoreboardContainer").FindChildTraverse("Scoreboard");
if (!scoreboard) return;
scoreboard.FindChildrenWithClassTraverse("sb-row").forEach(function(row) {
if (target_players[row.m_xuid]) {
row.style.backgroundColor = "rgb(0, 0, 0)";
row.style.border = "1px solid rgb(94, 94, 94)";
row.Children().forEach(function(child) {
let nameLabel = child.FindChildTraverse("name");
if (nameLabel) {
nameLabel.style.color = "rgb(155, 155, 155)";
nameLabel.style.fontFamily = "Stratum2 Bold Monodigit";
nameLabel.style.fontWeight = "bold";
}
if (nameLabel) {
let parent = nameLabel.GetParent();
parent.style.flowChildren = "left";
let image_panel = $.CreatePanel("Panel", parent, "custom_image_panel_" + row.m_xuid);
let layout = `
<root>
<Panel style="flow-children: left; margin-right: 5px;">
<Image textureheight="24" texturewidth="24" src="https://yougame.biz/data/avatars/l/279/279781.jpg?1735272377" />
</Panel>
</root>
`;
image_panel.BLoadLayoutFromString(layout, false, false);
parent.MoveChildBefore(image_panel, nameLabel);
name_panels[row.m_xuid] = image_panel;
}
});
}
});
};
var _Destroy = function() {
let scoreboard = $.GetContextPanel().FindChildTraverse("ScoreboardContainer").FindChildTraverse("Scoreboard");
if (scoreboard) {
scoreboard.FindChildrenWithClassTraverse("sb-row").forEach(function(row) {
row.style.backgroundColor = null;
row.style.border = null;
row.Children().forEach(function(child) {
let nameLabel = child.FindChildTraverse("name");
if (nameLabel) {
nameLabel.style.color = null;
nameLabel.style.fontFamily = "Stratum2";
nameLabel.style.fontWeight = "normal";
}
});
});
}
for (let xuid in name_panels) {
if (name_panels[xuid] && name_panels[xuid].IsValid()) {
name_panels[xuid].DeleteAsync(0.0);
}
}
name_panels = {};
target_players = {};
};
return {
update: _Update,
remove: _Destroy
};
]], "CSGOHud")()
local function update_github_file(steamid, action)
local headers = {
["Authorization"] = "token " .. GITHUB_TOKEN,
["Accept"] = "application/vnd.github.v3+json"
}
local api_url = string.format(
"https://api.github.com/repos/%s/%s/contents/%s",
REPO_OWNER, REPO_NAME, FILE_PATH
)
http.get(api_url, {headers = headers}, function(success, response)
if not success then return end
local current_data = {}
local sha = nil
if response.status == 200 then
local content = json.parse(response.body)
sha = content.sha
current_data = json.parse(base64.decode(content.content))
end
if action == "add" then
current_data[tostring(steamid)] = true
else
current_data[tostring(steamid)] = nil
end
local update_data = {
message = string.format("update - %s %s", action, steamid),
content = base64.encode(json.stringify(current_data)),
sha = sha
}
http.put(api_url, {
headers = headers,
body = json.stringify(update_data)
}, function(success, response)
if success then
if DEBUG_LEVEL > 1 then
print("[shared] successfully fully updated")
end
end
end)
end)
end
scoreboard_images.update(target_players)
local function get_local_steamid()
return tostring(panorama.open().MyPersonaAPI.GetXuid())
end
client.set_event_callback("player_connect_full", function(e)
local steamid = get_local_steamid()
if steamid then
update_github_file(steamid, "add")
local target = client.userid_to_entindex(e.userid)
if target == entity.get_local_player() then
scoreboard_images.remove()
client.delay_call(0.5, function()
scoreboard_images.update(target_players)
end)
else
scoreboard_images.remove()
client.delay_call(0.5, function()
scoreboard_images.update(target_players)
end)
end
end
end)
local function update_target_players(github_data)
target_players = {}
for steamid, _ in pairs(github_data) do
target_players[steamid] = true
end
scoreboard_images.update(target_players)
end
local function check_and_update_github()
local headers = {
["Authorization"] = "token " .. GITHUB_TOKEN,
["Accept"] = "application/vnd.github.v3+json"
}
local api_url = string.format(
"https://api.github.com/repos/%s/%s/contents/%s",
REPO_OWNER, REPO_NAME, FILE_PATH
)
http.get(api_url, {headers = headers}, function(success, response)
if success and response.status == 200 then
local content = json.parse(response.body)
local current_data = json.parse(base64.decode(content.content))
update_target_players(current_data)
if DEBUG_LEVEL > 0 then
print("[shared] successfully updated")
end
end
end)
end
check_and_update_github()
local last_update = 0
local last_github_check = 0
client.set_event_callback('paint', function()
local current_time = globals.realtime()
if current_time - last_update >= 3.0 then
scoreboard_images.update(target_players)
last_update = current_time
end
if current_time - last_github_check >= 1.5 then
check_and_update_github()
last_github_check = current_time
end
ui.set_callback(menu.scoreboard, function()
local steamid = get_local_steamid()
if not ui.get(menu.scoreboard) then
scoreboard_images.remove()
update_github_file(steamid, "remove")
else
update_github_file(steamid, "add")
check_and_update_github()
end
end)
end)
client.set_event_callback("shutdown", function()
local steamid = get_local_steamid()
if steamid then
scoreboard_images.remove()
update_github_file(steamid, "remove")
end
end)