Skip to content

Commit

Permalink
use enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Proxy-99 committed Oct 26, 2024
1 parent f5d4a05 commit 65bb7bf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,11 @@ ADD_ENUM(PreloadAreaOption::COLLISIONS, "collisions")
ADD_ENUM(PreloadAreaOption::ALL, "all")
IMPLEMENT_ENUM_CLASS_END("preload-area-option")

IMPLEMENT_ENUM_CLASS_BEGIN(taskType)
ADD_ENUM(taskType::PRIMARY_TASK, "primary")
ADD_ENUM(taskType::SECONDARY_TASK, "secondary")
IMPLEMENT_ENUM_CLASS_END("tasks-types")

//
// CResource from userdata
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ DECLARE_ENUM(ePools);
DECLARE_ENUM(eWorldProperty);
DECLARE_ENUM_CLASS(eModelLoadState);
DECLARE_ENUM_CLASS(PreloadAreaOption);
DECLARE_ENUM_CLASS(taskType);

class CRemoteCall;

Expand Down
22 changes: 14 additions & 8 deletions Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2495,13 +2495,19 @@ bool CLuaPedDefs::SetPedExitVehicle(CClientPed* pPed)
return pPed->ExitVehicle();
}

bool CLuaPedDefs::killPedTask(CClientPed* ped, std::string_view taskType, std::uint8_t taskNumber, std::optional<bool> gracefully) noexcept
bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional<bool> gracefully) noexcept
{
if (taskType == "primary") // PRIMARY
return ped->KillTask(taskNumber, gracefully.value_or(true));

else if (taskType == "secondary") // SECONDARY
return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true));

return false;
switch (taskType)
{
case taskType::PRIMARY_TASK:
{
return ped->KillTask(taskNumber, gracefully.value_or(true));
}
case taskType::SECONDARY_TASK:
{
return ped->KillTaskSecondary(taskNumber, gracefully.value_or(true));
}
default:
return false;
}
}
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaPedDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ class CLuaPedDefs : public CLuaDefs
static bool IsPedBleeding(CClientPed* ped);
static bool SetPedBleeding(CClientPed* ped, bool bleeding);

static bool killPedTask(CClientPed* ped, std::string_view taskType, std::uint8_t taskNumber, std::optional<bool> gracefully) noexcept;
static bool killPedTask(CClientPed* ped, taskType taskType, std::uint8_t taskNumber, std::optional<bool> gracefully) noexcept;
};
7 changes: 7 additions & 0 deletions Client/sdk/game/CTaskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ enum
ABORT_PRIORITY_IMMEDIATE
};

enum taskType
{
PRIMARY_TASK = 0,
SECONDARY_TASK
};


class CTaskManager
{
public:
Expand Down

0 comments on commit 65bb7bf

Please sign in to comment.