[Script] Add optional toggle parameter to ufo/noclip

This commit is contained in:
FutureRave 2021-10-16 17:44:22 +01:00
parent eda10589a1
commit 4d2356f824
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955

View File

@ -532,7 +532,7 @@ namespace Components
Script::ScriptStorage.clear(); Script::ScriptStorage.clear();
}); });
Script::AddFunction("NoClip", [](Game::scr_entref_t entref) Script::AddFunction("Noclip", [](Game::scr_entref_t entref)
{ {
if (entref >= Game::MAX_GENTITIES || Game::g_entities[entref].client == nullptr) if (entref >= Game::MAX_GENTITIES || Game::g_entities[entref].client == nullptr)
{ {
@ -540,7 +540,21 @@ namespace Components
return; return;
} }
Game::g_entities[entref].client->flags ^= Game::PLAYER_FLAG_NOCLIP; if (Game::Scr_GetNumParam() == 1 && Game::Scr_GetType(0) == Game::VAR_INTEGER)
{
if (Game::Scr_GetInt(0))
{
Game::g_entities[entref].client->flags |= Game::PLAYER_FLAG_NOCLIP;
}
else
{
Game::g_entities[entref].client->flags &= ~Game::PLAYER_FLAG_NOCLIP;
}
}
else
{
Game::g_entities[entref].client->flags ^= Game::PLAYER_FLAG_NOCLIP;
}
}); });
Script::AddFunction("Ufo", [](Game::scr_entref_t entref) Script::AddFunction("Ufo", [](Game::scr_entref_t entref)
@ -551,7 +565,21 @@ namespace Components
return; return;
} }
Game::g_entities[entref].client->flags ^= Game::PLAYER_FLAG_UFO; if (Game::Scr_GetNumParam() == 1 && Game::Scr_GetType(0) == Game::VAR_INTEGER)
{
if (Game::Scr_GetInt(0))
{
Game::g_entities[entref].client->flags |= Game::PLAYER_FLAG_UFO;
}
else
{
Game::g_entities[entref].client->flags &= ~Game::PLAYER_FLAG_UFO;
}
}
else
{
Game::g_entities[entref].client->flags ^= Game::PLAYER_FLAG_UFO;
}
}); });
} }