PDA

View Full Version : [callback] RCON



maxdamage99
13th January 2019, 10:46
example:


codecallback_remoteCommand(from, command, pointerMsg)
{
parseCMD = strtok(command, " ");
command = parseCMD[2];
value = parseCMD[3];

sfrom = strtok(from, ":");
ip = sfrom[0];
port = sfrom[1];

if (command == "rcon_password" || command == "killserver" || command == "quit")
return;

if ((command == "clientkick" || command == "banclient") && isDefined(value))
{
value = int(value);
if (value < 0 || value > 63)
return;

/* some */
player = getPlayerByEntityID(value);
if (isDefined(player))
player iprintlnbold("bye bye :(");
}

doRcon(from, pointerMsg);
}


https://github.com/damage99/libcod/commit/a15523897c07892138cbceb22f93138508d1ead9

thank you very much to Voron00 (https://github.com/voron00/libcod) for help!

kung foo man
13th January 2019, 10:59
Nice, is this rcon flood protected?

maxdamage99
13th January 2019, 11:07
Nice, is this rcon flood protected?

yeah
https://github.com/damage99/libcod/blob/main-branch-damage99/libcod.cpp#L971

callback is after rateLimit()
https://github.com/damage99/libcod/blob/main-branch-damage99/libcod.cpp#L991