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/
86 stars 18 forks source link

Does Button works? #1816

Closed SMDIndomitable closed 3 years ago

SMDIndomitable commented 4 years ago

Dear Nelson,

I am writing this with you to clarify if Unity button will work in Server. Someone told me OnClick event would not work on the server side. I tested it on the Client side and it is working as intended, an alternative solution towards mod hook. I have also found this "onEffectButtonClicked", is this for use in plugins only? Can you make the buttons work on server side without plugins?

TH3AL3X commented 4 years ago

Buttons only works with plugins Here we go, you have a example: EffectManager.onEffectButtonClicked += new EffectManager.EffectButtonClickedHandler(this.onEffectButtonClicked);

Take a look to this code, maybe can help you https://github.com/TH3AL3X/Advanced-Robs/blob/master/Atracos.cs

SMDIndomitable commented 4 years ago

@TH3AL3X Hi, I have just read the code. Thank you so much for the reply. From what I see, I would have to specific the button names in order for the respective buttons to work in the server right? Is there a way to make a plugin to enable all use of buttons in the server regardless of their name. Something like FindAllGameObjectWithComponent

TH3AL3X commented 4 years ago

@TH3AL3X Hi, I have just read the code. Thank you so much for the reply. From what I see, I would have to specific the button names in order for the respective buttons to work in the server right? Is there a way to make a plugin to enable all use of buttons in the server regardless of their name. Something like FindAllGameObjectWithComponent, so all the buttons can be used.

I don't think you can do that, since you have to use what the event says to work properly, and yep is working with button names

SMDIndomitable commented 4 years ago

Alright, thank you again for the quick reply :D

ghost commented 4 years ago

The problem is that activation through OnClickEvent is not transmitted to other clients through the server. There is a crutch way if you use a button to call a function that will be transferred to other clients. For example, you can call a chat message through ClientTextChatMessenger and thereby activate TextChatEventHook. However, it will only work if the Allow_Client_Messages option is enabled on the server. I wish Nelson listened to my suggestions and added simpler and more universal tools ...

ZoliWorks commented 4 years ago

The easiest and most universal tool would be a SirensEventHook and HeadlightsEventHook. Would open up many new possibilities, without the need for advanced systems and complications. It's not that we cant achieve the same results right now, it's just that it would make it a lot simpler.

ghost commented 4 years ago

No, Sirens and Headlights are already synchronized and can be used (the main thing is to know how). We need to make some kind of more universal tool. I guess make a universal UnityEvent binary state could be. Something like IOBS, but allowing you to add it to any object, whether it be Item or Vehicle. The main idea is that it would have two UnityEvent - ON and OFF, as well as a logical variable True / False. The server will monitor the hierarchy of which GameObject the script is in and send it the value of the variable from which UnityEvent will be launched. You may have to use a non-standard SteamCall, but I think it will not be so difficult to do. The task is to transfer the current state of the script from the server to the client and from the client to the server in order to get full synchronization of events.

SMDIndomitable commented 4 years ago

@TH3AL3X Hey, sorry to bother. Is there a tutorial for writing plugins and enable interaction with button? Will really appreciate the help.

TH3AL3X commented 4 years ago

@TH3AL3X Hey, sorry to bother. Is there a tutorial for writing plugins and enable interaction with button? Will really appreciate the help.

Sure, when I arrive to my home I will do the tutorial

SMDIndomitable commented 4 years ago

Thank you so much :D

TH3AL3X commented 4 years ago

Thank you so much :D I'm uploading the video, with the example source + unity project

TH3AL3X commented 4 years ago

Thank you so much :D

Github if you want the example with the Unity UI: https://github.com/TH3AL3X/TutorialButtonsEffects/ YouTube Video of the example: https://www.youtube.com/watch?v=y5_VquS5OrQ

SMDIndomitable commented 4 years ago

@TH3AL3X Thank you once again, I understood pretty much everything. I got one question though, does it have to be an effects? Can it be on a vehicle or an object?

TH3AL3X commented 4 years ago

@TH3AL3X Thank you once again, I understood pretty much everything. I got one question though, does it have to be an effects? Can it be on a vehicle or an object?

Only effects

tankirules commented 4 years ago

The problem is that activation through OnClickEvent is not transmitted to other clients through the server. There is a crutch way if you use a button to call a function that will be transferred to other clients. For example, you can call a chat message through ClientTextChatMessenger and thereby activate TextChatEventHook. However, it will only work if the Allow_Client_Messages option is enabled on the server. I wish Nelson listened to my suggestions and added simpler and more universal tools ...

Have you got examples of this? (using clienttextchatmessenger and the other one that executes commands )Thanks.