Greetings AC Web. I havent seen any tutorials about this so I figured that I will make one for you.This will be my first tutorial ever made so if its too hard to read or understand please tell me about it so I can modify this thread, and/or take your tips with me to my next tutorial.If you have any problems with this script you could ask for my help, but I wont help you set it up over TeamViewer or something like that.If you would like to take this script to the next level (creating other commands that is not in this thread) and you get stuck somewhere, or don't know what to do or how to make it, feel free to ask for my help.

Note: you cannot make custom commands on trinity if you are using a repack.

[C++] HowTo: Create custom commands. (Trinity)

First we want to create a new c++ file.If you don't know how to do this, the easiest way to do this is to;1. Open up notepad.2. Click file -> Save as.3. Change filetype from .txt to All files4. Type in the script's name in the box above. We will use (test_command.cpp) for this tutorial.

You can save this wherever you want, but in the end of the day it needs to be inside your source folder. (Mine's C:/Trinity)Save the file to X:/YourSourceFolder/src/server/scripts/Custom. I will save mine to C:/Trinity/src/server/scripts/Custom.Your new cpp file should be placed inside X:/YourSourceFolder/src/server/scripts/Custom

Now, open up the program you compile with, I use Microsoft Visual C++ 2010 Express.On the left, it should look something similar to this:[Only admins are allowed to see this image]

Now, open up scripts, right click on Source Files->Add and click Existing Item like this:[Only admins are allowed to see this image]

Now you should be able to locate the script you just made.- Go into your build folder (C:/Trinity/src/server/scripts/Custom- Select the .cpp file you made (test_command.cpp) and click the Add button.

The empty .cpp file you made should now be added to your program, inside scripts.Find the file, and double click it or whatever to open it inside your program.

First of all we would like to start with includes. You might not need all of these, but we will add them anyway.On the top line of your .cpp file add this:

Code: class test_commandscript : public CommandScript{public: test_commandscript() : CommandScript("test_commandscript") { }After that's done, we want to create our commands, but first of all we want to insert this:

So right now, we have created a command called "test", with a subcommand called "command".If you write .test while you are ingame you will get a list of the subcommands.If you write .test command - it would actually make your character do the command.

Code: SEC_PLAYER = 0, SEC_MODERATOR = 1, SEC_GAMEMASTER = 2, SEC_ADMINISTRATOR = 3, SEC_CONSOLE = 4The "&HandleTestCommand" will be the handler of each subcommand, and will be linked to the command's script that we will write later.The handlers needs to be unique and different from each subcommand, or else every command you make would have the same effect.

We have now created our test command. If you type .test command while you are ingame after compiling your character would say: test command?Note: You will not be able to compile the script into your server before you add the script to Scriptloader.cpp, but before we do that we will create simple teleport command into our test command.

void AddSC_test_commandscript(){ new test_commandscript();}Now, if you type .test gurubashi while you are ingame, it will teleport you to gurubashi if you're not in combat.If you are in combat and you do the command, you will not be teleported and you will get a message telling you that you're in combat.

Now we can add our script to Scriptloader.cppAt this time you remember where you opened your script inside your program.Minimize "scripts" over to the left in your program, as you wont need to have it open now.It should now look something like this (again):[Only admins are allowed to see this image]

Now open up your "game" and Source Files and look for ScriptLoader.cppAfter you have found your ScriptLoader.cpp, open it and scroll all the way to the bottom.It should look like this, if you haven't added any custom scripts to your server before.

Code: #ifdef SCRIPTS/* This is where custom scripts' loading functions should be declared. */

#endif

void AddCustomScripts(){#ifdef SCRIPTS /* This is where custom scripts should be added. */

#endif}As we used this in our script:

Code: void AddSC_test_commandscript(){ new test_commandscript();}That's what we want to use in ScriptLoader.cpp so our script gets added to the server.

Modify the ScriptLoader.cpp so it looks like this;

Code: #ifdef SCRIPTS/* This is where custom scripts' loading functions should be declared. */ void AddSC_test_commandscript();#endif

void AddCustomScripts(){#ifdef SCRIPTS /* This is where custom scripts should be added. */ AddSC_test_commandscript();#endif}When you're done with that, save ScriptLoader.cpp and save your test_command.cpp.You can now start the compile.

When the compile is complete it should say something like this:

Code: ------ Build started: Project: ALL_BUILD, Configuration: Release Win32 ------ Build all projects========== Build: 6 succeeded, 0 failed, 8 up-to-date, 0 skipped ==========If you are running the server from the build folder and worldserver.exe is up and running when you compile, the compile wont be successful.Close worldserver.exe and re-compile.

If you get any errors on the compile while your worldserver.exe is shut down, you might want to read the tutorial again and check if you missed something.The script should work on latest rev of Trinity, but feel free to test it.

Open up worldserver.exe, login and write .test [Only admins are allowed to see this image]Enjoy!

Here is a pastebin of the script we have just made: [Only admins are allowed to see this link]

Bottom line; I hope this tutorial was helpful. Please don't repost this and give yourself credits for it.

I might create and release a copy of Arena-Tournament (Abyssal WoW)'s player commands if you guys want me to. (Changefaction, customize, changerace, etc)