Add sv_disableCustomClasses
This commit is contained in:
parent
b4591b6e2f
commit
e54e17d6b0
34
data/cdata/scripts/mp/classes.gsc
Normal file
34
data/cdata/scripts/mp/classes.gsc
Normal file
@ -0,0 +1,34 @@
|
||||
main()
|
||||
{
|
||||
replacefunc(maps\mp\gametypes\_menus::getclasschoice, ::getclasschoice);
|
||||
}
|
||||
|
||||
getclasschoice(choice)
|
||||
{
|
||||
if (choice <= 100)
|
||||
{
|
||||
if (getdvar("sv_disableCustomClasses") == "1")
|
||||
{
|
||||
return "class0";
|
||||
}
|
||||
|
||||
choice = "custom" + choice;
|
||||
}
|
||||
else if (choice <= 200)
|
||||
{
|
||||
choice -= 101;
|
||||
choice = "class" + choice;
|
||||
}
|
||||
else if ( choice <= 206 )
|
||||
{
|
||||
choice -= 200;
|
||||
choice = "axis_recipe" + choice;
|
||||
}
|
||||
else
|
||||
{
|
||||
choice -= 206;
|
||||
choice = "allies_recipe" + choice;
|
||||
}
|
||||
|
||||
return choice;
|
||||
}
|
13
data/cdata/ui_scripts/classes/__init__.lua
Normal file
13
data/cdata/ui_scripts/classes/__init__.lua
Normal file
@ -0,0 +1,13 @@
|
||||
if (Engine.InFrontend()) then
|
||||
return
|
||||
end
|
||||
|
||||
local getclasscount = Cac.GetCustomClassCount
|
||||
Cac.GetCustomClassCount = function(...)
|
||||
local value = Engine.GetDvarBool("sv_disableCustomClasses")
|
||||
if (value) then
|
||||
return 0
|
||||
end
|
||||
|
||||
return getclasscount(...)
|
||||
end
|
@ -6,6 +6,7 @@
|
||||
#include "fastfiles.hpp"
|
||||
|
||||
#include "game/game.hpp"
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/memory.hpp>
|
||||
@ -260,6 +261,9 @@ namespace weapon
|
||||
utils::hook::call(0x41C595_b, g_find_config_string_index_stub);
|
||||
|
||||
utils::hook::call(0x36B4D4_b, load_ddl_asset_stub);
|
||||
|
||||
dvars::register_bool("sv_disableCustomClasses",
|
||||
false, game::DVAR_FLAG_REPLICATED, "Disable custom classes on server");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user