I’m trying to learn C# and started writing C# based framework/gamemode from scratch, but now i’m stuck with FiveM Exports.
I’m trying to get a value from one server side resource to another using Exports, but for some reason when i register the export like so: Method 1 (to return value): Exports.Add("LoadCharacterSkin", new Func<int, int, byte, string>((handle, charId, gender) => LoadCharacterSkin(handle, charId, gender)));
It does not register or cant be called or whatever since i get an error in the console when i try to call it from another script via: var skin = Exports["SNJRPPlayerCustomization"].LoadCharacterSkin(handle, id, (int)gender);
BUT
Now comes the funny part… When i use: Method 2 (Without returning the value): Exports.Add("LoadCharacterSkin", new Action(Test));
And call it from the other script with: Exports["SNJRPPlayerCustomization"].Test();
Then the the export works…
I know this probably not the answer you want but I can attempt to find a fix for your exports problem. I usually call either an event from a separate script or build the PlayerCustomization into the script you are current working on again not an efficient method to do it but it’s something temporary until I find a fix.
Little update! I managed to get the events working with callbacks, but so far it only works if i try to use it from server to server, when i try to trigger it from client → server to get a response from server, it just does nothing.
So currently my framework is triggering a server event from resource SNJRPPlayerCustomization and it gets a response like its supposed to with this:
However, if i try to trigger “SNJRPPlayerCustomization:GetCharacterSkin” from SNJRPPlayerCustomization client script, then it gives the following error on server side:
When i tried to change CallbackDelegate to NetworkCallbackDelegate, then even the server->server triggering wont work and instead of “Could not cast event argument from NetworkCallbackDelegate to CallbackDelegate” it says “Could not cast event argument from CallbackDelegate to NetworkCallbackDelegate” -_-
interesting because I’m getting the same error. I’m not 100% sure why it’s happening as it would be the same thing for LUA but because of C# being C# its Exports
I only really use exports I use is mainly for the spawn manager
Well yeah, like you can see from the first post, that kind of export works, but i need to exchange information between scripts and triggering 3 events to get one piece information is silly. At least i got the eventhandler working with the callback for now, gonna smoke my brains how to get information to the client script when i need to.