AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved HTML not rendered in MOTD (https://forums.alliedmods.net/showthread.php?t=308245)

naz7 06-12-2018 13:38

HTML not rendered in MOTD
 
1 Attachment(s)
Hi, I want to use HTML in a MOTD to display things nicely, and finally display a webpage with meta refresh when I have the webpage done and some more database things implemented.
I need help with the MOTD, because it's not rendering any HTML. I'm guessing it should at least just display the text inside it with some formating like any basic web browser, but here it just leaves the HTML tags and everything, as plain text.

I created a tiny plugin to reproduce this. In the attached screenshot it can be seen the MOTD that pops up when saying /mymotdhtml. The other 2 commands show the an equal MOTD, no HTML rendered.
PHP Code:

#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    
register_plugin("Testing MOTD""0.0.1""naz");
    
    
register_clcmd("say /mymotd""CmdMOTD");
    
register_clcmd("say /mymotdtxt""CmdMOTDFromTxt");
    
register_clcmd("say /mymotdhtml""CmdMOTDFromHTML");
}

// Passing a string to the show_motd
public CmdMOTD(id)
{
    
show_motd(id"<html><head></head><body><p>Test text</p></body></html>");
}

// Passing a .txt file to the show_motd
public CmdMOTDFromTxt(id)
{
    new 
motdPath[32];
    
get_configsdir(motdPathcharsmax(motdPath));
    
formatex(motdPathcharsmax(motdPath), "%s/motd.txt"motdPath);
    
show_motd(idmotdPath);
}

// Passing an HTML file to the show_motd
public CmdMOTDFromHTML(id)
{
    new 
motdPath[33];
    
get_configsdir(motdPathcharsmax(motdPath));
    
formatex(motdPathcharsmax(motdPath), "%s/motd.html"motdPath);
    
show_motd(idmotdPath);


I tried this in 2 different setups, but can't get it to display correctly in any of them:
  1. Client: Open Adrenaline Gamer (HL mod). Server: public (remote) ReHLDS server with AMXModX 1.8.3-dev+5154 and Metamod-r v1.3.0.126.
  2. Client: Half-Life. Server: listenserver with AMXModX 1.8.3-dev+5154 and Metamod 1.21.1-am.

Is it the plugin wrong? is there anything in those clients that prevent HTML from being rendered? because I've seen plugins in CS 1.6 render HTML in MOTD windows :| am I missing anything else?

Thanks for your attention!

jimaway 06-12-2018 14:01

Re: HTML not rendered in MOTD
 
pretty sure half life has only text based motd

fysiks 06-12-2018 20:43

Re: HTML not rendered in MOTD
 
Since the MOTD is implemented by the game client, you can't change what the MOTD is capable of rendering. Like jimaway said, Half-Life (the original game) doesn't support HTML-based MOTDs. Counter-Strike 1.6 and Day of Defeat (and some HL1 mods) have a basic web browser in the MOTD window which allows them to render basic HTML, use CSS, and execute Javascript.

naz7 06-13-2018 02:53

Re: HTML not rendered in MOTD
 
Thank you very much for your answers.
Then I think there's still some hope :)
Approximately 1/3 of the players use an open source client to play the mod (Adrenaline Gamer). I have zero experience in C++ and how a project of that kind is organized, but I think this is the implementation of the MOTD in the client: OpenAG MOTD

Maybe this is out of the scope of the thread/forum, but doing a fork of that repo to modify the MOTD implementation and adding for example a basic HTML or even something simpler as Markdown renderer would be enough for this to work? Maybe I would also have to include a client cvar that the server checks to see if the client can render the MOTD, and else fall to a default plain text MOTD for clients that don't have that cvar (ie. closed source client).

Also, could I change the 1536 char limit for the MOTD? there's a MAX_MOTD_LENGTH constant in the same repo in the hud.h and multiplay_gamerules.cpp,
but I think the reHLDS server only allows up to 2048? I'm a bit confused about all these different places, would I also have to do a fork of reHLDS to edit that limit so the server can send more than 2048? would all of this be VAC-safe, or a client with these modifications could be VAC-banned?

Sorry if this is out of scope and thank you again!

instinctpt1 06-13-2018 03:36

Re: HTML not rendered in MOTD
 
You can add your MotD html file on your server / Web Hosting
And provide the location of it ( on web server ) to your motd.txt ( server's )

In that way you can easily gain all functionality of HTML on your MOTD :)

naz7 06-13-2018 04:49

Re: HTML not rendered in MOTD
 
I already tried that with an iframe and with a meta refresh, but none works as the client thinks those HTML tags are plain text as I understand from the other answers. Or were you proposing a different idea and I misunderstood you?

instinctpt1 06-13-2018 07:11

Re: HTML not rendered in MOTD
 
Yes u misunderstood ...

I meant this :

Suppose u got a site : example.com
Post your HTML ( Motd) there .. ex : - example.com/motd.html

Now add this to motd.txt ( server side )
HTML Code:

<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="refresh" content="0;URL=http://example.com/motd.html">
    </head>
    <body>
    </body>
</html>

Now with this meta refresh .. client's MOTD will surely refresh contents from your site (example.com ) to his motd and will surely work ... as i have my MOTD on my site with html + CSS and it works :)

naz7 06-13-2018 07:18

Re: HTML not rendered in MOTD
 
The code in there is exactly the same as one I tried yesterday, replacing the URL with my website's, and yea, like I said in the previous comment what the player sees is just the same as the code you posted. Take the screenshot attached to the first post, that's what the player sees, and it's almost the simplest HTML you can get. Adding a meta refresh or iframe doesn't change anything if it doesn't even parse the <html> tag. :cry:

fysiks 06-13-2018 22:35

Re: HTML not rendered in MOTD
 
Quote:

Originally Posted by instinctpt1 (Post 2596688)
Yes u misunderstood ...

I meant this :

Suppose u got a site : example.com
Post your HTML ( Motd) there .. ex : - example.com/motd.html

Now add this to motd.txt ( server side )
HTML Code:

<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="refresh" content="0;URL=http://example.com/motd.html">
    </head>
    <body>
    </body>
</html>

Now with this meta refresh .. client's MOTD will surely refresh contents from your site (example.com ) to his motd and will surely work ... as i have my MOTD on my site with html + CSS and it works :)

Since the MOTD is not a web browser in Half-Life, it can't render HTML and obviously can't access the internet for grab web-based files that won't run it the MOTD anyways.

Quote:

Originally Posted by naz7 (Post 2596662)
would all of this be VAC-safe, or a client with these modifications could be VAC-banned?

Any modification to the client binaries of a game that supports VAC has the potential to cause a VAC ban since Valve doesn't tell you what VAC actually checks.

naz7 06-14-2018 19:43

Re: HTML not rendered in MOTD
 
I will face the risk. Not now though, I'll probably come back to this issue in 2 months and answer my other questions when I get everything done, so other people with this problem can hopefully solve it reading this thread.
I'm marking this as solved since the initial questions have been answered. If the others can be answered in the meanwhile then perfect. Thank you!


All times are GMT -4. The time now is 19:44.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.