Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,14 +1925,6 @@ const CMtaVersion& CStaticFunctionDefinitions::GetPlayerVersion(CPlayer* pPlayer
return pPlayer->GetPlayerVersion();
}

bool CStaticFunctionDefinitions::GetPlayerScriptDebugLevel(CPlayer* pPlayer, unsigned int& uiLevel)
{
assert(pPlayer);

uiLevel = pPlayer->GetScriptDebugLevel();
return true;
}

bool CStaticFunctionDefinitions::SetPlayerName(CElement* pElement, const char* szName)
{
assert(pElement);
Expand Down
1 change: 0 additions & 1 deletion Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class CStaticFunctionDefinitions
static bool GetPlayerIP(CElement* pElement, SString& strOutIP);
static CAccount* GetPlayerAccount(CElement* pElement);
static const CMtaVersion& GetPlayerVersion(CPlayer* pPlayer);
static bool GetPlayerScriptDebugLevel(CPlayer* pPlayer, unsigned int& uiLevel);

// Player set functions
static bool SetPlayerMoney(CElement* pElement, long lMoney, bool bInstant);
Expand Down
76 changes: 15 additions & 61 deletions Server/mods/deathmatch/logic/luadefs/CLuaPlayerDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void CLuaPlayerDefs::LoadFunctions()
{"getPlayerACInfo", GetPlayerACInfo},
{"resendPlayerModInfo", ResendPlayerModInfo},
{"resendPlayerACInfo", ResendPlayerACInfo},
{"getPlayerScriptDebugLevel", GetPlayerScriptDebugLevel},
{"getPlayerScriptDebugLevel", ArgumentParser<GetPlayerScriptDebugLevel>},

// Player set funcs
{"setPlayerMoney", SetPlayerMoney},
Expand All @@ -65,7 +65,7 @@ void CLuaPlayerDefs::LoadFunctions()
{"setPlayerName", SetPlayerName},
{"detonateSatchels", DetonateSatchels},
{"takePlayerScreenShot", TakePlayerScreenShot},
{"setPlayerScriptDebugLevel", SetPlayerScriptDebugLevel},
{"setPlayerScriptDebugLevel", ArgumentParser<SetPlayerScriptDebugLevel>},

// All seeing eye
{"getPlayerAnnounceValue", GetPlayerAnnounceValue},
Expand Down Expand Up @@ -946,47 +946,23 @@ int CLuaPlayerDefs::TakePlayerScreenShot(lua_State* luaVM)
return 1;
}

int CLuaPlayerDefs::SetPlayerScriptDebugLevel(lua_State* luaVM)
bool CLuaPlayerDefs::SetPlayerScriptDebugLevel(CElement* const element, const std::variant<unsigned int, bool> variant)
{
CElement* pElement;
unsigned int uiMode;
bool bHideDebugger = false;

CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pElement);
if (argStream.NextIsBool())
unsigned int level;
if (std::holds_alternative<bool>(variant))
{
bool bTemp;
argStream.ReadBool(bTemp);

if (bTemp)
argStream.SetCustomError("You can only pass false to hide the debug window or a level (0-3)");
else
bHideDebugger = true;
}
else
{
argStream.ReadNumber(uiMode);

if (uiMode < 0 || uiMode > 3)
argStream.SetCustomError("Invalid level (0-3)");
}

if (argStream.HasErrors())
{
return luaL_error(luaVM, argStream.GetFullErrorMessage());
}

if (CStaticFunctionDefinitions::SetPlayerScriptDebugLevel(pElement, bHideDebugger ? 0 : uiMode))
{
lua_pushboolean(luaVM, true);
return 1;
// cant be a true bool
if (std::get<bool>(variant))
throw std::invalid_argument("You can only pass 'false' to hide the debug window, pass in a level(0-3) to enable it");
level = 0;
}
else
{
lua_pushboolean(luaVM, false);
return 1;
level = std::get<unsigned int>(variant);
if (level > 3)
throw std::invalid_argument("Invalid level (0-3)");
}
return CStaticFunctionDefinitions::SetPlayerScriptDebugLevel(element, level);
}

int CLuaPlayerDefs::SetPlayerWantedLevel(lua_State* luaVM)
Expand Down Expand Up @@ -1511,31 +1487,9 @@ int CLuaPlayerDefs::ResendPlayerACInfo(lua_State* luaVM)
return 1;
}

int CLuaPlayerDefs::GetPlayerScriptDebugLevel(lua_State* luaVM)
unsigned int CLuaPlayerDefs::GetPlayerScriptDebugLevel(CPlayer* const player)
{
// int getPlayerScriptDebugLevel ( player thePlayer )
CPlayer* pPlayer;

CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pPlayer);

if (argStream.HasErrors())
{
return luaL_error(luaVM, argStream.GetFullErrorMessage());
}

unsigned int uiLevel;

if (CStaticFunctionDefinitions::GetPlayerScriptDebugLevel(pPlayer, uiLevel))
{
lua_pushnumber(luaVM, uiLevel);
return 1;
}
else
{
lua_pushboolean(luaVM, false);
return 1;
}
return player->GetScriptDebugLevel();
}

int CLuaPlayerDefs::BindKey(lua_State* luaVM)
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/luadefs/CLuaPlayerDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CLuaPlayerDefs : public CLuaDefs
LUA_DECLARE(GetPlayerAccount);
LUA_DECLARE(GetPlayerVersion);
LUA_DECLARE(GetPlayerACInfo);
LUA_DECLARE(GetPlayerScriptDebugLevel);
static unsigned int GetPlayerScriptDebugLevel(CPlayer* const player);

// Player set functions
LUA_DECLARE(SetPlayerMoney);
Expand All @@ -66,7 +66,7 @@ class CLuaPlayerDefs : public CLuaDefs
LUA_DECLARE(SetPlayerName);
LUA_DECLARE(DetonateSatchels);
LUA_DECLARE(TakePlayerScreenShot);
LUA_DECLARE(SetPlayerScriptDebugLevel);
static bool SetPlayerScriptDebugLevel(CElement* const element, const std::variant<unsigned int, bool> variant);

// All seeing eye
LUA_DECLARE(GetPlayerAnnounceValue);
Expand Down
2 changes: 1 addition & 1 deletion Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct CLuaFunctionParserBase
accumulator += "/" + TypeToName<param>();

if constexpr (is_variant<T>::count != 1)
return TypeToNameVariant<is_variant<T>::rest_t>(accumulator);
return TypeToNameVariant<typename is_variant<T>::rest_t>(accumulator);
}

template <typename T>
Expand Down