[TrinityCore] How To Add A Custom Script To Your Core

OMGhixD

Gold Supporter
Epic Member
522
2014
58
NOTICE! THIS TUTORIAL IS OLD. BUT STILL WORKS

[TrinityCore] How To Add A Custom Script To Your Core
I know its already out there but, i made this a while back and thought it wanted to release it
Hello!

Today Im Here To Show You How To Add A Custom C++ Script To Your Core,

NOTICE: THIS ONLY WORKS FOR TRINITYCORE AND TRINITY BASED CORES!

Step 1: Getting The Script!

''By Getting The Script I Mean Either Copy Paste The Script Content Into *EXAMPLE* Microsoft Ultimate 2012
By Saving The Script As A .cpp File *ÊXAMPLE* NewCustomScript.cpp''

Step 2: Applying It To The Build.

''By Applying It To The Build, I Simply Mean Put It In The Custom Script Folder! -> source/src/server/scripts/custom
Now Thats Where You Place The .cpp File Into, Now You Need To Open Cmakelist.txt And Add The File Name Between Theese Two Column's As Id Like To Call Them!
*EXAMPLE*


Code:
set(scripts_STAT_SRCS
${scripts_STAT_SRCS}
Custom/NewCustomScript.cpp
)
EXAMPLE*

Now Save And Your Done With That Part!

Step 3: Adding It To The Scriptloader.cpp

Now There Is ALOT OF WAYS TO DO THIS, But The Best Way (From Own Opinion Is Cmaking it, Then Open The Trinitycore.sln And Go To The Scriptloader From There, Scriptloader Location -> Game -> Source Then Just Scroll Until You See Scriptloader.cpp

Scroll Down Until You See Something Like 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
}
And Find The Content That Looks Like This In Your Custom Script At The Bottom!

Code:
void AddSC_Example()
{
new Example;
}
I Just Used Example, But On Your Script There Would Be Something Else! :)

After That. Copy The '' void AddSC_Example() '' Part!
NOW! That Uve Copied That, You Simply Want To Add It To The Scriptloader.cpp *EXAMPLE UNDER*

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! '' void '' Wil Only Stay On The #ifdef SCRIPTS part!

ALSO REMEMBER THAT YOU NEED TO ADD ; Behind ()

Thats How It Wil Look In The End! Now Hit The Save Button. AND COMPILE!

Thanks For Reading!

As always HAVE A NICE DAY!
OMGhixD!
 
  • Like
Reactions: ExO

RNSKS

Verified Member
24
2019
0
Thanks I have all these custom scripts that I never knew how to implement now I do lol thanks <3
 
Top