1. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

Disabling certain ! commands in test mode

Discussion in 'Modding Help' started by Voxxitronic, Jul 18, 2013.

  1. Voxxitronic

    Voxxitronic It's an adjective Donator

    Messages:
    46
    Hello forum. As you may or may not know, I run the TROUBLE server. Now, it is a less than serious server for sure, and I intend to keep that mentality. For the time being, I want to keep it in test mode for the enjoyment of others. Being test mode, players are given a very large amount of power, and that includes spamming and, in TDM, the power to spawn halls which crashes the server instantly. In TDM, this ALWAYS happens. Warnings will do nothing. I seek a solution to prevent chat spam, and to remove the !hall command from my server. Can anyone help me on either of these?
     
  2. VanHuek

    VanHuek KAG Guard Tester

    Messages:
    751
    I am not sure if removing things from ChatCommands in rules/common scripts works but you could try it, or just delete the halls script if it is TDM?
     
  3. SirLoading

    SirLoading Haxor

    Messages:
    22
    You can make it will load object only if player will not say "!hall" by adding two lines.
    Add this line:
    Code:
    if (text_in != "!hall"){
    here:
    Code:
    bool onServerProcessChat( CRules@ this, const string& in text_in, string& out text_out, CPlayer@ player )
    {
        if (player is null)
            return true;
     
        const bool canSpawn = sv_test || player.isMod();
    // add this line here
    
    And this:
    Code:
    } 
    Here:
    Code:
    // try to spawn an actor with this name !actor
            string name = text_in.substr(1, text_in.size());
     
            if (canSpawn && server_CreateBlob( name, -1, blob.getPosition() ) is null) {
                client_AddToChat( "blob " + text_in + " not found", SColor(255, 255, 0,0));
            }
        }
    // add this line here
        return true;
     
    }
    I hope this will help.
     
    Seanshoots and inactive_account like this.
  4. Voxxitronic

    Voxxitronic It's an adjective Donator

    Messages:
    46
    It probably would if I knew what file I add those lines into. c:
     
  5. AdrianC

    AdrianC Haxor Tester

    Messages:
    119
    Base/Rules/CommonScripts/ChatCommands.as
     
  6. Voxxitronic

    Voxxitronic It's an adjective Donator

    Messages:
    46
    Holy hell, it works! You're a miracle maker. Sorry it took so long for me to implement it. I don't know why I held off on it honestly, there hasn't been a single time i've been away from my server to find it crashed, and restarting it now is a chore because kag2dservers.com takes 5 minutes to do anything now.
     
  7. Seanshoots

    Seanshoots Builder Stabber

    Messages:
    5
    To stop them from spamming the chat you can also do this: (all in ChatCommands.as)

    Under the #include lines, add
    Code:
    int minTimeBetweenInSeconds = 1;
    so it looks something like
    Code:
    #include "MakeSeed.as";
    #include "MakeCrate.as";
    #include "MakeScroll.as";
     
    int minTimeBetweenInSeconds = 1;
    and then find these lines
    Code:
        //spawning things
        CBlob@ blob = player.getBlob();
     
        if (blob is null) {
            return true;
        }
    
    and put this under there
    Code:
    // Check the time since their last message, and see if they should be allowed to send another
        if (blob.exists("message sent"))
        {
            s32 timeDifference = getGameTime() - blob.get_s32("message sent");
            if(timeDifference < (50 * minTimeBetweenInSeconds))
            {
                client_AddToChat( "Please stop spamming", SColor(255, 255, 0,0));
                return false;
            }
            blob.set_s32("message sent", getGameTime());
        }
        else
        {
            blob.set_s32("message sent", getGameTime());
        }
    the whole top part should now look like this
    Code:
    #include "MakeSeed.as";
    #include "MakeCrate.as";
    #include "MakeScroll.as";
     
    int minTimeBetweenInSeconds = 1;
     
    bool onServerProcessChat( CRules@ this, const string& in text_in, string& out text_out, CPlayer@ player )
    {
    if (player is null)
    return true;
     
    const bool canSpawn = sv_test || player.isMod();
     
        if (text_in == "!bot" && player.isMod()) // TODO: whoaaa check seclevs
        {
            CPlayer@ bot = AddBot( "Henry" );
            return true;
        }
     
        //spawning things
        CBlob@ blob = player.getBlob();
     
        if (blob is null) {
            return true;
        }
     
    // Check the time since their last message, and see if they should be allowed to send another
    if (blob.exists("message sent"))
    {
    s32 timeDifference = getGameTime() - blob.get_s32("message sent");
    if(timeDifference < (50 * minTimeBetweenInSeconds))
    {
    client_AddToChat( "Please stop spamming", SColor(255, 255, 0,0));
    return false;
    }
    blob.set_s32("message sent", getGameTime());
    }
    else
    {
    blob.set_s32("message sent", getGameTime());
    }
    I posted the whole file at http://pastebin.com/uBtNmPfH but the indenting became skewed

    I don't think the time in between is actually correct (as in, I don't think 50 ticks is 1 second), but it seems to be quite close. If someone knows a better way, it would be much appreciated :)
     
  8. use getTicksASecond() function:
    if(timeDifference < ( getTicksASecond() * minTimeBetweenInSeconds))
     
    Seanshoots likes this.