77
88#include " StdInc.h"
99#include < scrEngine.h>
10+ #include < ScriptHandlerMgr.h>
11+
1012#include " ICoreGameInit.h"
1113#include < InputHook.h>
1214#include < IteratorView.h>
@@ -112,13 +114,24 @@ class FishThread : public GtaThread
112114
113115 bool m_initedNet;
114116
117+ bool m_hasScriptHandler;
118+
115119public:
116120 virtual void DoRun () override
117121 {
122+ if (!m_hasScriptHandler)
123+ {
124+ CGameScriptHandlerMgr::GetInstance ()->AttachScript (this );
125+
126+ m_hasScriptHandler = true ;
127+ }
128+
118129 if (!m_initedNet)
119130 {
120131 // make this a network script
121132 NativeInvoke::Invoke<0x1CA59E306ECB80A5 , int >(32 , false , -1 );
133+
134+ m_initedNet = true ;
122135 }
123136
124137 std::vector<std::shared_ptr<FishScript>> thisIterScripts (m_scripts);
@@ -129,6 +142,8 @@ class FishThread : public GtaThread
129142 }
130143 }
131144
145+ virtual void Kill () override ;
146+
132147 virtual rage::eThreadState Reset (uint32_t scriptHash, void * pArgs, uint32_t argCount) override ;
133148
134149 void AddScript (void (*fn)());
@@ -161,6 +176,11 @@ rage::eThreadState FishThread::Reset(uint32_t scriptHash, void* pArgs, uint32_t
161176 return GtaThread::Reset (scriptHash, pArgs, argCount);
162177}
163178
179+ void FishThread::Kill ()
180+ {
181+ m_hasScriptHandler = false ;
182+ }
183+
164184void FishThread::AddScript (void (*fn)())
165185{
166186 m_scripts.push_back (std::make_shared<FishScript>(fn));
0 commit comments