taywon Posted August 15, 2021 Posted August 15, 2021 Hey ! I'm trying to communicate between serverside c# and serverside js, with this kind of code: //serverside C# Debug.Assert(NAPI.LocalEvent != null, "Never happens, LocalEvent is not null") NAPI.LocalEvent.TriggerEvent("testEvent"); //throw System.NullReferenceException (Exception has been thrown by the target of an invocation), no matter what arguments are provided //serverside JS mp.events.add( "testEvent", () =>{ console.log("Never called"); }); Did someone already used this function ? Thanks
Division Posted August 16, 2021 Posted August 16, 2021 do smth like // c# trigger clientside event player.TriggerEvent("client.redirect", "myJSEventServerEvent"); // js cs event mp.events.add("client.redirect", function(eventName: string) { mp.events.callRemote(eventName); } //js serverside event mp.events.add("myJSEventServerEvent", () => { console.log("js reached through rpc"); }); fyi: this is just mind written, cuz i stopped my ragemp project, but should works otherwise lead you to a solution
taywon Posted August 20, 2021 Author Posted August 20, 2021 Hey ! Thank you for the answer. This trick will do the job, even if it's a bit nasty. I'll write a bug report later !
Division Posted August 21, 2021 Posted August 21, 2021 vor 5 Stunden schrieb taywon: Hey ! Thank you for the answer. This trick will do the job, even if it's a bit nasty. I'll write a bug report later ! Nah, it is nasty to use 2 different languages for server-side. I do not think that they will implement a js <> c# pipeline. Better rewrite ur js to c# to get it clean
taywon Posted August 21, 2021 Author Posted August 21, 2021 19 hours ago, Division said: Nah, it is nasty to use 2 different languages for server-side. I do not think that they will implement a js <> c# pipeline. Better rewrite ur js to c# to get it clean Maybe. Not sure. It's faster to develop in JS, but the module that you script cannot be as fast (neither efficient) as it was developped in c#. Two differents modules (e g gamemode vs population syncer) may be legitimately developped in two different language, even if it's imply low performance when the two modules communicates. But you were probably right when you said that NAPI.LocalEvent.TriggerEvent may not be maintened. TY again 😄
fl1k Posted September 5, 2021 Posted September 5, 2021 who says .NET is faster than JS? js has the speed / 2 of C++ while .NET compares worse I think you're looking for NAPI.ClientEvents.TriggerEvent nvm you're looking for server events
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now