|
|
|
|
Re: current players in servername - c++ [message #451594 is a reply to message #451368] |
Sun, 14 August 2011 14:26 |
iRANian
Messages: 4308 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
I wrote something simple that runs inside a dedicated thread and every 5 seconds updates the player list like that. It grabs the actual name of the server and saves it, then appends (%d/%d) to it so it looks like:
SERVER_NAME (CURRENT_PLAYERS/MAX_PLAYERS)
as shown in the attached screenshot. With my GameSpy plugin you can set it so GameSpy broadcasts a custom game title for your server different from the one you set for WOL, so the player count doesn't show up in the title of your server on GSA.
Here's the code and how to use it if you want to have it as an SSGM plugin:
plugin.cpp includes:
void Plugin_Load() {
CreateThread(NULL, NULL, Set_Player_Count_Game_Title, NULL, NULL, NULL);
}
DWORD WINAPI Set_Player_Count_Game_Title(LPVOID params)
{
const char* ServerName = WideCharToChar(The_Game()->GameTitle.Peek_Buffer());
char tmp[128];
for (;;)
{
memset(tmp, 0x0, 128);
sprintf(tmp, "%s (%d/%d)", ServerName, The_Game()->CurrentPlayers, The_Game()->MaxPlayers);
const wchar_t *Data = CharToWideChar(tmp);
The_Game()->GameTitle = Data;
delete []Data;
Sleep(5000);
}
delete []ServerName;
return 0;
}
And inside plugin.h include:
DWORD WINAPI Set_Player_Count_Game_Title(LPVOID params);
-
Attachment: Untitled.png
(Size: 68.94KB, Downloaded 109 times)
Long time and well respected Renegade community member, programmer, modder and tester.
Scripts 4.0 private beta tester since May 2011.
My Renegade server plugins releases
[Updated on: Sun, 14 August 2011 15:16] Report message to a moderator
|
|
|
|
|