diff --git a/c-api/event.cpp b/c-api/event.cpp index d2ac54d..52a3955 100644 --- a/c-api/event.cpp +++ b/c-api/event.cpp @@ -113,6 +113,8 @@ SetDelegate(AudioEvent); SetDelegate(ScriptRPC) SetDelegate(ScriptRPCAnswer) +SetDelegate(PlayerDimensionChange) + #endif CAPI_END() \ No newline at end of file diff --git a/c-api/event.h b/c-api/event.h index 2c61e1c..26ad00e 100644 --- a/c-api/event.h +++ b/c-api/event.h @@ -97,4 +97,6 @@ EXPORT_CLIENT void Event_SetPlayerBulletHitDelegate(CSharpResourceImpl* resource EXPORT_CLIENT void Event_SetVoiceConnectionDelegate(CSharpResourceImpl* resource, /** ClientEvents.VoiceConnectionModuleDelegate */ VoiceConnectionDelegate_t delegate); EXPORT_CLIENT void Event_SetScriptRPCDelegate(CSharpResourceImpl* resource, /** ClientEvents.ScriptRPCModuleDelegate */ ScriptRPCDelegate_t delegate); EXPORT_CLIENT void Event_SetScriptRPCAnswerDelegate(CSharpResourceImpl* resource, /** ClientEvents.ScriptRPCAnswerModuleDelegate */ ScriptRPCAnswerDelegate_t delegate); + +EXPORT_CLIENT void Event_SetPlayerDimensionChangeDelegate(CSharpResourceImpl* resource, /** ClientEvents.PlayerDimensionChangeModuleDelegate */ PlayerDimensionChangeDelegate_t delegate); #endif diff --git a/c-api/func_table.cpp b/c-api/func_table.cpp index acd7d81..c1e0647 100644 --- a/c-api/func_table.cpp +++ b/c-api/func_table.cpp @@ -1,6 +1,6 @@ #include "func_table.h" -inline uint64_t capiHash = 2737407539021183714UL; +inline uint64_t capiHash = 13628227844990757996UL; inline uint64_t capiHashes[] = { 0, #ifdef ALT_CLIENT_API @@ -293,6 +293,7 @@ inline uint64_t capiHashes[] = { 1013031841840963141UL, 10641081887455190199UL, 2849447755791784577UL, + 12559962844846581925UL, 11526105887646755055UL, 16259534399403863387UL, 10354256863799375649UL, @@ -2112,6 +2113,7 @@ inline void* capiPointers[] = { (void*) Event_SetPlayerChangeAnimationDelegate, (void*) Event_SetPlayerChangeInteriorDelegate, (void*) Event_SetPlayerChangeVehicleSeatDelegate, + (void*) Event_SetPlayerDimensionChangeDelegate, (void*) Event_SetPlayerDisconnectDelegate, (void*) Event_SetPlayerEnterVehicleDelegate, (void*) Event_SetPlayerLeaveVehicleDelegate, diff --git a/client/src/runtime/CSharpResourceImpl.cpp b/client/src/runtime/CSharpResourceImpl.cpp index 30902e1..1819a24 100644 --- a/client/src/runtime/CSharpResourceImpl.cpp +++ b/client/src/runtime/CSharpResourceImpl.cpp @@ -588,6 +588,16 @@ void CSharpResourceImpl::OnEvent(const alt::CEvent* ev) scriptRPCAnswerEvent->GetAnswerError().c_str()); break; } + case alt::CEvent::Type::PLAYER_DIMENSION_CHANGE: + { + auto playerDimensionChangeEvent = dynamic_cast(ev); + + OnPlayerDimensionChangeDelegate(Util_GetBaseObjectPointer(playerDimensionChangeEvent->GetTarget()), + playerDimensionChangeEvent->GetTarget()->GetType(), + playerDimensionChangeEvent->GetOldDimension(), + playerDimensionChangeEvent->GetNewDimension()); + break; + } default: { std::cout << "Unhandled client event #" << static_cast(ev->GetType()) << " got called" << std::endl; @@ -1011,4 +1021,6 @@ void CSharpResourceImpl::ResetDelegates() { OnScriptRPCDelegate = [](auto var, auto var2, auto var3, auto var4, auto var5) {}; OnScriptRPCAnswerDelegate = [](auto var, auto var2, auto var3) {}; + + OnPlayerDimensionChangeDelegate = [](auto var, auto var2, auto var3, auto var4) {}; } \ No newline at end of file diff --git a/client/src/runtime/CSharpResourceImpl.h b/client/src/runtime/CSharpResourceImpl.h index 25e9670..016ffc5 100644 --- a/client/src/runtime/CSharpResourceImpl.h +++ b/client/src/runtime/CSharpResourceImpl.h @@ -105,6 +105,8 @@ class CSharpResourceImpl : public alt::IResource::Impl ScriptRPCDelegate_t OnScriptRPCDelegate = nullptr; ScriptRPCAnswerDelegate_t OnScriptRPCAnswerDelegate = nullptr; + PlayerDimensionChangeDelegate_t OnPlayerDimensionChangeDelegate = nullptr; + bool MakeClient(alt::IResource::CreationInfo* info, std::vector files) { diff --git a/client/src/runtime/eventDelegates.h b/client/src/runtime/eventDelegates.h index ea45b5e..1690397 100644 --- a/client/src/runtime/eventDelegates.h +++ b/client/src/runtime/eventDelegates.h @@ -79,3 +79,5 @@ typedef void (* PlayerBulletHitDelegate_t)(uint32_t weapon, void* victim, alt::I typedef void (* VoiceConnectionDelegate_t)(uint8_t state); typedef void (* ScriptRPCDelegate_t)(const alt::CEvent* event, const char* name, alt::MValueConst** args, uint64_t size, uint16_t answerID); typedef void (* ScriptRPCAnswerDelegate_t)(uint16_t answerId, alt::MValueConst* answer, const char* answerError); + +typedef void (* PlayerDimensionChangeDelegate_t)(void* target, alt::IBaseObject::Type targetBaseObjectType, int32_t oldDim, int32_t newDim);