Skip to content

Commit

Permalink
ALTV-640 add parachuteStateChange Event
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Jan 18, 2025
1 parent a6f3067 commit 45d1019
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions c-api/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ SetDelegate(ScriptRPCAnswer)

SetDelegate(PlayerDimensionChange)

SetDelegate(ParachuteStateChange)

#endif

CAPI_END()
2 changes: 2 additions & 0 deletions c-api/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,6 @@ EXPORT_CLIENT void Event_SetScriptRPCDelegate(CSharpResourceImpl* resource, /**
EXPORT_CLIENT void Event_SetScriptRPCAnswerDelegate(CSharpResourceImpl* resource, /** ClientEvents.ScriptRPCAnswerModuleDelegate */ ScriptRPCAnswerDelegate_t delegate);

EXPORT_CLIENT void Event_SetPlayerDimensionChangeDelegate(CSharpResourceImpl* resource, /** ClientEvents.PlayerDimensionChangeModuleDelegate */ PlayerDimensionChangeDelegate_t delegate);

EXPORT_CLIENT void Event_SetParachuteStateChangeDelegate(CSharpResourceImpl* resource, /** ClientEvents.ParachuteStateChangeModuleDelegate */ ParachuteStateChangeDelegate_t delegate);
#endif
4 changes: 3 additions & 1 deletion c-api/func_table.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "func_table.h"

inline uint64_t capiHash = 14533172368099836198UL;
inline uint64_t capiHash = 93234109882736831UL;
inline uint64_t capiHashes[] = {
0,
#ifdef ALT_CLIENT_API
Expand Down Expand Up @@ -289,6 +289,7 @@ inline uint64_t capiHashes[] = {
1555813148561817401UL,
10052271841742065911UL,
15651483423859541657UL,
11234135878852629737UL,
17879780001793566297UL,
1013031841840963141UL,
10641081887455190199UL,
Expand Down Expand Up @@ -2111,6 +2112,7 @@ inline void* capiPointers[] = {
(void*) Event_SetLocalMetaChangeDelegate,
(void*) Event_SetMetaChangeDelegate,
(void*) Event_SetNetOwnerChangeDelegate,
(void*) Event_SetParachuteStateChangeDelegate,
(void*) Event_SetPlayerBulletHitDelegate,
(void*) Event_SetPlayerChangeAnimationDelegate,
(void*) Event_SetPlayerChangeInteriorDelegate,
Expand Down
12 changes: 12 additions & 0 deletions client/src/runtime/CSharpResourceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,16 @@ void CSharpResourceImpl::OnEvent(const alt::CEvent* ev)
playerDimensionChangeEvent->GetNewDimension());
break;
}
case alt::CEvent::Type::PARACHUTE_STATE_CHANGE:
{
auto parachuteStateChangeEvent = dynamic_cast<const alt::CParachuteStateChangeEvent*>(ev);

OnParachuteStateChangeDelegate(Util_GetBaseObjectPointer(parachuteStateChangeEvent->GetPlayer()),
parachuteStateChangeEvent->GetPlayer()->GetType(),
parachuteStateChangeEvent->GetOldState(),
parachuteStateChangeEvent->GetNewState());
break;
}
default:
{
std::cout << "Unhandled client event #" << static_cast<int>(ev->GetType()) << " got called" << std::endl;
Expand Down Expand Up @@ -1023,4 +1033,6 @@ void CSharpResourceImpl::ResetDelegates() {
OnScriptRPCAnswerDelegate = [](auto var, auto var2, auto var3) {};

OnPlayerDimensionChangeDelegate = [](auto var, auto var2, auto var3, auto var4) {};

OnParachuteStateChangeDelegate = [](auto var, auto var2, auto var3, auto var4) {};
}
2 changes: 2 additions & 0 deletions client/src/runtime/CSharpResourceImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class CSharpResourceImpl : public alt::IResource::Impl

PlayerDimensionChangeDelegate_t OnPlayerDimensionChangeDelegate = nullptr;

ParachuteStateChangeDelegate_t OnParachuteStateChangeDelegate = nullptr;


bool MakeClient(alt::IResource::CreationInfo* info, std::vector<std::string> files)
{
Expand Down
4 changes: 4 additions & 0 deletions client/src/runtime/eventDelegates.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ typedef void (* ScriptRPCDelegate_t)(const alt::CEvent* event, const char* name,
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);

typedef void (* ParachuteStateChangeDelegate_t)(void* player, alt::IBaseObject::Type playerType, alt::CParachuteStateChangeEvent::ParachuteState oldState, alt::CParachuteStateChangeEvent::ParachuteState newState);


2 changes: 1 addition & 1 deletion cpp-sdk

0 comments on commit 45d1019

Please sign in to comment.