Skip to content

Commit 571fcb5

Browse files
Improve export
1 parent fa4448c commit 571fcb5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/AltV.Net/Module.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Reflection;
5+
using System.Runtime.InteropServices;
56
using AltV.Net.Elements.Args;
67
using AltV.Net.Elements.Entities;
78
using AltV.Net.Events;
@@ -810,8 +811,11 @@ public virtual void OnScriptLoaded(IScript script)
810811

811812
public void SetExport(string key, Function function)
812813
{
814+
if (function == null) return;
813815
functionExports[key] = function;
814-
CSharpNativeResource.SetExport(key, MValue.Create(function.call));
816+
MValue.Function callDelegate = function.call;
817+
GCHandle.Alloc(callDelegate);
818+
CSharpNativeResource.SetExport(key, MValue.Create(callDelegate));
815819
}
816820
}
817821
}

0 commit comments

Comments
 (0)