Skip to content

Commit 2caa33e

Browse files
committed
feat(core): Menu Translation, CS2ServerGuidelines SDK Check
1 parent 9365efa commit 2caa33e

File tree

6 files changed

+158
-7
lines changed

6 files changed

+158
-7
lines changed

PackageScript

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ plugins_folder = builder.AddFolder(os.path.join('addons', MMSPlugin.plugin_name,
7979
builder.AddCopy(os.path.join(builder.sourcePath, 'plugin_files', 'plugins', '.gitignore'), plugins_folder)
8080

8181
translations_folder = builder.AddFolder(os.path.join('addons', MMSPlugin.plugin_name, 'translations'))
82-
builder.AddCopy(os.path.join(builder.sourcePath, 'plugin_files', 'translations', '.gitignore'), translations_folder)
82+
builder.AddCopy(os.path.join(builder.sourcePath, 'plugin_files', 'translations', '.gitignore'), translations_folder)
83+
builder.AddCopy(os.path.join(builder.sourcePath, 'plugin_files', 'translations', 'translation.core.json'), translations_folder)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"seconds": {
3+
"en": "{TIME} second(s)",
4+
"ro": "{TIME} secunde",
5+
"es": "{TIME} segundo(s)"
6+
},
7+
"minutes": {
8+
"en": "{TIME} minute(s)",
9+
"ro": "{TIME} minut(e)",
10+
"es": "{TIME} minuto(s)"
11+
},
12+
"hours": {
13+
"en": "{TIME} hour(s)",
14+
"ro": "{TIME} ore",
15+
"es": "{TIME} hora(s)"
16+
},
17+
"days": {
18+
"en": "{TIME} day(s)",
19+
"ro": "{TIME} zi(le)",
20+
"es": "{TIME} día(s)"
21+
},
22+
"forever": {
23+
"en": "Forever",
24+
"ro": "Pentru totdeauna",
25+
"es": "Para siempre"
26+
},
27+
"never": {
28+
"en": "Never",
29+
"ro": "Niciodată",
30+
"es": "Nunca"
31+
},
32+
"menu.next": {
33+
"en": "Next",
34+
"ro": "Următorul"
35+
},
36+
"menu.back": {
37+
"en": "Back",
38+
"ro": "Înapoi"
39+
},
40+
"menu.exit": {
41+
"en": "Exit",
42+
"ro": "Ieșire"
43+
},
44+
"menu.footer": {
45+
"en": "SHIFT - Cycle | E - Select | Page {PAGE}/{MAXPAGES}",
46+
"ro": "SHIFT - Schimbă | E - Selectează | Pagina {PAGE}/{MAXPAGES}"
47+
}
48+
}

src/menus/Menu.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ void Menu::ProcessOptions()
5959
if (processedItems == (pages == 0 ? 4 : 3))
6060
{
6161
if (options.size() - totalProcessedItems > 0)
62-
tempmap.push_back({"Next", "menunext"});
62+
tempmap.push_back({g_translations->FetchTranslation("core.menu.next"), "menunext"});
6363
if (pages != 0)
64-
tempmap.push_back({"Back", "menuback"});
64+
tempmap.push_back({g_translations->FetchTranslation("core.menu.back"), "menuback"});
6565

66-
tempmap.push_back({"Exit", "menuexit"});
66+
tempmap.push_back({g_translations->FetchTranslation("core.menu.exit"), "menuexit"});
6767

6868
processedItems = 0;
6969
pages++;
@@ -75,9 +75,9 @@ void Menu::ProcessOptions()
7575
if (tempmap.size() > 0)
7676
{
7777
if (this->processedOptions.size() != 0)
78-
tempmap.push_back({"Back", "menuback"});
78+
tempmap.push_back({g_translations->FetchTranslation("core.menu.back"), "menuback"});
7979

80-
tempmap.push_back({"Exit", "menuexit"});
80+
tempmap.push_back({g_translations->FetchTranslation("core.menu.exit"), "menuexit"});
8181

8282
processedItems = 0;
8383
this->processedOptions.push_back(tempmap);
@@ -101,7 +101,7 @@ void Menu::RegeneratePage(int page, int selected)
101101
for (int i = 0; i < processedOptions[page - 1].size(); i++)
102102
stringPage += string_format("<div><font color=\"#%s\">%s%s</font></div><br/>", (i == selected ? this->color.c_str() : "ffffff"), (i == selected ? "➤&nbsp;" : "&nbsp;&nbsp;&nbsp;&nbsp;"), processedOptions[page - 1][i].first.c_str());
103103

104-
stringPage += string_format("<div><font class='fontSize-s'>SHIFT - Cycle | E - Select | Page %d/%d</font></div>", page, processedOptions.size());
104+
stringPage += replace(replace(g_translations->FetchTranslation("core.menu.footer"), "{PAGE}", std::to_string(page)), "{MAXPAGES}", std::to_string(processedOptions.size()));
105105

106106
this->generatedPages[page - 1] = stringPage;
107107
}

src/menus/Menu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <string>
44
#include <map>
55
#include <vector>
6+
#include "../translations/Translations.h"
67

78
class Menu
89
{

src/plugins/core/scripting/schema.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,49 @@
11
#include "../scripting.h"
22

3+
std::map<std::string, bool> BlockedCS2GuidelinesFields = {
4+
{"m_bIsValveDS", true},
5+
{"m_bIsQuestEligible", true},
6+
{"m_iEntityLevel", true},
7+
{"m_iItemIDHigh", true},
8+
{"m_iItemIDLow", true},
9+
{"m_iAccountID", true},
10+
{"m_iEntityQuality", true},
11+
{"m_bInitialized", true},
12+
{"m_szCustomName", true},
13+
{"m_iAttributeDefinitionIndex", true},
14+
{"m_iRawValue32", true},
15+
{"m_iRawInitialValue32", true},
16+
{"m_flValue", true},
17+
{"m_flInitialValue", true},
18+
{"m_bSetBonus", true},
19+
{"m_nRefundableCurrency", true},
20+
{"m_OriginalOwnerXuidLow", true},
21+
{"m_OriginalOwnerXuidHigh", true},
22+
{"m_nFallbackPaintKit", true},
23+
{"m_nFallbackSeed", true},
24+
{"m_flFallbackWear", true},
25+
{"m_nFallbackStatTrak", true},
26+
{"m_iCompetitiveWins", true},
27+
{"m_iCompetitiveRanking", true},
28+
{"m_iCompetitiveRankType", true},
29+
{"m_iCompetitiveRankingPredicted_Win", true},
30+
{"m_iCompetitiveRankingPredicted_Loss", true},
31+
{"m_iCompetitiveRankingPredicted_Tie", true},
32+
{"m_nActiveCoinRank", true},
33+
{"m_nMusicID", true},
34+
};
35+
336
void WriteSchemaPtrValue(void *ptr, const char *className, const char *fieldName, bool isStruct, byte *value, int size)
437
{
38+
if (BlockedCS2GuidelinesFields.find(fieldName) != BlockedCS2GuidelinesFields.end() && g_Config->FetchValue<bool>("core.FollowCS2ServerGuidelines"))
39+
{
40+
PRINTF("Getting or setting %s::%s is not permitted due to CS2 Server Guidelines violation.\n", className, fieldName);
41+
PRINT("To get or set this value, switch to false the \"core.FollowCS2ServerGuidelines\" field.\n");
42+
PRINT("Note: Using non-compliant field values can result in a GSLT ban.\n");
43+
PRINT("Note: We are not providing any kind of support for people which are using these fields.\n");
44+
return;
45+
}
46+
547
auto datatable_hash = hash_32_fnv1a_const(className);
648
auto prop_hash = hash_32_fnv1a_const(fieldName);
749
const auto m_key = sch::GetOffset(className, datatable_hash, fieldName, prop_hash);
@@ -13,6 +55,15 @@ void WriteSchemaPtrValue(void *ptr, const char *className, const char *fieldName
1355

1456
void *GetSchemaPtr(void *ptr, const char *className, const char *fieldName)
1557
{
58+
if (BlockedCS2GuidelinesFields.find(fieldName) != BlockedCS2GuidelinesFields.end() && g_Config->FetchValue<bool>("core.FollowCS2ServerGuidelines"))
59+
{
60+
PRINTF("Getting or setting %s::%s is not permitted due to CS2 Server Guidelines violation.\n", className, fieldName);
61+
PRINT("To get or set this value, switch to false the \"core.FollowCS2ServerGuidelines\" field.\n");
62+
PRINT("Note: Using non-compliant field values can result in a GSLT ban.\n");
63+
PRINT("Note: We are not providing any kind of support for people which are using these fields.\n");
64+
return 0;
65+
}
66+
1667
auto datatable_hash = hash_32_fnv1a_const(className);
1768
auto prop_hash = hash_32_fnv1a_const(fieldName);
1869
auto m_key = sch::GetOffset(className, datatable_hash, fieldName, prop_hash);

src/plugins/core/scripting_includes.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,32 @@
1515
///////////////// Schema //////////////
1616
////////////////////////////////////////////////////////////
1717

18+
extern std::map<std::string, bool> BlockedCS2GuidelinesFields;
19+
1820
template <typename T>
1921
T GetSchemaValue(void *ptr, const char *className, const char *fieldName)
2022
{
23+
if (BlockedCS2GuidelinesFields.find(fieldName) != BlockedCS2GuidelinesFields.end() && g_Config->FetchValue<bool>("core.FollowCS2ServerGuidelines"))
24+
{
25+
PRINTF("Getting or setting %s::%s is not permitted due to CS2 Server Guidelines violation.\n", className, fieldName);
26+
PRINT("To get or set this value, switch to false the \"core.FollowCS2ServerGuidelines\" field.\n");
27+
PRINT("Note: Using non-compliant field values can result in a GSLT ban.\n");
28+
PRINT("Note: We are not providing any kind of support for people which are using these fields.\n");
29+
30+
if constexpr (std::is_same<T, Vector>::value)
31+
return Vector(0, 0, 0);
32+
else if constexpr (std::is_same<T, QAngle>::value)
33+
return QAngle(0, 0, 0);
34+
else if constexpr (std::is_same<T, Vector2D>::value)
35+
return Vector2D(0, 0);
36+
else if constexpr (std::is_same<T, Vector4D>::value)
37+
return Vector4D(0, 0, 0, 0);
38+
else if constexpr (std::is_same<T, Color>::value)
39+
return Color(0, 0, 0, 0);
40+
else
41+
return (T)0;
42+
}
43+
2144
auto datatable_hash = hash_32_fnv1a_const(className);
2245
auto prop_hash = hash_32_fnv1a_const(fieldName);
2346
auto m_key = sch::GetOffset(className, datatable_hash, fieldName, prop_hash);
@@ -28,6 +51,15 @@ T GetSchemaValue(void *ptr, const char *className, const char *fieldName)
2851
template <typename T>
2952
T *GetSchemaValuePtr(void *ptr, const char *className, const char *fieldName)
3053
{
54+
if (BlockedCS2GuidelinesFields.find(fieldName) != BlockedCS2GuidelinesFields.end() && g_Config->FetchValue<bool>("core.FollowCS2ServerGuidelines"))
55+
{
56+
PRINTF("Getting or setting %s::%s is not permitted due to CS2 Server Guidelines violation.\n", className, fieldName);
57+
PRINT("To get or set this value, switch to false the \"core.FollowCS2ServerGuidelines\" field.\n");
58+
PRINT("Note: Using non-compliant field values can result in a GSLT ban.\n");
59+
PRINT("Note: We are not providing any kind of support for people which are using these fields.\n");
60+
return 0;
61+
}
62+
3163
auto datatable_hash = hash_32_fnv1a_const(className);
3264
auto prop_hash = hash_32_fnv1a_const(fieldName);
3365
auto m_key = sch::GetOffset(className, datatable_hash, fieldName, prop_hash);
@@ -42,6 +74,15 @@ void WriteSchemaPtrValue(void *ptr, const char *className, const char *fieldName
4274
template <typename T>
4375
void SetSchemaValue(void *ptr, const char *className, const char *fieldName, bool isStruct, T value)
4476
{
77+
if (BlockedCS2GuidelinesFields.find(fieldName) != BlockedCS2GuidelinesFields.end() && g_Config->FetchValue<bool>("core.FollowCS2ServerGuidelines"))
78+
{
79+
PRINTF("Getting or setting %s::%s is not permitted due to CS2 Server Guidelines violation.\n", className, fieldName);
80+
PRINT("To get or set this value, switch to false the \"core.FollowCS2ServerGuidelines\" field.\n");
81+
PRINT("Note: Using non-compliant field values can result in a GSLT ban.\n");
82+
PRINT("Note: We are not providing any kind of support for people which are using these fields.\n");
83+
return;
84+
}
85+
4586
auto datatable_hash = hash_32_fnv1a_const(className);
4687
auto prop_hash = hash_32_fnv1a_const(fieldName);
4788

@@ -63,6 +104,15 @@ void SetSchemaValue(void *ptr, const char *className, const char *fieldName, boo
63104
template <typename T>
64105
void SetSchemaValueCUtlVector(void *ptr, const char *className, const char *fieldName, bool isStruct, std::vector<T> value)
65106
{
107+
if (BlockedCS2GuidelinesFields.find(fieldName) != BlockedCS2GuidelinesFields.end() && g_Config->FetchValue<bool>("core.FollowCS2ServerGuidelines"))
108+
{
109+
PRINTF("Getting or setting %s::%s is not permitted due to CS2 Server Guidelines violation.\n", className, fieldName);
110+
PRINT("To get or set this value, switch to false the \"core.FollowCS2ServerGuidelines\" field.\n");
111+
PRINT("Note: Using non-compliant field values can result in a GSLT ban.\n");
112+
PRINT("Note: We are not providing any kind of support for people which are using these fields.\n");
113+
return;
114+
}
115+
66116
auto datatable_hash = hash_32_fnv1a_const(className);
67117
auto prop_hash = hash_32_fnv1a_const(fieldName);
68118

0 commit comments

Comments
 (0)