Results 1 to 10 of 21

Thread: [Perl] [COD2] Nanny

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 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

  2. #2
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 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 15:30.

  3. 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)

  4. #3
    Private
    Join Date
    Jul 2016
    Posts
    38
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Quote Originally Posted by voron00 View Post
    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"
    PHP Code:
    ******* script compile error *******
    bad syntax: (file 'maps/mp/gametypes/_callbacksetup.gsc'line 151)
                
    sendGameServerCommand(-1"h "" + level.consoleName + "^7" + message + """);
                                              *
    ************************************
    Sys_ErrorError during initialization:
    script compile error
    (see console for details)

    > [
    PLUGIN UNLOADED]: 

Posting Permissions

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