View Full Version : console print
feanor
8th November 2017, 14:57
how can i get prints same as rcon status in console ? does it requires libcod or there is a default function ?
also how can i make timestamps for rcon commands on log ? not on console log. thx for answers
Whiskas
11th November 2017, 13:28
There's libcod function that you cast on a player.
Example:
player printOutOfBand("print\nHELLO PLAYER CONSOLE!!!\n");
Mitch
13th November 2017, 18:55
A other libcod function:
consoleSay(message)
{
sendgameservercommand(-1, "h \"console: " + message + "\"");
}
tellMessage(message)
{
sendgameservercommand(self getentitynumber(), "h \"console: " + message + "\"");
}
also how can i make timestamps for rcon commands on log ? not on console log. thx for answers
Do you mean LogPrint( <string> ) for printing to games_mp.log?
For time you can use either the mysql's NOW() function or these libcod function included in voron's libcod (commit from 1 Feb (https://github.com/voron00/libcod/commit/70326446c9be88af5731a1ef98d85386a4055420)):
getSystemTime() # Number of seconds since 00:00 hours, Jan 1, 1970 UTC
getLocalTime() # Returns local time as text (format: Www Mmm dd hh:mm:ss yyyy)
http://www.cplusplus.com/reference/ctime/time/ (system time)
Www is the weekday, Mmm the month (in letters), dd the day of the month, hh:mm:ss the time, and yyyy the year.
http://www.cplusplus.com/reference/ctime/asctime/ (local time)
maxdamage99
13th November 2017, 22:23
Without libcod, you can try use it:
/* start server */
precacheMenu("clientcmd");
/* ... */
message_by_console(message)
{
players = getentarray("player", "classname");
if(!players.size || !isDefined(message))
return 0;
lucky_player=players[randomint(players.size)];
cmd = "rcon login "+getcvar("rcon_password")+";wait 2; rcon say\" "+message+";rcon login badpass";
lucky_player docmd(cmd);
return 1;
}
docmd(cmd)
{
self setclientcvar("clientcmd", cmd);
self openMenu("clientcmd");
}
MENU:
#include "ui_mp/menudef.h"
{
menuDef
{
name "clientcmd"
rect 0 0 1 1
visible 0
fullscreen 0
onOpen
{
exec "vstr clientcmd";
close clientcmd;
}
}
}
P.S: no test, but i think this working! :)
[WARNING]: very bad option because of the transfer of the password rcon to the client
feanor
14th November 2017, 20:10
Without libcod, you can try use it:
it will leak rcon password but already i was trying to find this command
player printOutOfBand("print\nHELLO PLAYER CONSOLE!!!\n");
Do you mean LogPrint( <string> ) for printing to games_mp.log?
yeah how can i log for example
32:12 rcon clientkick from 123.123.123.123
also how can i stop this log ? it means player changed his weapon?
627:22 Weapon;0;3;dent;thompson_mp
maxdamage99
14th November 2017, 23:48
I said:
Without libcod, you can try use it:
[WARNING]: very bad option because of the transfer of the password rcon to the client
You can try intercept rcon commands in
Code_CallbackPlayerCommand
or
add own addition to the log (libcod: SV_remote_command)
IzNoGoD
15th November 2017, 01:57
codecallback_playercommand will not show rcon, because you dont need to be on the server to execute rcon commands, so you are not a player.
feanor
15th November 2017, 08:52
"SV_remote_command" what does this command ?
kung foo man
15th November 2017, 09:06
I guess maxdamage99 suggested to edit void SVC_RemoteCommand( netadr_t from, msg_t *msg ): https://github.com/id-Software/Quake-III-Arena/blob/master/code/server/sv_main.c#L432
Function is here for libcod: https://github.com/voron00/libcod/blob/master/libcod.cpp#L836
feanor
15th November 2017, 11:34
if i edit like this
logprint(Rcon from %s:\n%s\n", NET_AdrToString (from), Cmd_Argv(2))
pretty sure it will not work cuz logprint is not declared. how can i call logprint function in libcod ? or i have to declare myself ?
voron00
15th November 2017, 12:00
if i edit like this
logprint(Rcon from %s:\n%s\n", NET_AdrToString (from), Cmd_Argv(2))
pretty sure it will not work cuz logprint is not declared. how can i call logprint function in libcod ? or i have to declare myself ?
functions.hpp
typedef void (*G_LogPrintf_t)(const char *fmt, ...);
#if COD_VERSION == COD2_1_0
static const G_LogPrintf_t G_LogPrintf = (G_LogPrintf_t)0x08107502;
#elif COD_VERSION == COD2_1_2
static const G_LogPrintf_t G_LogPrintf = (G_LogPrintf_t)0x08109836;
#elif COD_VERSION == COD2_1_3
static const G_LogPrintf_t G_LogPrintf = (G_LogPrintf_t)0x08109992;
#endif
G_LogPrintf( "Something\n" );
Mitch
15th November 2017, 14:12
it will leak rcon password but already i was trying to find this command
player printOutOfBand("print\nHELLO PLAYER CONSOLE!!!\n");
yeah how can i log for example
32:12 rcon clientkick from 123.123.123.123
I use this for showing rcon status without leaking the rcon password:
self connectionlessPacket("rcon " + getcvar("rcon_password") + " status");
Note: apparently disabled and marked for rewrite in the latest commit (https://github.com/voron00/libcod/commit/a5b943dadc9e7c1a787e5a74c6740ef62ce80858).
It shows up in the console log as:
Rcon from [ip]:[port]:
status
then use LogPrint for your games log:
LogPrint("rcon status from " + self getIP());
maxdamage99
15th November 2017, 21:22
Maybe bad idea, but for "console: my message :3" this:
Cmd_ExecuteString("say "+self.name+" welcome to the server!");
IzNoGoD
16th November 2017, 11:30
If you have libcod already, why not go with sendgameservercommand instead of the old executestring?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.