Jump to content

Force a script to run from server?


MafiaPuppet

Recommended Posts

I get how the client/server divide works. I'm not retarded. But ATM, I can't figure out how to do get client lua scripts to get sent to the server. I mean, besides the places where they seem to do it automatically.

 

Deal damage to a door? --> Automatically sent to server

Unlock a door? --> Never sent to server

Open a door? --> Never sent to server

Speak as your character? --> Automatically sent to server

Speak as another character? --> Never sent to server

 

To be more concrete, irrigation mod works multiplayer because all the lua triggers that it relies on can just be ordered for the server to check every 10 minutes, etc. Lockpicking doesn't work because the triggers are client-side, like using a context menu. The effects of Lockingpicking only register for the person who picked the lock, then he has to close/reopen the door/window for everyone else to see what he did.

 

This is really frustrating for me. I've added the ability to attach padlocks to containers and doors and it works in single player, but the doors/containers don't update to the server when they're attached in multiplayer. The effect is that the client who attached them sees them as locked, but everyone else sees them as the same.

 

If someone could explain to me how to force a function to run from the server box instead of the client box when the client's action triggers the function, I would be very grateful. I think that would let me use spraypaint, lockpicking, my padlocks, etc from multiplayer,

 

Or maybe there's something obvious I'm missing about the client/server divide.

Link to comment
Share on other sites

Can't be done as far as I know. Whether things get sent over to the server and other players depends on whether the thing in question has network synchronization code written for it in the engine. Currently everything doesn't. Your best bet is probably to post your specific "scripting thing x doesn't work in MP" grievances in the scripting requests thread, where devs will hopefully see and fix them.

 

Edit: ApCom is probably the most extensive multiplayer mod currently, so looking at how it does things could be educational.

Link to comment
Share on other sites

Actually, I just found a workaround. It turns out you can force everyone to run the exact same function, which hurts my efficiency soul to do, but it's not like zomboid bottlenecks at client CPU anyway. Anywhere that doesn't automatically sync, I just have that function execute on all clients simultaneously, and it pretends to sync.

 

It feels like this is going to bite me in the ass at some point, though.

Link to comment
Share on other sites

Eya, if you wanna send your own commands from server to client vice versa etc, then take a look at apcom as harraka suggested.

 

Apcom is shipped with another mod "LuaNet" this is a single lua file mod that can be required by other mods. LuaNet is basically a wrapper lua class for some networking functions the game provides to make use of them in lua easy, and it can be included by any other mod that wants to use it.

(im still planning to make a thread for luanet for ages, but never gotten around to actually writing it :P)

 

If you decide to use try it and run into problems feel free to contact me as it currently lacks documentation a bit.

Link to comment
Share on other sites

Eya, if you wanna send your own commands from server to client vice versa etc, then take a look at apcom as harraka suggested.

 

Apcom is shipped with another mod "LuaNet" this is a single lua file mod that can be required by other mods. LuaNet is basically a wrapper lua class for some networking functions the game provides to make use of them in lua easy, and it can be included by any other mod that wants to use it.

(im still planning to make a thread for luanet for ages, but never gotten around to actually writing it :P)

 

If you decide to use try it and run into problems feel free to contact me as it currently lacks documentation a bit.

Thanks so much.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...