Skip to content

Commit 3c200db

Browse files
committed
init(project): First commit.
0 parents  commit 3c200db

File tree

5 files changed

+137
-0
lines changed

5 files changed

+137
-0
lines changed

README.MD

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<p align="center">
2+
<a href="https://github.com/swiftly-solution/faceit-level">
3+
<img src="https://cdn.swiftlycs2.net/swiftly-logo.png" alt="SwiftlyLogo" width="80" height="80">
4+
</a>
5+
6+
<h3 align="center">[Swiftly] Faceit Level</h3>
7+
8+
<p align="center">
9+
A simple plugin for Swiftly that queries the level faceit of a player and add the icon on the scoreboard.
10+
<br/>
11+
</p>
12+
</p>
13+
14+
<p align="center">
15+
<img src="https://img.shields.io/github/downloads/swiftly-solution/faceit-level/total" alt="Downloads">
16+
<img src="https://img.shields.io/github/contributors/swiftly-solution/faceit-level?color=dark-green" alt="Contributors">
17+
<img src="https://img.shields.io/github/issues/swiftly-solution/faceit-level" alt="Issues">
18+
<img src="https://img.shields.io/github/license/swiftly-solution/faceit-level" alt="License">
19+
</p>
20+
21+
---
22+
23+
### Installation 👀
24+
25+
1. Download the newest [release](https://github.com/swiftly-solution/faceit-level/releases).
26+
2. Everything is drag & drop, so i think you can do it!
27+
3. You can either make the workshop addon yourself or use ours that it's publicly available [here](https://steamcommunity.com/sharedfiles/filedetails/?id=3369129706)
28+
29+
### Instructions on making the addon 📝
30+
31+
1. Download the `workshop.rar` archive from the GitHub repository.
32+
2. Navigate to your game files, which by default are in: `Steam\steamapps\common\Counter-Strike Global Offensive\game\csgo` and open the `gameinfo.gi` file. There, scroll down until you find `VpkDirectories`, add a new entry with the `panorama/images/econ/status_icons` path, it should look like this:
33+
`"include" "panorama/images/econ/status_icons"`
34+
3. Open the Workshop Tools and make a new addon, there, upload the `panorama` folder from the archive onto `Steam\steamapps\common\Counter-Strike Global Offensive\game\csgo_addons\YOUR_ADDON_NAME` and onto `Steam\steamapps\common\Counter-Strike Global Offensive\content\csgo_addons\YOUR_ADDON_NAME`
35+
4. Upload the addon to the workshop and wait for the approval.
36+
5. Delete the entry that we did in gameinfo.gi, (this is the important as you can't join any community servers with modified gameinfo.gi)
37+
38+
### Configuring the plugin 🧐
39+
40+
- After installing the plugin, you need to change the default values from `addons/swiftly/configs/faceit-level.json`
41+
- In order to create an Faceit API Key, follow these instructions:
42+
43+
1. Click [here](https://developers.faceit.com/apps/new) and make a new app.
44+
2. Go to `API KEYS` and press on the plus sign, at the API Type select `Client-Side`.
45+
3. Change the API Key from `addons/swiftly/configs/faceit-level.json` with your freshly generated Key.
46+
47+
### Credits ✨
48+
49+
- Thanks to Pisex for providing the images (and the base mm plugin too).
50+
51+
### Creating A Pull Request 😃
52+
53+
1. Fork the Project
54+
2. Create your Feature Branch
55+
3. Commit your Changes
56+
4. Push to the Branch
57+
5. Open a Pull Request
58+
59+
### Have ideas/Found bugs? 💡
60+
61+
Join [Swiftly Discord Server](https://swiftlycs2.net/discord) and send a message in the topic from `📕╎plugins-sharing` of this plugin!
62+
63+
---

configs/plugins/faceit-level.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"apikey": "YOUR-API-KEY"
3+
}

plugins/faceit-level/core.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function GetPluginAuthor()
2+
return "Swiftly Solution"
3+
end
4+
5+
function GetPluginVersion()
6+
return "1.0.0"
7+
end
8+
9+
function GetPluginName()
10+
return "Faceit Level"
11+
end
12+
13+
function GetPluginWebsite()
14+
return "https://github.com/swiftly-solution/faceit-level"
15+
end

plugins/faceit-level/main.lua

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
-- thanks Pisex for providing PoC and images --
2+
3+
local iLevels = {
4+
[1] = 1088,
5+
[2] = 1087,
6+
[3] = 1032,
7+
[4] = 1055,
8+
[5] = 1041,
9+
[6] = 1074,
10+
[7] = 1039,
11+
[8] = 1067,
12+
[9] = 1061,
13+
[10] = 1017
14+
}
15+
16+
AddEventHandler("OnClientConnect", function (event, playerid)
17+
local player = GetPlayer(playerid)
18+
if not player or player:IsFakeClient() then return end
19+
20+
local apiKey = config:Fetch("faceit-level.apikey")
21+
local url = "https://open.faceit.com/data/v4/players?game=cs2&game_player_id=" .. player:GetSteamID()
22+
23+
local function callback(status, body, headers, err)
24+
if status ~= 200 and status ~= 404 then
25+
print("HTTP request failed with status code:", status)
26+
return
27+
end
28+
29+
local responseData = json.decode(body)
30+
if not responseData then
31+
print("Failed to decode json")
32+
return
33+
end
34+
35+
local level = nil
36+
if responseData.games and responseData.games.cs2 and responseData.games.cs2.skill_level then
37+
level = responseData.games.cs2.skill_level
38+
player:SetVar("level", level)
39+
end
40+
end
41+
42+
local headers = { ["Authorization"] = "Bearer " .. apiKey }
43+
PerformHTTPRequest(url, callback, "GET", {}, headers)
44+
45+
end)
46+
47+
AddEventHandler("OnPlayerSpawn", function (event)
48+
local playerid = event:GetInt("userid")
49+
local player = GetPlayer(playerid)
50+
if not player or player:IsFakeClient() or not player:IsValid() then return end
51+
52+
local faceitLevel = iLevels[player:GetVar("level")] or 1088
53+
local ranks = player:CCSPlayerController().InventoryServices.Rank
54+
ranks[6] = faceitLevel
55+
player:CCSPlayerController().InventoryServices.Rank = ranks
56+
end)

workshop.rar

889 KB
Binary file not shown.

0 commit comments

Comments
 (0)