Modcraft - The community dedicated to quality WoW modding!

Wrath of the Lich King Modding => Serverside Modding => Tutorials => Topic started by: Steff on August 21, 2011, 01:11:13 pm

Title: [TUTORIAL] Own server messages in the alert box on login scr
Post by: Steff on August 21, 2011, 01:11:13 pm
Because some guys ask, here is a little hint how to have your own server messages in the login screen.
You need a webserver on port 80 where you can put the message text file the client will load on every startup.

- Setup a new folder called alert on the root of your webserver.
- Put an index.htm or an index.php if you want to generate the news from a database there.
- Add the messages to this file in the following form.

Code: [Select]
<html><body>
SERVERALERT:
<p>TEST1<br />Message number 1<br />Message number 1 Line2<br /><br /></p>
<p>TEST2<br />Message number 2<br />Message number 2 Line2<br /><br /></p>
</body></html>

- You have to be careful. The WoW HTML renderer (CSimpleHTML) does not support many HTML commands. So test your output after every change.
- Add the file InterfaceGlueXMLGlueStrings.lua to your patch if not already done.
- Open it and search the string SERVER_ALERT_URL and set it to your server's URL.
- Now create your MPQ and start the client.
- Be aware that this file is not language neutral. Adding it to your patch will get the people using your patch the same language at glue screens as you have. You may want to have multiple patches like this for every language or do the edit in a language neutral file.

If you are skilled in php you can create the messages from a forum DB or one you setup and fill yourself.

(http://is.gd/3MdmKx)
http://is.gd/3MdmKx
Title: Re: [TUTORIAL] Own server messages in the alert box on login scr
Post by: doresain on August 21, 2011, 05:46:43 pm
you need an unlocked wow.exe binary for this
Title: Re: [TUTORIAL] Own server messages in the alert box on login scr
Post by: Steff on August 24, 2011, 09:06:44 pm
You need to unlock for all interface cahnges. So i think everyone will have it :)
Title: Re: [TUTORIAL] Own server messages in the alert box on login scr
Post by: Laniax on August 25, 2011, 12:14:20 am
You could also do this without an MPQ.

You can simple add a entry in your hosts file that changes launcher.worldofwarcraft.com to your own webhost, which has a index.html/php file that has the above info. Works exactly the same way, except you do the redirection inside windows, and not inside the WoW GLUE files.
Title: Re: [TUTORIAL] Own server messages in the alert box on login scr
Post by: schlumpf on August 25, 2011, 01:27:16 am
Quote from: "Laniax"
You could also do this without an MPQ.

You can simple add a entry in your hosts file that changes launcher.worldofwarcraft.com to your own webhost, which has a index.html/php file that has the above info. Works exactly the same way, except you do the redirection inside windows, and not inside the WoW GLUE files.

Do you really want to let your users edit a file with the possibility to hijack every access to remote resources of the system instead of distributing a change inside an MPQ, you will most likely ship anyway as you have modded stuff?

Editing the host-file is nothing one should do for reasons like this. You don't edit the hosts file instead of changing the realmlist, do you?
Title: Re: [TUTORIAL] Own server messages in the alert box on login scr
Post by: Steff on August 25, 2011, 12:09:23 pm
And if you paly on different servers this will not work. All clients you start will show the messages of the one setup in the hosts file.
Title: Re: [TUTORIAL] Own server messages in the alert box on login scr
Post by: Laniax on August 25, 2011, 10:53:15 pm
Both of you are correct, im just saying this as there is a non-mpq solution if someone searches that. It can be done by a custom launcher so users cant fuck it up. I never said it would be a better way of doing.
Title: Re: [TUTORIAL] Own server messages in the alert box on login scr
Post by: schlumpf on August 29, 2011, 10:27:57 pm
Quote from: "Laniax"
Both of you are correct, im just saying this as there is a non-mpq solution if someone searches that. It can be done by a custom launcher so users cant fuck it up. I never said it would be a better way of doing.
That file should be only writable by an admin, so requiring that for your launcher is not really good. ;)

Btw: An public repository for your server? Nice.
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: Meiya Stormsinger on June 14, 2012, 09:29:31 am
I am currently using this on my login UI, but there's a problem...

Html tags won't register, I have a file named index.html, yet when I use the <html> tags, it actually shows up in the window, so only plain text works, any ideas?
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: Steff on June 14, 2012, 01:09:25 pm
You only cna use a very low set of tags. Even bold or strong dont work. I think it was only hr and br. Thats it.
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: mathex on April 20, 2013, 09:37:25 pm
Hello, I've now followed this tutorial 100% and I get an error where it says that I need to re install WoW, I've narrowed it down to being whenever I edit an interface file. So I was wondering if any of you as mentioned above have a download link for a "unlocked" wow.exe or mind explaining how to do that? Thank you very much :-)
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: Ascathos on April 20, 2013, 09:45:47 pm
viewtopic.php?f=59&t=883 (http://modcraft.io/viewtopic.php?f=59&t=883" onclick="window.open(this.href);return false;)
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: mathex on April 20, 2013, 09:47:48 pm
Quote from: "Ascathos"
http://modcraft.io/viewtopic.php?f=59&t=883

Thank you very much, Sir.
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: stoneharry on April 21, 2013, 05:50:11 pm
I'm struggling to get this to work for some reason.

I know the URL is visited because I have this code:

Code: [Select]
SERVERALERT:TESTING
<?php

$myFile 
"test.txt";
$fh fopen($myFile'w') or die("can't open file");
fwrite($fh"TESTING THIS");
fclose($fh);

/*"SERVERALERT:
<html><body>
<p>TEST1<br />Message number 1<br />Message number 1 Line2<br /><br /></p>
<p>TEST2<br />Message number 2<br />Message number 2 Line2<br /><br /></p>
</body></html>*/
?>


The text file is created and written to when I start WoW up.

However, the event is never fired:
Code: [Select]
function AccountLogin_OnEvent(event, arg1, arg2, arg3)
if ( event == "SHOW_SERVER_ALERT" ) then
ServerAlertText:SetText(arg1);
ServerAlertFrame:Show();
This snippet of code is never called, so the text is never updated and the frame never shown.

I did find I had to edit both:
Code: [Select]
GlueLocalization.lua
GlueStrings.lua
Both files contain SERVER_ALERT_URL's that need to be modified - as the localisation one is loaded after the GlueStrings.lua one and thus overwrites it. The GlueStrings.Lua will only overwrite it if the GlueLocalization.lua is not included in your patch, because your custom patch is loaded last.
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: Steff on April 23, 2013, 06:21:03 am
Ok thanks nice tip stoneharry.
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: detonatorss on February 18, 2015, 01:11:35 pm
just a little question if i'll try to add a clone of this windows if i made it all how i made to load it in the function?
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: osler on February 18, 2015, 02:32:43 pm
In AccountLogin.lua modify the following:

Original
Code: [Select]
function AccountLogin_OnEvent(event, arg1, arg2, arg3)
if ( event == "SHOW_SERVER_ALERT" ) then
ServerAlertText:SetText(arg1);
ServerAlertFrame:Show();
elseif ...

Modified:
Code: [Select]
function AccountLogin_OnEvent(event, arg1, arg2, arg3)
if ( event == "SHOW_SERVER_ALERT" ) then
ServerAlertText:SetText(arg1);
ServerAlertFrame:Show();
ServerAlertCustomText:SetText(arg1);
ServerAlertCustomFrame:Show();
elseif ...

This will display the serveralert text in the new frame, but it will be merely a mirror of the original one since the text is piped into the game through the SHOW_SERVER_ALERT event.
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: detonatorss on February 18, 2015, 05:01:46 pm
i know it like an hour ago i thought it, but it has linked the link of server alert i am  trying to add my new link but is linked into the event the server alert and shos the same as the server alert
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: osler on February 18, 2015, 10:27:21 pm
AFAIK it is not possible to have two server alerts, although you may be able to send both serveralerts through the same event as a big string of text and then divide it.
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: detonatorss on February 18, 2015, 11:42:10 pm
Quote from: "osler"
AFAIK it is not possible to have two server alerts, although you may be able to send both serveralerts through the same event as a big string of text and then divide it.

and how i do it?
Title: Re: [TUTORIAL] Own server messages in the alert box on login
Post by: osler on February 19, 2015, 05:22:43 pm
Add a marker (=======////======== for example) to separate the articles. Then split the string http://lua-users.org/wiki/SplitJoin (http://lua-users.org/wiki/SplitJoin" onclick="window.open(this.href);return false;) using the marker.
Title: Re: [TUTORIAL] Own server messages in the alert box on login scr
Post by: jacburn1 on October 05, 2017, 06:22:03 am
Necro post but you can do a lot more with SimpleHTML than thought of here, just need to format it correctly.

Code: [Select]
SERVERALERT:
<html><body>
<p>Here's a sample of what can be done in the server alert file.

</p>
<p>There's three different header styles:</p>
<br/>
<h1 align="center">This is header style 1</h1>
<h2 align="center">This is header style 2</h2>
<h3 align="center">This is header style 3 (like paragraph style)</h3>
<hr/>
<p align="left">Text can be aligned left,</p>
<p align="center">center,</p>
<p align="right">or to the right!</p>

<img src="Interface/Icons/Ability_Ambush" width="24" height="24" align="right"/>
<img src="Interface/Icons/INV_Misc_Coin_02" width="24" height="24" align="left"/>
<img src="Interface/Icons/INV_Misc_Coin_03" width="24" height="24" align="center"/>

<p>It is |cffff0000also|r |cffff00ffpossible|r to |cff8080ffcolorize|r |cff00ffffthe|r |cff00ff00text|r,</p>
<p>add icons |TInterface/Icons/INV_Misc_Coin_01:16:16:0:0:64:64:4:60:4:60|t to the middle of the text,</p>
<hr/>
<p>You can have links also: <a href="modcraft.io">This link takes you to modcraft</a></p>
</body></html>


Note that img have to be outside of any text formatting and the src has to be part of the WoW Client. Colors and icons mid-text can be done just as with WoW API for escape sequencing since it gets converted to Lua basically in the end anyways, so those work.

Also seems that - while having "SERVERALERT:" inside the <html><body> on 3.3.5a works - later versions (only tested on Legion) require it to be outside of everything and the very first thing in the file.

Figured I'd put this here though since it's really the only topic on this content.
Title: Re: [TUTORIAL] Own server messages in the alert box on login scr
Post by: Steff on October 05, 2017, 08:55:06 pm
Thanks for this infos :)