How to add a C++ Script to your core menu

User Tag List

Results 1 to 2 of 2
  1. #1
    jameyboor's Avatar Private
    Reputation
    6
    Join Date
    Aug 2011
    Posts
    8
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to add a C++ Script to your core


    Hello all,

    this is a tutorial on how to add a custom C++ script to your Trinity core.

    I know there are more of these only some are not very clear.

    lets start:


    How to add a C++ script to your server?:


    1. You NEED a self-compiled server, so NOT a repack.

    2. Open up your Microsoft Visual Studio , hit Ctrl+N then a screen will pop-up, click on Visual C++ and click on C++ file.cpp

    3. paste the whole code in the new text box and save it as your desired name.cpp and place it in your C:/Trinity/src/server/scripts/Custom folder.

    4. open up C:/Trinity/src/server/scripts/Custom/Cmakelists.txt

    5. you will see some copyright text, scroll down to you find this:
    Code:
    set(scripts_STAT_SRCS
      ${scripts_STAT_SRCS}
    )
    do like this Custom/yourscriptname.cpp
    so example:
    Code:
    set(scripts_STAT_SRCS
      ${scripts_STAT_SRCS}
    Custom/lol.cpp
    )
    then save that

    6. Go to your build folder Default C:/Build.

    7. Open the TrinityCore.sln file with the type: Microsoft Visual Studio Solution

    8. on the left of the screen you should have a solution explorer, if not then hit CTRL+ Alt + L

    9. open up the project "game" in your solution explorer by clicking on the arrow left to the "game" project.

    10. click on the arrow that says "Source files" and scroll down until you see Scriptloader.cpp

    11. open the file Scriptloader.cpp, scroll all the way down until you see this:
    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
    }
    12. Find the code of your script and scroll all the way down until you see something like this:
    Code:
    void AddSC_Example()
    {
    	new Example;
    }
    I used example but at your code there can be other text ofcourse.

    13. Copy the void AddSC_Example() then go back to your Scriploader.cpp file and paste that, so that it will look like this :
    Code:
    #ifdef SCRIPTS
    /* This is where custom scripts' loading functions should be declared. */
    void AddSC_Example();
    #endif
    
    void AddCustomScripts()
    {
    #ifdef SCRIPTS
        /* This is where custom scripts should be added. */
    AddSC_Example();
    #endif
    }
    Remember to add the ; at the end to both and remove the void at the second.

    14. Go back to your Solution Explorer and search the project "scripts", then click on the arrow left from the project.

    15. Right-click on the Source files folder and click on Add->Existing Item.

    16. You will see a window popping up that will ask where your .cpp file is, we already saved it in a folder so lets go and open that folder.
    Go to C:/Trinity/src/server/scripts/Custom and double-click on your .cpp file to add it.

    17. Recompile and your done, Congratulations!


    How to recompile?

    Alot of people don't know what the word "recompiling" means in the beginning, the meaning of this word is just the re-making (building) of your server, how to do this?
    1. on the top of your screen you will see a green triangle and a dropdown- menu on the side of it.
    2. Make sure that the dropdown-menu is set to Release and set to the right Bit version, according to your Computer (32/64 bit)
    3. Click on the green triangle, a box will pop-up asking you to build some projects, click on "yes" and the recompiling will start, Congratulations!


    This part is only for adding a script to an areatrigger/creature/gameobject/instance/item, if your script is not about any of these categories then you are done.

    If you want to add a areatrigger/creature/gameobject/instance/item
    then you have to do one more thing, I will show you in a few steps.


    1. Open up your Database and open up the catergory table of what you want to add like : creature_template for creatures.

    2. Make or edit an existing areatrigger/creature/gameobject/instance/item

    3. Go to the column named "ScriptName".

    4. Go to your script, and search something like this ( used Faded's teleporter (a creature)) :
    Code:
    class tc_teleporter : public CreatureScript
    {
    	public:
    		tc_teleporter()
    			: CreatureScript("tc_teleporter")
    			{}
    5. When you have that then you will need
    Code:
    : CreatureScript("tc_teleporter")
    6. Go back to your Database and Write in ScriptName, the part i wrote in red:

    Code:
    : CreatureScript("tc_teleporter")
    7. You are done now, you may need to restart your server or reload your areatrigger/creature/gameobject/instance/item.

    Note: I took a teleporter script so that why its : tc_teleporter, ofcourse there can be something else in your script.

    Remember that you can always ask me questions if you need help with this, just leave a post

    I am always in for commentary just remember = flamers and trollers will get reported.

    How to add a C++ Script to your core
  2. #2
    Harambeqt's Avatar Elite User CoreCoins Purchaser
    Reputation
    333
    Join Date
    Mar 2010
    Posts
    1,206
    Thanks G/R
    9/29
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    +r Thanks for taking your time writing the guide.
    Last edited by Harambeqt; 01-19-2013 at 06:04 AM.
    Support the #1 WoW Emulator:
    http://arcemu.org/
    https://github.com/arcemu/arcemu
    - - -

Similar Threads

  1. [Trinity] How to add a custom script to your TrinityCore
    By turtleswin in forum WoW EMU Guides & Tutorials
    Replies: 1
    Last Post: 12-20-2012, 02:08 AM
  2. [Guide] How to easily add a C++ script to your server
    By 2dgreengiant in forum WoW EMU Guides & Tutorials
    Replies: 2
    Last Post: 06-05-2009, 12:08 AM
  3. [Question] Add an Lua Script to your Server from a different Computer?
    By kevinno in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 05-25-2008, 05:25 PM
  4. How to add a vote popup to your emu website!
    By Kael'Thas in forum WoW EMU Guides & Tutorials
    Replies: 44
    Last Post: 05-21-2008, 03:56 PM
  5. How To Add A New Database To Your Server!
    By Linkin.Park. in forum WoW EMU Guides & Tutorials
    Replies: 2
    Last Post: 03-10-2008, 02:38 PM
All times are GMT -5. The time now is 10:35 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search