Project Zomboid

Project Zomboid

Radar
此主题已被锁定
« Zero »  [开发者] 2022 年 8 月 4 日 上午 7:48
'Ping location' and 'pass server configuration' features might be fully canceled.
I've been trying to trigger the mod's 'OnClientCommand' event hook for multiplayer listen server since many hours ago but it just wouldn't work. Therefore canceled until someone can teach me how to do server-client communication for multiplayer game hosted through listen server.

For any experienced modders who can help me:

When I mentioned 'listen server', I mean hosting multiplayer game through the game itself. Not the dedicated server. And, I didn't attempt the same tests on dedicated server yet.

So, what I did is execute 'sendClientCommand(mod_id, command, args)' from 'lua/client' folder through 'OnPlayerUpdated' event for the listen server mod loading order (shared -> client -> server) and hook the 'OnClientCommand' event from any of the three lua folders. The 'Client', 'Server' and 'Shared' folders. The hook was not called at all so I can't progress from this point onward since the server can't receive command from client.

Not being able to trigger the hook is one thing. Not being able to detect if you are executing code from server side while hosting listen server is another problem. These two problems rendered my reference articles outdated AF. API used to detect if client is hosting server would be 'isServer()' and 'isClient()'.

References:
https://steamlists.com/project-zomboid-client-server-concept-script-guide/
https://theindiestone.com/forums/index.php?/topic/15256-multiplayer-coding-questions/

If there's any modder who can still trigger 'OnClientCommand' hook by hosting current version of listen server, please teach me haha. Otherwise I can't add any feature involving server-client communication in the future which sucks for me.
< >
正在显示第 1 - 1 条,共 1 条留言
« Zero »  [开发者] 2022 年 8 月 4 日 下午 6:07 
Haha, I really messed up. You can find listen server logs from 'coop-console.txt' instead of 'console.txt'.

For any modder interested on server-client communication for listen server, you can learn some informations underneath.

1. When should host's client request data from server?
- That would be some time after the client start their update tick. The server logic usually start ticking bit later than the client. So, if the server have huge amount of mods enabled, it's recommended to delay the request since the server might start ticking bit later. FYI, I delayed my data request by 60 ticks just in case there's any user experiencing late server run.
- So, the event you want to hook would be 'OnPlayerUpdate' event.

2. Mod loading order for listen server
- This is bit screwed up on dev's end. Reason would be client loading server lua when hosting which shouldn't happened at all.
- So, the loading order for client would be 'Shared' > 'Client' > 'Server' while the order for listen server would be 'Shared' > 'Server'.

As always, listen server is the in-game server, not the dedicated server alright.

This discussion will be locked.
最后由 « Zero » 编辑于; 2022 年 8 月 4 日 下午 6:07
< >
正在显示第 1 - 1 条,共 1 条留言
每页显示数: 1530 50