Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: [Perl] [COD2] Nanny

  1. #1
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    224
    Thanks
    62
    Thanked 189 Times in 100 Posts

    Post [Perl] [COD2] Nanny

    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.

  2. The Following 6 Users Say Thank You to voron00 For This Useful Post:

    kung foo man (27th February 2015),maxdamage99 (1st March 2015),Ni3ls (27th February 2015),serthy (27th February 2015),ysniper (24th March 2016),YuriJurek (27th February 2015)

  3. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    1,950
    Thanks
    1,839
    Thanked 1,055 Times in 732 Posts
    Nice that there are some more developers out there.

    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.
    timescale 0.01

  4. #3
    Brigadier General
    Join Date
    Dec 2012
    Posts
    988
    Thanks
    436
    Thanked 164 Times in 126 Posts
    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

  5. #4
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    224
    Thanks
    62
    Thanked 189 Times in 100 Posts
    Quote Originally Posted by kung foo man View Post
    Nice that there are some more developers out there.

    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

    PHP Code:
    //    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(eInflictoreAttackeriDamageiDFlagssMeansOfDeathsWeaponvPointvDirsHitLoctimeOffset)
    {
        
    self endon("disconnect");
        [[
    level.callbackPlayerDamage]](eInflictoreAttackeriDamageiDFlagssMeansOfDeathsWeaponvPointvDirsHitLoctimeOffset);
    }

    /*================
    Called when a player has been killed.
    self is the player that was killed.
    ================*/
    CodeCallback_PlayerKilled(eInflictoreAttackeriDamagesMeansOfDeathsWeaponvDirsHitLoctimeOffsetdeathAnimDuration)
    {
        
    self endon("disconnect");
        [[
    level.callbackPlayerKilled]](eInflictoreAttackeriDamagesMeansOfDeathsWeaponvDirsHitLoctimeOffsetdeathAnimDuration);
    }

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

    /*================
    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
    PHP Code:
    if ($command =~ /^say\s(.*)/) { $command "say " '"' "$1" '"'; } 
    with
    PHP Code:
    if ($command =~ /^say\s(.*)/) { $command "sayw " '"' "$1" '"'; } 
    And start server with +set consoleName "^6Nanny"
    Last edited by voron00; 27th February 2015 at 16:30.

  6. The Following 3 Users Say Thank You to voron00 For This Useful Post:

    kung foo man (27th February 2015),Ni3ls (27th February 2015),serthy (27th February 2015)

  7. #5
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Such a good bot ! I set it on my server. Working !

  8. #6
    Private feritkkan's Avatar
    Join Date
    Jun 2016
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts
    how run on linux i'm using putty somebody help me ty (note:i am noob at linux)
    /[kick them all/

  9. #7
    Private
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    0
    Thanked 15 Times in 15 Posts
    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#

  10. #8
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    224
    Thanks
    62
    Thanked 189 Times in 100 Posts
    sudo apt-get rekt

  11. #9
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,569
    Thanks
    17
    Thanked 916 Times in 570 Posts
    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
    ...
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

    Sending me a private message makes me want to help you LESS.

  12. #10
    Private
    Join Date
    Jul 2016
    Posts
    26
    Thanks
    0
    Thanked 15 Times in 15 Posts
    Install but Same problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •