Page 1 of 2

Csgo motd

Posted: Thu Aug 06, 2015 3:29 pm
by stonedegg
I tried this, but can't get it to work, is there another way?

Syntax: Select all

from _messages import UserMessage
from filters.players import PlayerIter
from filters.recipients import RecipientFilter

def load():
for index in PlayerIter():
motd(index,
name='info', show=True,
subkeys={'title': 'Test', 'type': '2', 'msg': 'http://www.google.com'})

def motd(users, name, show=True, subkeys=dict()):
recipients = RecipientFilter(users)
message = UserMessage(recipients, 'VGUIMenu')
message.set_string('name', name)
message.set_bool('show', show)
message.set_byte('length', len(subkeys))
for key, value in subkeys.items():
message.set_string('key', key)
message.set_string('value', value)
message.send_message()


I'm getting errors like "Could not find field name 'key' for usermessage 'VGUIMenu'".

Posted: Sun Aug 09, 2015 10:11 pm
by stonedegg
bump.

Posted: Mon Aug 10, 2015 11:29 am
by stinkyfax
It is likely that you are doing something wrong in your `key, value` loop, but I do not have enough experience to tell you.

On the CSGO MOTD subject, it is very sensitive issue and when you fix your key-value problem, you are likely to get to the point when MOTD just doesn't work anyway.
In that case, please read this topic: https://forums.alliedmods.net/showthread.php?p=1808763 it helped me once, hopefully it will save you hours of a pain.

Posted: Mon Aug 10, 2015 1:34 pm
by stonedegg
I took the script from here: http://forums.sourcepython.com/showthread.php?718-TF2-VGUIMenu-not-working&p=4007&viewfull=1#post4007

The built-in messages class isn't working either.

Posted: Tue Nov 17, 2015 1:13 pm
by stonedegg
I tried to open a motd window in csgo now again with the recent messages update, but it's still not working properly.
In my testing code I found out that the motd panel actually opens, but it's hidden even tho "show" is set to True. The website I'm using opens a new browser tab/window which will be displayed in game, but the actual motd won't.

Screenshot


Syntax: Select all

from messages import VGUIMenu
from events import Event
from players.helpers import index_from_userid


def motd(index, title, site, show=True):
name = 'info'
subkeys = {'title': title, 'type': '2', 'msg': site}

VGUIMenu(name, subkeys=subkeys, show=show).send(index)

@Event('player_say')
def player_say(event):
print("test")
userid = event.get_int('userid')
index = index_from_userid(userid)
motd(index, 'test', 'https://jsfiddle.net/opuztLvj/4/')


Any ideas? Thanks.

Posted: Tue Nov 17, 2015 2:08 pm
by Ayuto
Your screenshot shows a working MOTD, so where is the problem?

When I was testing the MOTD with the new messages package I was using the example MOTD from the AlliedModders thread stinckyfax linked here:

Code: Select all

<html>
<
head>
<
script type="text/javascript">
window.onload = function(){
    var 
popup=window.open("http://blog.counter-strike.net/motd/recent_post.php","Test Page :D ","height=600,width=800");
};
</script>
</head>
<body>
</body>
</html>
It seems like you always need to use the "window.onload" listener and use the JavaScript function "window.open" to open your website.

Posted: Tue Nov 17, 2015 2:32 pm
by stonedegg
The problem is that this is not a solution, but a workaround. You will first need to open another website to get to the website you actually want to go, making it a bit more tricky if you have a plugin that let's you open a players' steam profile and not the same website every time.

Sourcemod can do it, so why not SourcePython? I would still like to use the regular MOTD panel.

Posted: Tue Nov 17, 2015 2:55 pm
by Ayuto
A better workaround would be to write a temporary file on your server and send that instead of the actual website. Though, I hope there is a real fix.

Posted: Tue Nov 17, 2015 3:34 pm
by stonedegg
Ayuto wrote:A better workaround would be to write a temporary file on your server and send that instead of the actual website.


How do you send that?

Posted: Tue Nov 17, 2015 3:44 pm
by Ayuto

Syntax: Select all

motd(index, 'test', <path to the file on your server>)

Posted: Tue Nov 17, 2015 4:04 pm
by stonedegg
Thanks

Posted: Tue Nov 17, 2015 4:34 pm
by iPlayer
I've never used MOTD with local server pages, so I don't know - path relative to what? mod folder? E.g. cstrike/page.html?

Posted: Tue Nov 17, 2015 9:49 pm
by Ayuto
I can't remember if relative paths were working. But if they are working, they would probably need to be relative to the srcds executable. Example:

Syntax: Select all

motd(index, 'test', 'file://cstrike/page.html')

Posted: Mon Dec 21, 2015 6:12 pm
by iPlayer
Worth mentioning that I got this error in CS:S

Blocking MOTD URL 'file://D:/srv/page.html'; must begin with 'http://' or 'https://' or be about:blank

Re:

Posted: Tue Aug 23, 2016 5:11 am
by decompile
stonedegg wrote:The problem is that this is not a solution, but a workaround. You will first need to open another website to get to the website you actually want to go, making it a bit more tricky if you have a plugin that let's you open a players' steam profile and not the same website every time.

Sourcemod can do it, so why not SourcePython? I would still like to use the regular MOTD panel.


Sorry for bumping older threads, but Im still having problems with that.

In my plugin, players can view their or other's player profiles in form of a menu and theres one option to open up the player's steamcommunity page. Is there already a work around or a good redirect script for that? I dont want to add for every player a specific STEAM_0:xx redirect file on my web server.

Re: Csgo motd

Posted: Tue Aug 23, 2016 5:38 am
by iPlayer
How about this

Syntax: Select all

<!doctype html>
<html>
<head>
<title>Redirect</title>
<script type="application/javascript">
var redirectToIndex = location.href.indexOf('#');
if (redirectToIndex > -1) {
var redirectTo = location.href.slice(redirectToIndex + 1);
window.open(redirectTo, "MOTD", "scrollbars=yes");
}
</script>
</head>
<body>
</body>
</html>

Use it like so

Code: Select all

/redirect.html#http://steamcommunity.com/id/its_iPlayer

Re: Csgo motd

Posted: Tue Aug 23, 2016 6:36 am
by decompile
Thank you, all I wanted :)

Re: Csgo motd

Posted: Mon Jul 30, 2018 10:48 am
by battleweaver
Guys, a new Valve patch happened.
It broke this way of displaying vgui menu in CS:GO.

Some code:

Syntax: Select all

from commands.typed import TypedSayCommand
from filters.players import PlayerIter
from messages import VGUIMenu
from players.engines.csgo import Player

def motd(player, title, site, show=True):
name = 'info'
subkeys = {'title': title, 'type': '2', 'msg': site}
return VGUIMenu(name, subkeys=subkeys, show=show).send(player.index)


def vgui_show(player: int, session_url: str, session_id: str):
print(f'opening {session_url}/ for player {player.index}')
vgui_menu = motd(player, 'test', f'{session_url}/')
return vgui_menu

@TypedSayCommand('!vgui')
def cmd_on_strip(command_info):
print(command_info.index)
player = Player(command_info.index)
vgui_show(player, "https://jsfiddle.net/opuztLvj/4", "")

Code, in jsfiddle link:

Code: Select all

<script>
function timeIt(){
    setTimeout("moveIt()",1);
}
function moveIt(){
    window.open("http://google.com");
}
</script>
<body onload="timeIt()">

I used windows game client with -insecure argument for testing.
--------------------------------------------------------
Checksum : 4aae7cec04d8de05a7f0f2e20700746d
Date : 2018-07-30 10:43:39.893110
OS : Windows-10-10.0.17134
Game : csgo
SP version : 653
Github commit : e5c043f1c5d7e15aaaca30d8f6341363002d1240
Server plugins:
00: Source.Python, (C) 2012-2018, Source.Python Team.
SP plugins:
00: my_messages
--------------------------------------------------------
When I type command, I get text message and i do not get any vgui window.
Any ideas?

Re: Csgo motd

Posted: Mon Jul 30, 2018 11:48 am
by decompile
Hey,

you should definitely read this thread because CS:GO is not showing a motd unless you use a workaround with javascript.

Im not sure, but I think I heard something about the dead of CS:GO motd because the way they changed the motd in the recent patch. (You can only put a url in the motd file...)

I cant confirm it, but I can remember hearing something like this the past days.

Maybe because of the Panorama update? Are you using it for the testing purpose?

Re: Csgo motd

Posted: Mon Jul 30, 2018 1:28 pm
by battleweaver
decompile wrote:Hey,

you should definitely read this thread because CS:GO is not showing a motd unless you use a workaround with javascript.
Im not sure, but I think I heard something about the dead of CS:GO motd because the way they changed the motd in the recent patch. (You can only put a url in the motd file...)
I cant confirm it, but I can remember hearing something like this the past days.
Maybe because of the Panorama update? Are you using it for the testing purpose?

First of, I should mention, that I used code from this thread, and it worked fine before Panorama update. I tried to debug it till protobuff method in _send().
Worked without errors, and trick you described, worked fine (see jsfiddle code).
In my opinion, problem is in Panorama update. Valve even mentioned MOTD in official patch notes (not relating to this issue, but still...). If this is correct, I still require community help with this issue (at least, pointing out that my testing enviroment is incorrect, and everything works fine).