mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Implement signal for executed scripts.
This commit is contained in:
parent
0ed82f66e1
commit
3bef7e9419
@ -356,6 +356,7 @@ bool Core::Initialize()
|
||||
InitSignalPair(mOnPreLoad, NullLightObj(), nullptr);
|
||||
InitSignalPair(mOnPostLoad, NullLightObj(), nullptr);
|
||||
InitSignalPair(mOnUnload, NullLightObj(), nullptr);
|
||||
InitSignalPair(mOnScript, NullLightObj(), nullptr);
|
||||
|
||||
CSimpleIniA::TNamesDepend scripts;
|
||||
// Attempt to retrieve the list of keys to make sure there's actually something to process
|
||||
@ -510,6 +511,7 @@ void Core::Terminate(bool shutdown)
|
||||
// Tell modules to do their monkey business
|
||||
//_Func->SendPluginCommand(0xDEADC0DE, "");
|
||||
}
|
||||
|
||||
cLogDbg(m_Verbosity >= 1, "Clearing the entity containers");
|
||||
// Release all entity resources by clearing the containers
|
||||
const ContainerCleaner cc_players(m_Players, ENT_PLAYER, !shutdown);
|
||||
@ -571,6 +573,7 @@ void Core::Terminate(bool shutdown)
|
||||
{
|
||||
cLogDbg(m_Verbosity >= 1, "Releasing any final resources and all loaded scripts");
|
||||
// Release all script callbacks
|
||||
ResetSignalPair(mOnScript);
|
||||
DropEvents();
|
||||
// Release the script instances
|
||||
m_Scripts.clear();
|
||||
@ -793,6 +796,8 @@ bool Core::LoadScript(const SQChar * filepath, Function & cb, LightObj & ctx, bo
|
||||
// Release callback since we know it exists
|
||||
s.mFunc.Release();
|
||||
}
|
||||
// Invoke the global callback
|
||||
(*mOnScript.first)(s.mPath, s.mCtx);
|
||||
// Release context, if any
|
||||
s.mCtx.Release();
|
||||
}
|
||||
@ -926,6 +931,8 @@ bool Core::DoScripts(Scripts::iterator itr, Scripts::iterator end)
|
||||
// Release callback since we know it exists
|
||||
s.mFunc.Release();
|
||||
}
|
||||
// Invoke the global callback
|
||||
(*Core::Get().mOnScript.first)(s.mPath, s.mCtx);
|
||||
// Release context, if any
|
||||
s.mCtx.Release();
|
||||
}
|
||||
@ -966,6 +973,8 @@ bool Core::DoScripts(Scripts::iterator itr, Scripts::iterator end)
|
||||
// Release callback since we know it exists
|
||||
s.mFunc.Release();
|
||||
}
|
||||
// Invoke the global callback
|
||||
(*Core::Get().mOnScript.first)(s.mPath, s.mCtx);
|
||||
// Release context, if any
|
||||
s.mCtx.Release();
|
||||
}
|
||||
@ -2339,7 +2348,7 @@ void Core::InitEvents()
|
||||
#endif
|
||||
InitSignalPair(mOnServerOption, m_Events, "ServerOption");
|
||||
InitSignalPair(mOnScriptReload, m_Events, "ScriptReload");
|
||||
InitSignalPair(mOnScriptLoaded, m_Events, "ScriptLoaded");
|
||||
InitSignalPair(mOnScript, m_Events, "ScriptLoaded");
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void Core::DropEvents()
|
||||
@ -2484,7 +2493,7 @@ void Core::DropEvents()
|
||||
#endif
|
||||
ResetSignalPair(mOnServerOption);
|
||||
ResetSignalPair(mOnScriptReload);
|
||||
ResetSignalPair(mOnScriptLoaded);
|
||||
ResetSignalPair(mOnScript);
|
||||
m_Events.Release();
|
||||
}
|
||||
|
||||
@ -2545,6 +2554,15 @@ static SQInteger SqGetEvents(HSQUIRRELVM vm)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static SQInteger SqGetOnScript(HSQUIRRELVM vm)
|
||||
{
|
||||
// Push the events table object on the stack
|
||||
sq_pushobject(vm, Core::Get().mOnScript.second);
|
||||
// Specify that we're returning a value
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void SqEmitCustomEvent(int32_t group, int32_t header, LightObj & payload)
|
||||
{
|
||||
@ -2869,6 +2887,7 @@ void Register_Core(HSQUIRRELVM vm)
|
||||
.CbFunc(_SC("LoadScriptNotify"), &SqLoadScriptNotify)
|
||||
.SquirrelFunc(_SC("ForceEnableNullEntities"), &SqForceEnableNullEntities)
|
||||
.SquirrelFunc(_SC("LoadScript"), &SqLoadScript, -3, ".b.")
|
||||
.SquirrelFunc(_SC("OnScript"), &SqGetOnScript)
|
||||
.SquirrelFunc(_SC("On"), &SqGetEvents);
|
||||
|
||||
RootTable(vm).Bind(_SC("SqCore"), corens);
|
||||
|
281
module/Core.hpp
281
module/Core.hpp
@ -704,154 +704,155 @@ public:
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Module signals.
|
||||
*/
|
||||
SignalPair mOnPreLoad;
|
||||
SignalPair mOnPostLoad;
|
||||
SignalPair mOnUnload;
|
||||
SignalPair mOnPreLoad{};
|
||||
SignalPair mOnPostLoad{};
|
||||
SignalPair mOnUnload{};
|
||||
SignalPair mOnScript{}; // Callback to be invoked for each loaded script.
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Server signals.
|
||||
*/
|
||||
SignalPair mOnCustomEvent;
|
||||
SignalPair mOnBlipCreated;
|
||||
SignalPair mOnCheckpointCreated;
|
||||
SignalPair mOnKeyBindCreated;
|
||||
SignalPair mOnObjectCreated;
|
||||
SignalPair mOnPickupCreated;
|
||||
SignalPair mOnPlayerCreated;
|
||||
SignalPair mOnVehicleCreated;
|
||||
SignalPair mOnBlipDestroyed;
|
||||
SignalPair mOnCheckpointDestroyed;
|
||||
SignalPair mOnKeyBindDestroyed;
|
||||
SignalPair mOnObjectDestroyed;
|
||||
SignalPair mOnPickupDestroyed;
|
||||
SignalPair mOnPlayerDestroyed;
|
||||
SignalPair mOnVehicleDestroyed;
|
||||
SignalPair mOnBlipCustom;
|
||||
SignalPair mOnCheckpointCustom;
|
||||
SignalPair mOnKeyBindCustom;
|
||||
SignalPair mOnObjectCustom;
|
||||
SignalPair mOnPickupCustom;
|
||||
SignalPair mOnPlayerCustom;
|
||||
SignalPair mOnVehicleCustom;
|
||||
SignalPair mOnCustomEvent{};
|
||||
SignalPair mOnBlipCreated{};
|
||||
SignalPair mOnCheckpointCreated{};
|
||||
SignalPair mOnKeyBindCreated{};
|
||||
SignalPair mOnObjectCreated{};
|
||||
SignalPair mOnPickupCreated{};
|
||||
SignalPair mOnPlayerCreated{};
|
||||
SignalPair mOnVehicleCreated{};
|
||||
SignalPair mOnBlipDestroyed{};
|
||||
SignalPair mOnCheckpointDestroyed{};
|
||||
SignalPair mOnKeyBindDestroyed{};
|
||||
SignalPair mOnObjectDestroyed{};
|
||||
SignalPair mOnPickupDestroyed{};
|
||||
SignalPair mOnPlayerDestroyed{};
|
||||
SignalPair mOnVehicleDestroyed{};
|
||||
SignalPair mOnBlipCustom{};
|
||||
SignalPair mOnCheckpointCustom{};
|
||||
SignalPair mOnKeyBindCustom{};
|
||||
SignalPair mOnObjectCustom{};
|
||||
SignalPair mOnPickupCustom{};
|
||||
SignalPair mOnPlayerCustom{};
|
||||
SignalPair mOnVehicleCustom{};
|
||||
#if SQMOD_SDK_LEAST(2, 1)
|
||||
SignalPair mOnCheckpointStream;
|
||||
SignalPair mOnObjectStream;
|
||||
SignalPair mOnPickupStream;
|
||||
SignalPair mOnPlayerStream;
|
||||
SignalPair mOnVehicleStream;
|
||||
SignalPair mOnCheckpointStream{};
|
||||
SignalPair mOnObjectStream{};
|
||||
SignalPair mOnPickupStream{};
|
||||
SignalPair mOnPlayerStream{};
|
||||
SignalPair mOnVehicleStream{};
|
||||
#endif
|
||||
SignalPair mOnServerStartup;
|
||||
SignalPair mOnServerShutdown;
|
||||
SignalPair mOnServerFrame;
|
||||
SignalPair mOnIncomingConnection;
|
||||
SignalPair mOnPlayerRequestClass;
|
||||
SignalPair mOnPlayerRequestSpawn;
|
||||
SignalPair mOnPlayerSpawn;
|
||||
SignalPair mOnPlayerWasted;
|
||||
SignalPair mOnPlayerKilled;
|
||||
SignalPair mOnPlayerEmbarking;
|
||||
SignalPair mOnPlayerEmbarked;
|
||||
SignalPair mOnPlayerDisembark;
|
||||
SignalPair mOnPlayerRename;
|
||||
SignalPair mOnPlayerState;
|
||||
SignalPair mOnStateNone;
|
||||
SignalPair mOnStateNormal;
|
||||
SignalPair mOnStateAim;
|
||||
SignalPair mOnStateDriver;
|
||||
SignalPair mOnStatePassenger;
|
||||
SignalPair mOnStateEnterDriver;
|
||||
SignalPair mOnStateEnterPassenger;
|
||||
SignalPair mOnStateExit;
|
||||
SignalPair mOnStateUnspawned;
|
||||
SignalPair mOnPlayerAction;
|
||||
SignalPair mOnActionNone;
|
||||
SignalPair mOnActionNormal;
|
||||
SignalPair mOnActionAiming;
|
||||
SignalPair mOnActionShooting;
|
||||
SignalPair mOnActionJumping;
|
||||
SignalPair mOnActionLieDown;
|
||||
SignalPair mOnActionGettingUp;
|
||||
SignalPair mOnActionJumpVehicle;
|
||||
SignalPair mOnActionDriving;
|
||||
SignalPair mOnActionDying;
|
||||
SignalPair mOnActionWasted;
|
||||
SignalPair mOnActionEmbarking;
|
||||
SignalPair mOnActionDisembarking;
|
||||
SignalPair mOnPlayerBurning;
|
||||
SignalPair mOnPlayerCrouching;
|
||||
SignalPair mOnPlayerGameKeys;
|
||||
SignalPair mOnPlayerStartTyping;
|
||||
SignalPair mOnPlayerStopTyping;
|
||||
SignalPair mOnPlayerAway;
|
||||
SignalPair mOnPlayerMessage;
|
||||
SignalPair mOnPlayerCommand;
|
||||
SignalPair mOnPlayerPrivateMessage;
|
||||
SignalPair mOnPlayerKeyPress;
|
||||
SignalPair mOnPlayerKeyRelease;
|
||||
SignalPair mOnPlayerSpectate;
|
||||
SignalPair mOnPlayerUnspectate;
|
||||
SignalPair mOnPlayerCrashReport;
|
||||
SignalPair mOnPlayerModuleList;
|
||||
SignalPair mOnVehicleExplode;
|
||||
SignalPair mOnVehicleRespawn;
|
||||
SignalPair mOnObjectShot;
|
||||
SignalPair mOnObjectTouched;
|
||||
SignalPair mOnObjectWorld;
|
||||
SignalPair mOnObjectAlpha;
|
||||
SignalPair mOnObjectReport;
|
||||
SignalPair mOnPickupClaimed;
|
||||
SignalPair mOnPickupCollected;
|
||||
SignalPair mOnPickupRespawn;
|
||||
SignalPair mOnPickupWorld;
|
||||
SignalPair mOnPickupAlpha;
|
||||
SignalPair mOnPickupAutomatic;
|
||||
SignalPair mOnPickupAutoTimer;
|
||||
SignalPair mOnPickupOption;
|
||||
SignalPair mOnCheckpointEntered;
|
||||
SignalPair mOnCheckpointExited;
|
||||
SignalPair mOnCheckpointWorld;
|
||||
SignalPair mOnCheckpointRadius;
|
||||
SignalPair mOnEntityPool;
|
||||
SignalPair mOnClientScriptData;
|
||||
SignalPair mOnPlayerUpdate;
|
||||
SignalPair mOnVehicleUpdate;
|
||||
SignalPair mOnPlayerHealth;
|
||||
SignalPair mOnPlayerArmour;
|
||||
SignalPair mOnPlayerWeapon;
|
||||
SignalPair mOnPlayerHeading;
|
||||
SignalPair mOnPlayerPosition;
|
||||
SignalPair mOnPlayerOption;
|
||||
SignalPair mOnPlayerAdmin;
|
||||
SignalPair mOnPlayerWorld;
|
||||
SignalPair mOnPlayerTeam;
|
||||
SignalPair mOnPlayerSkin;
|
||||
SignalPair mOnPlayerMoney;
|
||||
SignalPair mOnPlayerScore;
|
||||
SignalPair mOnPlayerWantedLevel;
|
||||
SignalPair mOnPlayerImmunity;
|
||||
SignalPair mOnPlayerAlpha;
|
||||
SignalPair mOnPlayerEnterArea;
|
||||
SignalPair mOnPlayerLeaveArea;
|
||||
SignalPair mOnVehicleColor;
|
||||
SignalPair mOnVehicleHealth;
|
||||
SignalPair mOnVehiclePosition;
|
||||
SignalPair mOnVehicleRotation;
|
||||
SignalPair mOnVehicleOption;
|
||||
SignalPair mOnVehicleWorld;
|
||||
SignalPair mOnVehicleImmunity;
|
||||
SignalPair mOnVehiclePartStatus;
|
||||
SignalPair mOnVehicleTyreStatus;
|
||||
SignalPair mOnVehicleDamageData;
|
||||
SignalPair mOnVehicleRadio;
|
||||
SignalPair mOnVehicleHandlingRule;
|
||||
SignalPair mOnVehicleEnterArea;
|
||||
SignalPair mOnVehicleLeaveArea;
|
||||
SignalPair mOnServerStartup{};
|
||||
SignalPair mOnServerShutdown{};
|
||||
SignalPair mOnServerFrame{};
|
||||
SignalPair mOnIncomingConnection{};
|
||||
SignalPair mOnPlayerRequestClass{};
|
||||
SignalPair mOnPlayerRequestSpawn{};
|
||||
SignalPair mOnPlayerSpawn{};
|
||||
SignalPair mOnPlayerWasted{};
|
||||
SignalPair mOnPlayerKilled{};
|
||||
SignalPair mOnPlayerEmbarking{};
|
||||
SignalPair mOnPlayerEmbarked{};
|
||||
SignalPair mOnPlayerDisembark{};
|
||||
SignalPair mOnPlayerRename{};
|
||||
SignalPair mOnPlayerState{};
|
||||
SignalPair mOnStateNone{};
|
||||
SignalPair mOnStateNormal{};
|
||||
SignalPair mOnStateAim{};
|
||||
SignalPair mOnStateDriver{};
|
||||
SignalPair mOnStatePassenger{};
|
||||
SignalPair mOnStateEnterDriver{};
|
||||
SignalPair mOnStateEnterPassenger{};
|
||||
SignalPair mOnStateExit{};
|
||||
SignalPair mOnStateUnspawned{};
|
||||
SignalPair mOnPlayerAction{};
|
||||
SignalPair mOnActionNone{};
|
||||
SignalPair mOnActionNormal{};
|
||||
SignalPair mOnActionAiming{};
|
||||
SignalPair mOnActionShooting{};
|
||||
SignalPair mOnActionJumping{};
|
||||
SignalPair mOnActionLieDown{};
|
||||
SignalPair mOnActionGettingUp{};
|
||||
SignalPair mOnActionJumpVehicle{};
|
||||
SignalPair mOnActionDriving{};
|
||||
SignalPair mOnActionDying{};
|
||||
SignalPair mOnActionWasted{};
|
||||
SignalPair mOnActionEmbarking{};
|
||||
SignalPair mOnActionDisembarking{};
|
||||
SignalPair mOnPlayerBurning{};
|
||||
SignalPair mOnPlayerCrouching{};
|
||||
SignalPair mOnPlayerGameKeys{};
|
||||
SignalPair mOnPlayerStartTyping{};
|
||||
SignalPair mOnPlayerStopTyping{};
|
||||
SignalPair mOnPlayerAway{};
|
||||
SignalPair mOnPlayerMessage{};
|
||||
SignalPair mOnPlayerCommand{};
|
||||
SignalPair mOnPlayerPrivateMessage{};
|
||||
SignalPair mOnPlayerKeyPress{};
|
||||
SignalPair mOnPlayerKeyRelease{};
|
||||
SignalPair mOnPlayerSpectate{};
|
||||
SignalPair mOnPlayerUnspectate{};
|
||||
SignalPair mOnPlayerCrashReport{};
|
||||
SignalPair mOnPlayerModuleList{};
|
||||
SignalPair mOnVehicleExplode{};
|
||||
SignalPair mOnVehicleRespawn{};
|
||||
SignalPair mOnObjectShot{};
|
||||
SignalPair mOnObjectTouched{};
|
||||
SignalPair mOnObjectWorld{};
|
||||
SignalPair mOnObjectAlpha{};
|
||||
SignalPair mOnObjectReport{};
|
||||
SignalPair mOnPickupClaimed{};
|
||||
SignalPair mOnPickupCollected{};
|
||||
SignalPair mOnPickupRespawn{};
|
||||
SignalPair mOnPickupWorld{};
|
||||
SignalPair mOnPickupAlpha{};
|
||||
SignalPair mOnPickupAutomatic{};
|
||||
SignalPair mOnPickupAutoTimer{};
|
||||
SignalPair mOnPickupOption{};
|
||||
SignalPair mOnCheckpointEntered{};
|
||||
SignalPair mOnCheckpointExited{};
|
||||
SignalPair mOnCheckpointWorld{};
|
||||
SignalPair mOnCheckpointRadius{};
|
||||
SignalPair mOnEntityPool{};
|
||||
SignalPair mOnClientScriptData{};
|
||||
SignalPair mOnPlayerUpdate{};
|
||||
SignalPair mOnVehicleUpdate{};
|
||||
SignalPair mOnPlayerHealth{};
|
||||
SignalPair mOnPlayerArmour{};
|
||||
SignalPair mOnPlayerWeapon{};
|
||||
SignalPair mOnPlayerHeading{};
|
||||
SignalPair mOnPlayerPosition{};
|
||||
SignalPair mOnPlayerOption{};
|
||||
SignalPair mOnPlayerAdmin{};
|
||||
SignalPair mOnPlayerWorld{};
|
||||
SignalPair mOnPlayerTeam{};
|
||||
SignalPair mOnPlayerSkin{};
|
||||
SignalPair mOnPlayerMoney{};
|
||||
SignalPair mOnPlayerScore{};
|
||||
SignalPair mOnPlayerWantedLevel{};
|
||||
SignalPair mOnPlayerImmunity{};
|
||||
SignalPair mOnPlayerAlpha{};
|
||||
SignalPair mOnPlayerEnterArea{};
|
||||
SignalPair mOnPlayerLeaveArea{};
|
||||
SignalPair mOnVehicleColor{};
|
||||
SignalPair mOnVehicleHealth{};
|
||||
SignalPair mOnVehiclePosition{};
|
||||
SignalPair mOnVehicleRotation{};
|
||||
SignalPair mOnVehicleOption{};
|
||||
SignalPair mOnVehicleWorld{};
|
||||
SignalPair mOnVehicleImmunity{};
|
||||
SignalPair mOnVehiclePartStatus{};
|
||||
SignalPair mOnVehicleTyreStatus{};
|
||||
SignalPair mOnVehicleDamageData{};
|
||||
SignalPair mOnVehicleRadio{};
|
||||
SignalPair mOnVehicleHandlingRule{};
|
||||
SignalPair mOnVehicleEnterArea{};
|
||||
SignalPair mOnVehicleLeaveArea{};
|
||||
#if SQMOD_SDK_LEAST(2, 1)
|
||||
SignalPair mOnEntityStream;
|
||||
SignalPair mOnEntityStream{};
|
||||
#endif
|
||||
SignalPair mOnServerOption;
|
||||
SignalPair mOnScriptReload;
|
||||
SignalPair mOnScriptLoaded;
|
||||
SignalPair mOnServerOption{};
|
||||
SignalPair mOnScriptReload{};
|
||||
SignalPair mOnScriptLoaded{};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user