SmartlyDressedGames / Unturned-3.x-Community

Community portion of the Unturned-3.x repo. If you have access to the source code you can find it here:
https://github.com/SmartlyDressedGames/Unturned-3.x/
84 stars 18 forks source link

Communication between server and client via module #4297

Closed Maximjetfs1305 closed 2 weeks ago

Maximjetfs1305 commented 5 months ago

Hello, I had this idea to make a module for client and server. I need to be able to call some methods from my module on the client side. I understand that this can be organized with the help of "SteamChannel". but it didn't work out well for me(((. Perhaps someone has already done this and can share examples of work?) I would be very grateful.

GazziFX commented 5 months ago

SDG.Unturned.NetReflection class is very flexible, you need to patch .cctor to include your module into search (probably need to call .cctor again) and it will register methods marked with NetInvokableGeneratedMethod in static classes marked NetInvokableGeneratedClass

DanielWillett commented 5 months ago

Also see https://github.com/SmartlyDressedGames/Unturned-3.x-Community/discussions/4176

Maximjetfs1305 commented 5 months ago

Also see #4176

Hi, watched your code really professionally done) Could you help me with this? As my programming level doesn't allow me to use your code or fully understand how it works. I would be very happy if you could help me to make a module or give me a small example of a module with work between client and server. Because I am just learning to program and it is very difficult for me. I will be glad if you contact me by e-mail hldmcsscs@gmail.com.

DanielWillett commented 5 months ago

In that case, maybe try @GazziFX's way. I think @Jdance-Media had success doing it gazzi's way, maybe he'd be willing to show how he did it. The only reason I went with my way instead of just patching is because I already had a lot of that code written beforehand otherwise I would've probably used the ingame system.

And btw it looks like the line number in the link there is a bit out of date now it starts at around line 131