I Need To Limit the amount of times this can be used ;-;

Discussion in 'Server and Client Scripting' started by pokemon 2000, Jul 26, 2014.

  1. pokemon 2000

    pokemon 2000 Former #1 ranked XY UBERS player

    Joined:
    Jun 7, 2014
    Messages:
    18
    Likes Received:
    0
    PO Trainer Name:
    [Nagato]
    // ATTACK
    // ******** ******** ********

    var vCommand = "-attack";

    // CHECK COMMAND AND DATA

    // ******** ******** ********

    var vCommandData = "";

    var vDataAdded = false;

    // CHECK IF FIRST PART OF MESSAGE MATCHES COMMAND TEST

    if (vCommand == vMessage.substring(0, vCommand.length)){

    // COMMAND WITHOUT DATA

    if (vMessage.length == vCommand.length){

    var vDataAdded = false;

    }

    // COMMAND WITH DATA

    if (vMessage.length > vCommand.length+1){

    var vDataAdded = true;

    vCommandData = vMessageNotCased.substring(vCommand.length+1, vMessageNotCased.length);

    }

    // BUILD MOVE LIST

    // ******** ******** ********

    var vMoveName = [];

    var vMoveNameDone = false;

    for (x=0; vMoveNameDone == false; x++){

    vMoveName[x] = sys.move(x);

    if (vMoveName[x] == undefined){

    vMoveNameDone = true;

    // REMOVE (No Move)

    vMoveName.shift();

    // REMOVE LAST ENTRY undefined

    vMoveName.pop();

    }

    }

    // GENERATE RANDOM MOVE NAMES

    // ******** ******** ********

    var vRNGMove1 = vMoveName[Math.floor((Math.random()*vMoveName.length)+0)];

    var vRNGMove2 = vMoveName[Math.floor((Math.random()*vMoveName.length)+0)];

    var vRNGMove3 = vMoveName[Math.floor((Math.random()*vMoveName.length)+0)];



    // DAMAGE IS CAPED AT 999 IF 1000

    // ******** ******** ********

    var vRNGDamage = Math.floor((Math.random()*1000)+0);



    // BUILD CHANNEL PLAYER NAMES

    // ******** ******** ********

    vChannelPlayerID = client.channel(channel).players();

    // BUILD AND COLLECT NAME ARRAY

    vChannelPlayerName = [];

    for (var x = 0; x < vChannelPlayerID.length; x++){

    vChannelPlayerName[x] = client.name(vChannelPlayerID[x]);

    }

    // STORE A RANDOM CHANNEL USER NAME

    var vRNGName1 = vChannelPlayerName[Math.floor((Math.random()*vChannelPlayerName.length)+0)];



    // DATA INPUT CHECK AND CHANCE TO ATTACK SELF

    // ******** ******** ********

    if (vDataAdded == true){

    // 3 = 33% CHANCE OF HITTING SELF

    vDataInputMissChance = 3;

    var vInputMissValue = Math.floor((Math.random()*vDataInputMissChance)+0);

    if (vInputMissValue == 0){

    vRNGName1 = "themself";

    }

    if (vInputMissValue != 0){

    vRNGName1 = vCommandData;

    }

    }

    if (vDataAdded == false){

    // CHANGE NAME IF SAME USER WHO SENT

    if (vRNGName1 == vUserSent){

    vRNGName1 = "themself";

    }

    }



    // CRTICAL CHANCE + MESSAGE

    // ******** ******** ********

    // 16 IN-GAME DEFAULT OF 1/16 CHANCE

    var vCriticalChance = 16;

    var vRNGCritical = Math.floor((Math.random()*vCriticalChance)+0);

    // CRITICAL

    if (vRNGCritical == 0){

    vRNGDamage = Math.floor(vRNGDamage*1.5);

    client.network().sendChanMessage(channel, "/me " + vUserSent + " attacked " + vRNGName1 + " with " + vRNGMove1 + ", " + vRNGMove2 + " and " + vRNGMove3 + "! CRITICAL HIT! Dealing " + vRNGDamage + " damage! ***");

    }

    // NORMAL DAMAGE

    if (vRNGCritical != 0){

    client.network().sendChanMessage(channel, "/me " + vUserSent + " attacked " + vRNGName1 + " with " + vRNGMove1 + ", " + vRNGMove2 + " and " + vRNGMove3 + "! Dealing " + vRNGDamage + " damage! ***");

    }

    }



    }





    })

    Ok, so i have this script put into my bot and it works perfectly.... only problem is that anyone can endlessly spam the command and it floods the channel ;-;... can someone plz help me with creating a spamblock the disables the bot or even just changes the command name from -attack to --hidden-- after being used 4 times for an amount of time like 4 minutes or something? I appreciate any and all help :].. TY in advance
     
  2. SongSing

    SongSing KILLL

    Joined:
    Jan 2, 2013
    Messages:
    641
    Likes Received:
    191
    PO Trainer Name:
    SongSing
    Just use the timer functions alongside a bool and counter
    Like every time they use the command a counter increases, and if it's above a certain threshhold, the command is ignored
    A timer would reset the counter every x minutes

    The timer could just repeat or activate when someone uses the command and the timer isn't currently running

    If doing something like this would give you trouble, I'd recommend reading up on javascript or just programming logic in general; Don't get someone to do it for you or you wont learn it!
     
  3. pokemon 2000

    pokemon 2000 Former #1 ranked XY UBERS player

    Joined:
    Jun 7, 2014
    Messages:
    18
    Likes Received:
    0
    PO Trainer Name:
    [Nagato]
    I am sry, I never ment to come off like I wanted someone to do it for me. I would actually rather learn myself than to have someone do it for me. I just wouldve liked some ideas and mabey an example script or something to refer to. I know how to set a counter and use timer functions to reset the counter but i dont know how to "ignore" a command.. ik its probably something simple that i skimmed over while reading my JS tutorial. Also I guess i shouldve been more specific in my first post about what i been tryna do and that i didnt want someone to do it for me.. TY for the idea but its pretty much what ive been trying to do and I cant find out how to ignore commands.. lol goin in loops now.. again TY for the idea and i hope i can figure this out
     
  4. SongSing

    SongSing KILLL

    Joined:
    Jan 2, 2013
    Messages:
    641
    Likes Received:
    191
    PO Trainer Name:
    SongSing
    I know you weren't asking or anything, I was just saying that'd be the best way to go about it, on your own (not that you insinuated anything different). "ignoring" a command would just be not executing the code, like using an if statement to check the counter or the bool associated with it and only executing if the counter is below the limit or the bool is true/false (depending on how you're using it)
     
  5. pokemon 2000

    pokemon 2000 Former #1 ranked XY UBERS player

    Joined:
    Jun 7, 2014
    Messages:
    18
    Likes Received:
    0
    PO Trainer Name:
    [Nagato]
    ohh yep, i found a way to add it too the spam blocker i have lol. thanks for the help again SS!! I just added vMessageCounter = vMessageCounter + 1 at the part where it displays the text and added an if/else if in front of the whole script^^ u led me to the answer by explaining about not actually ignoring the command but simply not executing it lol TY for helping yet again!
     
  6. SongSing

    SongSing KILLL

    Joined:
    Jan 2, 2013
    Messages:
    641
    Likes Received:
    191
    PO Trainer Name:
    SongSing
    Alright, I'm glad you got it! :)