[TUTORIAL] How to add a command

Results 1 to 2 of 2
  1. #1
    Novice Kizeko is offline
    MemberRank
    Mar 2018 Join Date
    2Posts

    config [TUTORIAL] How to add a command

    EDIT :In this tutorial we create an admin command so thats why i chose PcCommandHandler.java. You could choose an other file, or create new one depending on what type of command you want to add.
    If you guys want a tutorial on how to manage command permissions, create a new file for player command etc... pm me :p




    Hey, welcome to this little tutorial, today i'll be showing you how to add a command to the game since we cannot do this via properties file, some of you might not know how to do this if you don't have the basics of Java :

    I'm using the 661 client/server for this tutorial, it might be the same method as 491 client/server.

    661 client/server :
    http://forum.ragezone.com/f1000/661-wip-server-files-source-1149004/

    1) Open "PcComandHandler.java" Location :
    com.bdoemu.gameserver.scripts.commands



    At the top of the file, you can see this. Basically we're adding to a StringBuilder multiple strings, this is what you'll receive when you'll type "/pc" in game.

    In this tutorial we'll do a "addfailstacks" command.


    2) Add your command to the string builder

    We'll add our command to the string builder, so when the admin type "/pc" he will see our command being sent to him.



    3) Creating the command

    Scroll down and let's create our command!



    Lets begin by entering the method name and the parameters of this method:



    So basically we'll have to add a a number of failstacks that the player will choose, try catch the possible errors, add the failstacks and send a packet to the player so that the failstacks are being shown in the enhancement window.



    First, we parse the string to an integer, in the same time we check if its integer and then we make sure that there is only 1 argument after the name of the command Ex : "/pc addfailstacks 30"




    We make sure that the failstack is over 0 to prevent issues.



    Finally, we set the failstack to his current failstack + the chosen failstack. Then we send a packet to the player so that the enhancement window shows the correct number.



    So the code should look like this now, you'll have to decompile the code and update it to the server, i hope you enjoyed this tutorial, if i made a mistake, just tell it to me :)
    Last edited by Kizeko; 29-05-18 at 06:55 PM.


  2. #2
    Novice pollo1 is offline
    MemberRank
    Apr 2020 Join Date
    4Posts

    Re: [TUTORIAL] How to add a command

    Not Found for Me
    or you can add the code to be able to copy it please?

    Edite: I already solved it, thanks. by the way, the code is wrong.
    Last edited by pollo1; 30-11-20 at 01:42 PM.



Advertisement