PDA

View Full Version : [Perl] [COD2] Nanny



voron00
27th February 2015, 10:52
Hello, i just want to share this awesome piece of code that i've been working on for nearly 4 years


Some historical explanations:

Original name of this program is NannyBot, and it was written by smugllama so all respect
goes to him first.
The project was abandoned in 2010.
But you can still get it download the original from http://smaert.com/nannybot.zip

Shortly, NannyBot is a log-parser, she loops through the server log-file and filters all
necessary data with regular expressions, she does not modify any game-files,
things like chat-responses, player statistics, !commands, etc. etc. are coming from this.

To send rcon commands to a server, NannyBot are using very old KKron perl module http://kkrcon.sourceforge.net/
Smugllama has improved it a bit, and so did i.

So what i did and why:

The thing has started somwhere in 2011 when i got my hands on RUS_Toujane_SD server, i wanted to bring NannyBot there,
but since 90% of people on that server are Russian, back than, i just wanted to translate
NannyBot to Russian language so i started digging through it's source code.

Job well done:

The whole deal went really far and despite the translation, NannyBot received
insane amount of good stuff from me and some of my friends.
Here is only some of stuff i did:

1. .exe?! Nope:

A perl script must be a perl script, it must run on whatever you want it to run. Windows, Linux, Macs, Mobile phones (hopefully in a future),
doesn't matter. The bad thing is, you must have a perl-runtime installed.
Linux and Macs already have it, on windows there is a cool build of perl called Strawberry Perl.

2. Use player GUID's to track their stats

Originally in NannyBot, players stats has been tracked by their nicknames,
this is good idea only if you are running a cracked server and everyone have
a Zero (0) GUID, but since most servers (even now) are pure, i made NannyBot
to track stats using GUID numbers.
Also added stats tracking for SD bomb plants/defuses, first bloods, nice/bad shots.
Also ability to remove stats for a player via single chat command.

3. Better IP-Geolocation

I've improved the geolocation code, and updated it's dependent modules and database
to the latest versions.

4. Voting system

No idea for what reason i did it, but i did it: !votekick, !voteban, !votemap, !votemap, !votetype
The thing is actually pretty simple and stupid, 60% of players on a server must vote !yes to make it pass.

5. Many many more...

There has been a lot of things done, many new !commands, etc.etc.etc...
You can loop through my github, there is not everything committed, the 'fork',
was started way earlier, but anyways...

Note: I removed the (Bot) thing from name, because...reasons...so now it's just Nanny.

Why now? It's 2015 already dude!:

Sorry about that, but i never planned of making an english version of 'Nanny'
But recently i had some time to do it and on RUS_Toujane_SD some people has
been asking for it.

Anyways, you can get it on my github page:
https://github.com/voron00/Nanny
English branch: https://github.com/voron00/Nanny/tree/cod2_english
Russian branch: https://github.com/voron00/Nanny/tree/cod2_russian
I know, i screwed up some commits there, but...anyways...

Install instruction are in README.md, it's pretty simple.
On linux, you need to install some modules through CPAN.
If you have any questions about that, you can ask here or
help yourself by using Google.
On windows, install a perl runtime, configure and run, easy as hell.
Also to simplify the intallation, i already included some dependent modules
in my github project.

Bugs:

Although, i squashed most of them, there are some bugs:

1. FTP, FTP and FTP: Nanny does't work properly with
some windows ftp servers (FileZilla?). Also rare issues like
disconnects, 'double' messages.

2. English translation issues (typos, crappy translated things, etc.)
The definitions database contains english and russian definitions (too lazy to care)

3. Code formatting issues on github:
I higly recommend using Notepad++ for viewing the code, it's simply great.

Well, i think that's all, not sure what else...Ii'm too lazy to post ALL the !commands,
but you can find them in a chat section (lines 1293-2335) or a config file.
Translation fixes, ideas are very welcome, thanks for reading and
good luck exploring the project.

kung foo man
27th February 2015, 14:48
Nice that there are some more developers out there. :D

It just feels a bit like "unfinished B3" though and Perl isn't exactly what most devs want to develop in.

I found your GitHub some weeks ago, a bit disappointing that the vmf2map repo got deleted.

Ni3ls
27th February 2015, 15:10
I used the nannybot myself a couple of years ago. B3 was too hard for me to understand and nannybot was easy as f*ck :) It was also very easy to add own commands back then

voron00
27th February 2015, 15:25
Nice that there are some more developers out there. :D

It just feels a bit like "unfinished B3" though and Perl isn't exactly what most devs want to develop in.

I found your GitHub some weeks ago, a bit disappointing that the vmf2map repo got deleted.

Well, im not forcing anyone to use or develop it, just sharing. I don't know b3, never seen, never used.
Anyways, a little hack for libcod users to make Nanny use sendGameServerCommand (change 'console' to 'whatever')

callbacksetup.gsc


// Callback Setup
// This script provides the hooks from code into script for the gametype callback functions.

//================================================== ===========================
// Code Callback functions

/*================
Called by code after the level's main script function has run.
================*/
CodeCallback_StartGameType()
{
// If the gametype has not beed started, run the startup
if(!isDefined(level.gametypestarted) || !level.gametypestarted)
{
//disableGlobalPlayerCollision(); // libcod: disable player collisions
thread consoleName();
thread sayw();
[[level.callbackStartGameType]]();
level.gametypestarted = true; // so we know that the gametype has been started up
}
}

/*================
Called when a player begins connecting to the server.
Called again for every map change or tournement restart.

Return undefined if the client should be allowed, otherwise return
a string with the reason for denial.

Otherwise, the client will be sent the current gamestate
and will eventually get to ClientBegin.

firstTime will be qtrue the very first time a client connects
to the server machine, but qfalse on map changes and tournement
restarts.
================*/
CodeCallback_PlayerConnect()
{
self endon("disconnect");
self thread kickFakeClients();
self thread unknown();
[[level.callbackPlayerConnect]]();
}

/*================
Called when a player drops from the server.
Will not be called between levels.
self is the player that is disconnecting.
================*/
CodeCallback_PlayerDisconnect()
{
self notify("disconnect");
[[level.callbackPlayerDisconnect]]();
}

/*================
Called when a player has taken damage.
self is the player that took damage.
================*/
CodeCallback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset)
{
self endon("disconnect");
[[level.callbackPlayerDamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset);
}

/*================
Called when a player has been killed.
self is the player that was killed.
================*/
CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
{
self endon("disconnect");
[[level.callbackPlayerKilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration);
}

//================================================== ===========================

/*================
Setup any misc callbacks stuff like defines and default callbacks
================*/
SetupCallbacks()
{
SetDefaultCallbacks();
// Set defined for damage flags used in the playerDamage callback
level.iDFLAGS_RADIUS = 1;
level.iDFLAGS_NO_ARMOR = 2;
level.iDFLAGS_NO_KNOCKBACK = 4;
level.iDFLAGS_NO_TEAM_PROTECTION = 8;
level.iDFLAGS_NO_PROTECTION = 16;
level.iDFLAGS_PASSTHRU = 32;
}

/*================
Called from the gametype script to store off the default callback functions.
This allows the callbacks to be overridden by level script, but not lost.
================*/
SetDefaultCallbacks()
{
level.default_CallbackStartGameType = level.callbackStartGameType;
level.default_CallbackPlayerConnect = level.callbackPlayerConnect;
level.default_CallbackPlayerDisconnect = level.callbackPlayerDisconnect;
level.default_CallbackPlayerDamage = level.callbackPlayerDamage;
level.default_CallbackPlayerKilled = level.callbackPlayerKilled;
}

/*================
Called when a gametype is not supported.
================*/
AbortLevel()
{
println("Aborting level - gametype is not supported");
level.callbackStartGameType = ::callbackVoid;
level.callbackPlayerConnect = ::callbackVoid;
level.callbackPlayerDisconnect = ::callbackVoid;
level.callbackPlayerDamage = ::callbackVoid;
level.callbackPlayerKilled = ::callbackVoid;
setcvar("g_gametype", "dm");
exitLevel(false);
}

/*================
================*/
callbackVoid()
{
}

consoleName()
{
for (;;)
{
if (getCvar("consoleName") != "")
{
level.consoleName = getCvar("consoleName");
}
wait 0.05;
}
}

sayw()
{
setcvar("sayw", "");
for (;;)
{
if (getCvar("sayw") != "")
{
message = getCvar("sayw");
sendGameServerCommand(-1, "h \"" + level.consoleName + "^7: " + message + "\"");
setcvar("sayw", "");
}
wait 0.05;
}
}


Then, in KKrcon.pm, replace this line

if ($command =~ /^say\s(.*)/) { $command = "say " . '"' . "$1" . '"'; }
with

if ($command =~ /^say\s(.*)/) { $command = "sayw " . '"' . "$1" . '"'; }
And start server with +set consoleName "^6Nanny"

suck000
21st March 2016, 09:56
Such a good bot ! I set it on my server. Working !

feritkkan
1st July 2016, 16:36
how run on linux i'm using putty somebody help me ty (note:i am noob at linux)

bulent
16th June 2017, 14:51
root@73:~/cod2/Nanny# ./nanny.sh
Can't locate DBD/SQLite.pm in @INC (you may need to install the DBD::SQLite module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at nanny.pl line 65.
BEGIN failed--compilation aborted at nanny.pl line 65 (#1)
(F) You said to do (or require, or use) a file that couldn't be found.
Perl looks for the file in all the locations mentioned in @INC, unless
the file name included the full path to the file. Perhaps you need
to set the PERL5LIB or PERL5OPT environment variable to say where the
extra library is, or maybe the script needs to add the library name
to @INC. Or maybe you just misspelled the name of the file. See
"require" in perlfunc and lib.
Uncaught exception from user code:
Can't locate DBD/SQLite.pm in @INC (you may need to install the DBD::SQLite module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at nanny.pl line 65.
BEGIN failed--compilation aborted at nanny.pl line 65.
root@73:~/cod2/Nanny#

voron00
17th June 2017, 00:55
cpan DBD::SQLite

http://www.cpan.org/modules/INSTALL.html

IzNoGoD
17th June 2017, 12:50
root@73:~/cod2/Nanny# ./nanny.sh
Can't locate DBD/SQLite.pm in @INC (you may need to install the DBD::SQLite module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at nanny.pl line 65.
BEGIN failed--compilation aborted at nanny.pl line 65 (#1)
(F) You said to do (or require, or use) a file that couldn't be found.
Perl looks for the file in all the locations mentioned in @INC, unless
the file name included the full path to the file. Perhaps you need
to set the PERL5LIB or PERL5OPT environment variable to say where the
extra library is, or maybe the script needs to add the library name
to @INC. Or maybe you just misspelled the name of the file. See
"require" in perlfunc and lib.
Uncaught exception from user code:
Can't locate DBD/SQLite.pm in @INC (you may need to install the DBD::SQLite module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at nanny.pl line 65.
BEGIN failed--compilation aborted at nanny.pl line 65.
root@73:~/cod2/Nanny#


Really?


...
you may need to install the DBD::SQLite module
...

bulent
17th June 2017, 15:30
Install but Same problem.

bulent
17th June 2017, 15:33
root@73:~# cpan DBD::SQLite
Reading '/root/.cpan/Metadata'
Database was generated on Sat, 17 Jun 2017 00:29:02 GMT
Running install for module 'DBD::SQLite'
Running make for I/IS/ISHIGAKI/DBD-SQLite-1.54.tar.gz
Checksum for /root/.cpan/sources/authors/id/I/IS/ISHIGAKI/DBD-SQLite-1.54.tar.gz ok

CPAN.pm: Building I/IS/ISHIGAKI/DBD-SQLite-1.54.tar.gz

Checking if your kit is complete...
Looks good
Using DBI 1.63 (for perl 5.018002 on x86_64-linux-gnu-thread-multi) installed in /usr/lib/perl5/auto/DBI/
Writing Makefile for DBD::SQLite
Writing MYMETA.yml and MYMETA.json
ISHIGAKI/DBD-SQLite-1.54.tar.gz
make -- NOT OK
'YAML' not installed, will not store persistent state
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
root@73:~#

kung foo man
17th June 2017, 16:22
Based on this https://stackoverflow.com/questions/22360091/how-to-fix-yaml-not-installed-when-installing-xmlsimple

You either need: apt-get install build-essential

Or: cpan YAML

bulent
27th June 2017, 19:09
Based on this https://stackoverflow.com/questions/22360091/how-to-fix-yaml-not-installed-when-installing-xmlsimple

You either need: apt-get install build-essential

Or: cpan YAML



root@73:~/cod2/Nanny# apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
dpkg-dev fakeroot libalgorithm-diff-perl libalgorithm-diff-xs-perl
libalgorithm-merge-perl libdpkg-perl libfakeroot libfile-fcntllock-perl
Suggested packages:
debian-keyring
The following NEW packages will be installed
build-essential dpkg-dev fakeroot libalgorithm-diff-perl
libalgorithm-diff-xs-perl libalgorithm-merge-perl libdpkg-perl libfakeroot
libfile-fcntllock-perl
0 to upgrade, 9 to newly install, 0 to remove and 3 not to upgrade.
Need to get 1,082 kB of archives.
After this operation, 4,083 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libdpkg-perl all 1.17.5ubuntu5.7 [179 kB]
Get:2 http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main dpkg-dev all 1.17.5ubuntu5.7 [726 kB]
Get:3 http://tr.archive.ubuntu.com/ubuntu/ trusty/main build-essential amd64 11.6ubuntu6 [4,838 B]
Get:4 http://tr.archive.ubuntu.com/ubuntu/ trusty/main libfakeroot amd64 1.20-3ubuntu2 [25.4 kB]
Get:5 http://tr.archive.ubuntu.com/ubuntu/ trusty/main fakeroot amd64 1.20-3ubuntu2 [55.0 kB]
Get:6 http://tr.archive.ubuntu.com/ubuntu/ trusty/main libalgorithm-diff-perl all 1.19.02-3 [50.0 kB]
Get:7 http://tr.archive.ubuntu.com/ubuntu/ trusty/main libalgorithm-diff-xs-perl amd64 0.04-2build4 [12.6 kB]
Get:8 http://tr.archive.ubuntu.com/ubuntu/ trusty/main libalgorithm-merge-perl all 0.08-2 [12.7 kB]
Get:9 http://tr.archive.ubuntu.com/ubuntu/ trusty/main libfile-fcntllock-perl amd64 0.14-2build1 [15.9 kB]
Fetched 1,082 kB in 0s (3,672 kB/s)
Selecting previously unselected package libdpkg-perl.
(Reading database ... 67072 files and directories currently installed.)
Preparing to unpack .../libdpkg-perl_1.17.5ubuntu5.7_all.deb ...
Unpacking libdpkg-perl (1.17.5ubuntu5.7) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../dpkg-dev_1.17.5ubuntu5.7_all.deb ...
Unpacking dpkg-dev (1.17.5ubuntu5.7) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../build-essential_11.6ubuntu6_amd64.deb ...
Unpacking build-essential (11.6ubuntu6) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../libfakeroot_1.20-3ubuntu2_amd64.deb ...
Unpacking libfakeroot:amd64 (1.20-3ubuntu2) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../fakeroot_1.20-3ubuntu2_amd64.deb ...
Unpacking fakeroot (1.20-3ubuntu2) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../libalgorithm-diff-perl_1.19.02-3_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.02-3) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../libalgorithm-diff-xs-perl_0.04-2build4_amd64.deb ...
Unpacking libalgorithm-diff-xs-perl (0.04-2build4) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../libalgorithm-merge-perl_0.08-2_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-2) ...
Selecting previously unselected package libfile-fcntllock-perl.
Preparing to unpack .../libfile-fcntllock-perl_0.14-2build1_amd64.deb ...
Unpacking libfile-fcntllock-perl (0.14-2build1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libdpkg-perl (1.17.5ubuntu5.7) ...
Setting up dpkg-dev (1.17.5ubuntu5.7) ...
Setting up build-essential (11.6ubuntu6) ...
Setting up libfakeroot:amd64 (1.20-3ubuntu2) ...
Setting up fakeroot (1.20-3ubuntu2) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libalgorithm-diff-perl (1.19.02-3) ...
Setting up libalgorithm-diff-xs-perl (0.04-2build4) ...
Setting up libalgorithm-merge-perl (0.08-2) ...
Setting up libfile-fcntllock-perl (0.14-2build1) ...
root@73:~/cod2/Nanny# ./nanny.sh
Can't locate DBD/SQLite.pm in @INC (you may need to install the DBD::SQLite module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at nanny.pl line 65.
BEGIN failed--compilation aborted at nanny.pl line 65 (#1)
(F) You said to do (or require, or use) a file that couldn't be found.
Perl looks for the file in all the locations mentioned in @INC, unless
the file name included the full path to the file. Perhaps you need
to set the PERL5LIB or PERL5OPT environment variable to say where the
extra library is, or maybe the script needs to add the library name
to @INC. Or maybe you just misspelled the name of the file. See
"require" in perlfunc and lib.

Uncaught exception from user code:
Can't locate DBD/SQLite.pm in @INC (you may need to install the DBD::SQLite module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at nanny.pl line 65.
BEGIN failed--compilation aborted at nanny.pl line 65.
root@73:~/cod2/Nanny#

IzNoGoD
28th June 2017, 12:42
I see you havent even tried everything and area already out of ideas.

Good job on sending me a private message about 30 minutes after responding to a thread. I will now never help you again, because you obviously can't read.

YuriJurek
28th June 2017, 12:49
LMAO, it says it all right there in what you have pasted...

bulent
28th January 2018, 14:16
Hi guys
nanny bot banned !ban good work but one question.Example:I banned aimbot reconnect aimbot 10-15 second play bot banned I want 1 second aimbot banned nannybot

bulent
30th January 2018, 20:14
I see you havent even tried everything and area already out of ideas.

Good job on sending me a private message about 30 minutes after responding to a thread. I will now never help you again, because you obviously can't read.


Proud IzNoGod so bad lol...

bulent
30th January 2019, 23:16
Well, im not forcing anyone to use or develop it, just sharing. I don't know b3, never seen, never used.
Anyways, a little hack for libcod users to make Nanny use sendGameServerCommand (change 'console' to 'whatever')

callbacksetup.gsc


// Callback Setup
// This script provides the hooks from code into script for the gametype callback functions.

//================================================== ===========================
// Code Callback functions

/*================
Called by code after the level's main script function has run.
================*/
CodeCallback_StartGameType()
{
// If the gametype has not beed started, run the startup
if(!isDefined(level.gametypestarted) || !level.gametypestarted)
{
//disableGlobalPlayerCollision(); // libcod: disable player collisions
thread consoleName();
thread sayw();
[[level.callbackStartGameType]]();
level.gametypestarted = true; // so we know that the gametype has been started up
}
}

/*================
Called when a player begins connecting to the server.
Called again for every map change or tournement restart.

Return undefined if the client should be allowed, otherwise return
a string with the reason for denial.

Otherwise, the client will be sent the current gamestate
and will eventually get to ClientBegin.

firstTime will be qtrue the very first time a client connects
to the server machine, but qfalse on map changes and tournement
restarts.
================*/
CodeCallback_PlayerConnect()
{
self endon("disconnect");
self thread kickFakeClients();
self thread unknown();
[[level.callbackPlayerConnect]]();
}

/*================
Called when a player drops from the server.
Will not be called between levels.
self is the player that is disconnecting.
================*/
CodeCallback_PlayerDisconnect()
{
self notify("disconnect");
[[level.callbackPlayerDisconnect]]();
}

/*================
Called when a player has taken damage.
self is the player that took damage.
================*/
CodeCallback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset)
{
self endon("disconnect");
[[level.callbackPlayerDamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset);
}

/*================
Called when a player has been killed.
self is the player that was killed.
================*/
CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
{
self endon("disconnect");
[[level.callbackPlayerKilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration);
}

//================================================== ===========================

/*================
Setup any misc callbacks stuff like defines and default callbacks
================*/
SetupCallbacks()
{
SetDefaultCallbacks();
// Set defined for damage flags used in the playerDamage callback
level.iDFLAGS_RADIUS = 1;
level.iDFLAGS_NO_ARMOR = 2;
level.iDFLAGS_NO_KNOCKBACK = 4;
level.iDFLAGS_NO_TEAM_PROTECTION = 8;
level.iDFLAGS_NO_PROTECTION = 16;
level.iDFLAGS_PASSTHRU = 32;
}

/*================
Called from the gametype script to store off the default callback functions.
This allows the callbacks to be overridden by level script, but not lost.
================*/
SetDefaultCallbacks()
{
level.default_CallbackStartGameType = level.callbackStartGameType;
level.default_CallbackPlayerConnect = level.callbackPlayerConnect;
level.default_CallbackPlayerDisconnect = level.callbackPlayerDisconnect;
level.default_CallbackPlayerDamage = level.callbackPlayerDamage;
level.default_CallbackPlayerKilled = level.callbackPlayerKilled;
}

/*================
Called when a gametype is not supported.
================*/
AbortLevel()
{
println("Aborting level - gametype is not supported");
level.callbackStartGameType = ::callbackVoid;
level.callbackPlayerConnect = ::callbackVoid;
level.callbackPlayerDisconnect = ::callbackVoid;
level.callbackPlayerDamage = ::callbackVoid;
level.callbackPlayerKilled = ::callbackVoid;
setcvar("g_gametype", "dm");
exitLevel(false);
}

/*================
================*/
callbackVoid()
{
}

consoleName()
{
for (;;)
{
if (getCvar("consoleName") != "")
{
level.consoleName = getCvar("consoleName");
}
wait 0.05;
}
}

sayw()
{
setcvar("sayw", "");
for (;;)
{
if (getCvar("sayw") != "")
{
message = getCvar("sayw");
sendGameServerCommand(-1, "h \"" + level.consoleName + "^7: " + message + "\"");
setcvar("sayw", "");
}
wait 0.05;
}
}


Then, in KKrcon.pm, replace this line

if ($command =~ /^say\s(.*)/) { $command = "say " . '"' . "$1" . '"'; }
with

if ($command =~ /^say\s(.*)/) { $command = "sayw " . '"' . "$1" . '"'; }
And start server with +set consoleName "^6Nanny"



******* script compile error *******
bad syntax: (file 'maps/mp/gametypes/_callbacksetup.gsc', line 151)
sendGameServerCommand(-1, "h "" + level.consoleName + "^7: " + message + """);
*
************************************
Sys_Error: Error during initialization:
script compile error
(see console for details)

> [PLUGIN UNLOADED]:

kung foo man
30th January 2019, 23:49
sendGameServerCommand(-1, "h \"" + level.consoleName + "^7: " + message + "\"");


For some reason the forum seems to remove the slash from \ when copying the code back into the textarea :S

Just make sure to have the two \ in your code

I might disable the complete color shit and stupid formatting in vbb editor.

bulent
31st January 2019, 16:35
sendGameServerCommand(-1, "h \"" + level.consoleName + "^7: " + message + "\"");


For some reason the forum seems to remove the slash from \ when copying the code back into the textarea :S

Just make sure to have the two \ in your code

I might disable the complete color shit and stupid formatting in vbb editor.

(Maybe wrong that test.sh "+set consoleName $Nanny"\)


#!/bin/bash

sv_maxclients="32"
fs_game="console"
fs_homepath="/root/cod2"
cod="/root/cod2/cod2_lnxded_1_0a"
com_hunkMegs="256"
config="by.cfg"
cracked="1"
net_port="28929"


args=\
"+set fs_homepath \"$fs_homepath\" "\
"+set sv_cracked $cracked "\
"+set fs_game $fs_game "\
"+set net_port $net_port "\
"+set com_hunkMegs $com_hunkMegs "\
"+set sv_maxclients $sv_maxclients "\
"+set fs_basepath \"$fs_homepath\" "\
"+set consoleName $Nanny"\
"+exec $config"


LD_PRELOAD="/root/cod2/libcod/bin/libcod2_1_0.so" $cod $args +set g_gametype tdm +map mp_toujane

IzNoGoD
31st January 2019, 19:18
"+set consoleName \"\$Nanny\" "\