diff --git a/server/include/CSharpResourceImpl.h b/server/include/CSharpResourceImpl.h index 0e7a614..85e1e70 100644 --- a/server/include/CSharpResourceImpl.h +++ b/server/include/CSharpResourceImpl.h @@ -195,6 +195,8 @@ typedef void (* ClientDeleteObjectDelegate_t)(const alt::CEvent* event, alt::IPl typedef void (* PlayerHealDelegate_t)(alt::IPlayer* target, uint16_t oldHealth, uint16_t newHealth, uint16_t oldArmour, uint16_t newArmour); +typedef void (* GivePedScriptedTaskDelegate_t)(alt::IPlayer* source, alt::IPed* target, int32_t taskType); + class CSharpResourceImpl : public alt::IResource::Impl { void OnEvent(const alt::CEvent* ev) override; @@ -328,6 +330,8 @@ class CSharpResourceImpl : public alt::IResource::Impl { PlayerHealDelegate_t OnPlayerHealDelegate = nullptr; + GivePedScriptedTaskDelegate_t OnGivePedScriptedTaskDelegate = nullptr; + std::vector invokers; std::mutex invokersLock = {}; CoreClr* coreClr; @@ -536,4 +540,6 @@ EXPORT void CSharpResourceImpl_SetClientRequestObjectDelegate(CSharpResourceImpl EXPORT void CSharpResourceImpl_SetClientDeleteObjectDelegate(CSharpResourceImpl* resource, ClientDeleteObjectDelegate_t delegate); -EXPORT void CSharpResourceImpl_SetPlayerHealDelegate(CSharpResourceImpl* resource, PlayerHealDelegate_t delegate); \ No newline at end of file +EXPORT void CSharpResourceImpl_SetPlayerHealDelegate(CSharpResourceImpl* resource, PlayerHealDelegate_t delegate); + +EXPORT void CSharpResourceImpl_SetGivePedScriptedTaskDelegate(CSharpResourceImpl* resource, GivePedScriptedTaskDelegate_t delegate); \ No newline at end of file diff --git a/server/src/CSharpResourceImpl.cpp b/server/src/CSharpResourceImpl.cpp index b367f10..20eaa8e 100644 --- a/server/src/CSharpResourceImpl.cpp +++ b/server/src/CSharpResourceImpl.cpp @@ -70,6 +70,8 @@ void CSharpResourceImpl::ResetDelegates() OnClientDeleteObjectDelegate = [](auto var, auto var2) {}; OnPlayerHealDelegate = [](auto var, auto var2, auto var3, auto var4, auto var5) {}; + + OnGivePedScriptedTaskDelegate = [](auto var, auto var2, auto var3) {}; } bool CSharpResourceImpl::Start() @@ -743,6 +745,20 @@ case alt::CEvent::Type::SYNCED_META_CHANGE: playerHealEvent->GetNewArmour()); break; } + case alt::CEvent::Type::GIVE_PED_SCRIPTED_TASK: + { + auto givePedScriptedTaskEvent = dynamic_cast(ev); + + auto target = givePedScriptedTaskEvent->GetTarget(); + auto source = givePedScriptedTaskEvent->GetSource(); + + if (target == nullptr) return; + if (source == nullptr) return; + + OnGivePedScriptedTaskDelegate(source, target, givePedScriptedTaskEvent->GetTaskType()); + + break; + } default: { std::cout << "Unhandled server event #" << static_cast(ev->GetType()) << " got called" << std::endl; @@ -1253,6 +1269,11 @@ void CSharpResourceImpl_SetPlayerHealDelegate(CSharpResourceImpl* resource, Play resource->OnPlayerHealDelegate = delegate; } +void CSharpResourceImpl_SetGivePedScriptedTaskDelegate(CSharpResourceImpl* resource, GivePedScriptedTaskDelegate_t delegate) +{ + resource->OnGivePedScriptedTaskDelegate = delegate; +} + bool CSharpResourceImpl::MakeClient(alt::IResource::CreationInfo* info, std::vector files) { const std::string clientMain = resource->GetClientMain();