Csgo motd

Please post any questions about developing your plugin here. Please use the search function before posting!
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Csgo motd

Postby stonedegg » Thu Aug 06, 2015 3:29 pm

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'".
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Sun Aug 09, 2015 10:11 pm

bump.
stinkyfax
Junior Member
Posts: 4
Joined: Tue Aug 04, 2015 2:07 pm

Postby stinkyfax » Mon Aug 10, 2015 11:29 am

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.
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Mon Aug 10, 2015 1:34 pm

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.
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Tue Nov 17, 2015 1:13 pm

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.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Tue Nov 17, 2015 2:08 pm

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.
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Tue Nov 17, 2015 2:32 pm

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.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Tue Nov 17, 2015 2:55 pm

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.
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Tue Nov 17, 2015 3:34 pm

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?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Tue Nov 17, 2015 3:44 pm

Syntax: Select all

motd(index, 'test', <path to the file on your server>)
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Tue Nov 17, 2015 4:04 pm

Thanks
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Postby iPlayer » Tue Nov 17, 2015 4:34 pm

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?
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Tue Nov 17, 2015 9:49 pm

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')
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Postby iPlayer » Mon Dec 21, 2015 6:12 pm

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
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re:

Postby decompile » Tue Aug 23, 2016 5:11 am

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.
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: Csgo motd

Postby iPlayer » Tue Aug 23, 2016 5:38 am

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
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: Csgo motd

Postby decompile » Tue Aug 23, 2016 6:36 am

Thank you, all I wanted :)
battleweaver
Member
Posts: 43
Joined: Mon Oct 02, 2017 7:57 am
Location: Moscow
Contact:

Re: Csgo motd

Postby battleweaver » Mon Jul 30, 2018 10:48 am

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?
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: Csgo motd

Postby decompile » Mon Jul 30, 2018 11:48 am

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?
battleweaver
Member
Posts: 43
Joined: Mon Oct 02, 2017 7:57 am
Location: Moscow
Contact:

Re: Csgo motd

Postby battleweaver » Mon Jul 30, 2018 1:28 pm

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).

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 36 guests