StrangeLoopGames / EcoModKit

Eco Modkit
https://docs.play.eco
69 stars 25 forks source link

Enable Custom Webpage Opening #36

Closed MonzUn closed 2 years ago

MonzUn commented 2 years ago

Is your feature request related to a problem? Please describe. There are cases where I could make my plugins more convinient to use and more easy to explain the usage of if a webpage could be used. Examples would be joining the server Discord via a DiscordLink command or opening the DiscordLink documentation page for account linking instead of presenting only a box with plain text.

Describe the solution you'd like A server side function call for a logged in user to open a webpage.

Describe alternatives you've considered My current solution is to print the URL in plain text and have the user manually copy it. Another solution could be to have URLs be formatted and clickable in chat.

Additional context It would be preferrable if a similar prompt as when opening the Server WebUI was presented to the player, showing them the link they will open if they hit "OK".

thetestgame commented 2 years ago

There already is a solution to this starting in 9.5. It was added for something else though it could be repurposed. From the user object you access their network client and call "OpenServerWebpage" which will prompt for confirmation similar to the already in place graphs UI button.

user?.Client?.RPC("OpenServerWebpage", "https://www.google.com");
MonzUn commented 2 years ago

Wow, this AND the ability to get logging events! 9.5 really has it all! Thank you very much, feel free to close this one ^^

MonzUn commented 2 years ago

@thetestgame The above code you suggested will prefix page you input with the server web address. So you can't open generic pages. Did you have something else in mind for 9.5?

MonzUn commented 2 years ago

Could we reopen this as the proposed solution did not work?

thetestgame commented 2 years ago

Support for asking a user if they'd like to open a web page as well as support for inviting a user to a Discord guild through the Discord overlay/client with a web fallback was added to our next release after 9.6. They can be accessed via the following

user.Client.OpenWebpage("www.google.com");

and

user.Client.OpenDiscordInvite("X3JeE4CV");