[Server] Add SetRuleString and SetRuleValue to script API

This commit is contained in:
Koncord 2017-05-07 02:13:41 +08:00
parent a0b71eda23
commit a4a77ddeff
2 changed files with 18 additions and 0 deletions

View file

@ -144,3 +144,17 @@ void ScriptFunctions::SetServerPassword(const char *passw) noexcept
{ {
mwmp::Networking::getPtr()->setServerPassword(passw); mwmp::Networking::getPtr()->setServerPassword(passw);
} }
void ScriptFunctions::SetRuleString(const char *key, const char *value) noexcept
{
auto mc = mwmp::Networking::getPtr()->getMasterClient();
if(mc)
mc->SetRuleString(key, value);
}
void ScriptFunctions::SetRuleValue(const char *key, double value) noexcept
{
auto mc = mwmp::Networking::getPtr()->getMasterClient();
if(mc)
mc->SetRuleValue(key, value);
}

View file

@ -69,6 +69,8 @@ public:
static void SetModname(const char* name) noexcept; static void SetModname(const char* name) noexcept;
static void SetHostname(const char* name) noexcept; static void SetHostname(const char* name) noexcept;
static void SetServerPassword(const char *passw) noexcept; static void SetServerPassword(const char *passw) noexcept;
static void SetRuleString(const char *key, const char *value) noexcept;
static void SetRuleValue(const char *key, double value) noexcept;
static constexpr ScriptFunctionData functions[]{ static constexpr ScriptFunctionData functions[]{
{"CreateTimer", ScriptFunctions::CreateTimer}, {"CreateTimer", ScriptFunctions::CreateTimer},
@ -92,6 +94,8 @@ public:
{"SetModname", ScriptFunctions::SetModname}, {"SetModname", ScriptFunctions::SetModname},
{"SetHostname", ScriptFunctions::SetHostname}, {"SetHostname", ScriptFunctions::SetHostname},
{"SetServerPassword", ScriptFunctions::SetServerPassword}, {"SetServerPassword", ScriptFunctions::SetServerPassword},
{"SetRuleString", ScriptFunctions::SetRuleString},
{"SetRuleValue", ScriptFunctions::SetRuleValue},
POSITIONAPI, POSITIONAPI,
CELLAPI, CELLAPI,