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/
83 stars 17 forks source link

The mod hook cannot run on the server #4402

Closed hyjhkt closed 1 month ago

hyjhkt commented 1 month ago

Recently, I have discovered that many mod hooks cannot run properly on the server. I believe that currently there are NPC global event messengers, client text messengers, and server text messengers that cannot run on the server, but can run in single player mode.

Rocket Hook cannot cause damage to any object (player vehicles, buildings, obstacles, zombies, animals) on the server, and Kill Hook cannot kill on the server ![Uploading RU2BC13MN_55XD5H5(DFVLT.png…]()

As a MOD creator and server owner with two years of experience, I believe these are very important for technological changes and plugins can be omitted. I am a hyj who often sends you emails.

ai-kana commented 1 month ago

https://unturned.info/Modding/ModHooks/ The chat hooks as stated above require special server settings, make sure those are applied. I've had these hooks work in past server side.

As for the other hooks wait for someone else!

hyjhkt commented 1 month ago

https://unturned.info/Modding/ModHooks/ 如上所述的聊天挂钩需要特殊的服务器设置,请确保应用这些设置。我已经让这些钩子在过去的服务器端工作了。

至于其他的钩子等别人吧!

Thank you very much. I did not find this answer on. cs or elsewhere. Thank you for your reminder

hyjhkt commented 1 month ago

https://unturned.info/Modding/ModHooks/ The chat hooks as stated above require special server settings, make sure those are applied. I've had these hooks work in past server side.

As for the other hooks wait for someone else!

"UnityEvents": { "Allow_Server_Messages": true, "Allow_Server_Commands": true, "Allow_Client_Messages": true, "Allow_Client_Commands": true }, This still doesn't work on the server, I don't understand...

hyjhkt commented 1 month ago

"UnityEvents": { "Allow_Server_Messages": true, "Allow_Server_Commands": true, "Allow_Client_Messages": true, "Allow_Client_Commands": true }, This still doesn't work on the server, I don't understand...

SDGNelson commented 1 month ago

Thanks ai-kana, that's correct.

@hyjhkt How do you have your components configured? For example, what object are they attached to?

hyjhkt commented 1 month ago

@SDGNelson 1 )CPBQD}P$E4R88KWO@G_{B1 IWQ@E@LJOL(@{ZW)6UL}_ZC ~40`FFDV~_PZRL_H46 TJS8 ~40`FFDV~_PZRL_H46 TJS8

I want ActivationEventHook to check the animal's Skeleton. If the animal is generated, send an event named 'Appearing Dreadnought Warrior' to the UI. Then the NpcGlobalEventHook of the UI detects the event and activates the sub UI。

I have tested many times and found that NpcGlobalEventMessenger cannot run on the server. however Interactivity Quest Interactivity Reports 2 Interactivity Report_0-Type Event Interactibility-Reward-0-ID appears as the fearless warrior Interactivity Report_1-Type Event Interactibility-Reward_1iD Death Fearless Warrior Interactivity Report_1_GrantDelaySeconds 3 This works on the server, so I don't think NpcGlobalEventMessenger can run on the server. I turned it on

hyjhkt commented 1 month ago

@SDGNelson {Q(AMQ$Y8JE A{WR5U(BD0 Q_84 EM037(X5BX({{_9~ Q This is when I ask the cube to send an event to GameObject within five seconds. GameObject will generate an effect, which is valid in single player mode but not on the server

SDGNelson commented 1 month ago

Thanks for the example. The reason is that by default the NPC Global Event Messenger only emits the event on the server. If you enable Should Replicate it will be emitted on the client as well.

With that change, is it now working how you expect?

Note: SendEvent only works from the server. i.e., clients cannot call SendEvent.

hyjhkt commented 1 month ago

@SDGNelson Does NpcGlobalEventMessenger work on animals? The layer is Entity and the label is Animal

SDGNelson commented 1 month ago

There's no reason it shouldn't, however the _Dedicated prefab is spawned on the dedicated server and the _Server prefab is spawned in singleplayer.

SDGNelson commented 1 month ago

Closing but feel free to comment and I will re-open.