Changing game description

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Changing game description

Postby VinciT » Thu Apr 28, 2016 9:55 pm

Is there a way to change a server's game description with SP? It's the string found in the 'Game' tab on the server browser:

Image

SourceMod has 'OnGetGameDescription' for this, is there a way to achieve the same thing with SP?
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Changing game description

Postby Ayuto » Fri Apr 29, 2016 6:45 am

It requires a hook. For which game do you want this?
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: Changing game description

Postby VinciT » Fri Apr 29, 2016 1:15 pm

Half Life 2: Deathmatch
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Changing game description

Postby Ayuto » Sat Apr 30, 2016 10:04 am

With version 319 you will be able to use this little snippet.

Syntax: Select all

from memory import get_virtual_function
from memory.hooks import PreHook

from engines.server import server_game_dll

@PreHook(get_virtual_function(server_game_dll, 'GetGameDescription'))
def pre_get_game_description(args):
return 'Your description'
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: Changing game description

Postby iPlayer » Sat Apr 30, 2016 10:09 am

I looked at how SM (SteamWorks extension) does it, and it uses SetGameDescription from ISteamGameServer.
Isn't that better to use the function that is meant to set game description anyway?

https://github.com/KyleSanderson/SteamWorks/blob/master/Extension/gsnatives.cpp#L91
https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/public/steam/isteamgameserver.h#L38
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
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Changing game description

Postby Ayuto » Sat Apr 30, 2016 10:24 am

Yeah :D I didn't know that method exists.

However, getting this to work requires more work, because the ISteamGameServer header is missing (at least in CS:S). We should create a PR for that. For now the snippet should suffice. :P
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: Changing game description

Postby VinciT » Sat Apr 30, 2016 3:43 pm

Works great, thank you so much Ayuto.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 122 guests