Idea Motion Group
လူၾကီးမင္းတြင္ Idea Motion Group မွမွတ္ပံုတင္ျပီးေသာ Member Account ရွိပါက Log In မွ တဆင့္ဝင္ေရာက္ပါ။
New Guest ျဖစ္ပါက Register ျပဳလုပ္၍ဝင္ေရာက္ေပးပို႔ႏိုင္ပါသည္။။
*********Idea Motion Group*********

Join the forum, it's quick and easy

Idea Motion Group
လူၾကီးမင္းတြင္ Idea Motion Group မွမွတ္ပံုတင္ျပီးေသာ Member Account ရွိပါက Log In မွ တဆင့္ဝင္ေရာက္ပါ။
New Guest ျဖစ္ပါက Register ျပဳလုပ္၍ဝင္ေရာက္ေပးပို႔ႏိုင္ပါသည္။။
*********Idea Motion Group*********
Idea Motion Group
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Log in

I forgot my password

Latest topics
» Eternion/Wowwal repack 3.3.5a – TrinityCore
Creating Custom Commands I_icon_minitimeTue Jan 17, 2017 5:58 am by janpara

» SolidWoW BlizzLike 4.0.6-4.3.0 Repack stable UPDATED
Creating Custom Commands I_icon_minitimeThu Apr 10, 2014 5:39 pm by ycabrerag

» JZY’s Trinity Blizzlike Repack 3.35a (updated)
Creating Custom Commands I_icon_minitimeSun Dec 01, 2013 8:38 am by Bottscan

» Hello Everyone Well
Creating Custom Commands I_icon_minitimeThu Jun 27, 2013 12:56 pm by 

» ညီမေလး ဖတ္ဖို႔
Creating Custom Commands I_icon_minitimeThu Jun 13, 2013 6:27 am by 

Country Codes

Timer

Total
  • >

/>

Test

Creating Custom Commands

Go down

Creating Custom Commands Empty Creating Custom Commands

Post   Fri Jul 06, 2012 8:57 am

Maybe you want to make custom commands sometime for your server. Look here and learn:


void onCommand(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
if(Message == "#command") //If player message is #command do followning
{
pPlayer->EventTeleport(MAPID, X, Y, Z);
}
}
void SetupCommand(ScriptMgr * Mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &onCommand); //Register the command
}


Here is the Explanation: (sorry, couldn't write it before, hadn't the time)

This is for the first a C++ script, just compile it to make it work.

void onCommand(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)

this line over here, You declare the void
OnCommand, so you can call this function later in any other function.
This line is much more interesting:

if(Message == "#command")

so If player Message is (==) #command, then we do followning between these two { }

so it should look like this by now

void onCommand(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
if(Message == "#command")
{

Here we can code anything you want the player to do when entering the command. In this case we use an Teleport Event.

pPlayer->EventTeleport(MAPID, X, Y, Z);

MapID = The mapid of the map.
X = the X location.
Y = the Y location.
Z = the Z location.

just type .gps
ingame to get these Coordinates at the spot your standing.

So this far we have declared an function, and if the player says: #command, you get teleported to your location.

But it ain't far from done yet, so we end the IF section with this character:

}

The script should look like this now :

void onCommand(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
if(Message == "#command")
{
pPlayer->EventTeleport(MAPID, X, Y, Z);
}


but now we have to finish the Function by another { letter:

void onCommand(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
if(Message == "#command")
{
pPlayer->EventTeleport(MAPID, X, Y, Z);
}
}

So now we just did a simple function. Now we only
have to Register the function so it works ingame, we do that by another
function:

void SetupCommand(ScriptMgr * Mgr)
{



The server call this function inside the DLL, just to register the #command event.

Now we have to register the command event. Do that by typing this in the SetupCommand function:

mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &onCommand);

Note the white text, this text right here calls our earlier function OnCommand, just by placing character & in front of it.

Now we have done the command event, and soon the SetupCommand event, just by finishing it with this character }

}

Now it should look like this :

void onCommand(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
if(Message == "#command")
{
pPlayer->EventTeleport(MAPID, X, Y, Z);
}
}
void SetupCommand(ScriptMgr * Mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &onCommand);
}


We have just written an .cpp script, hurray!
You just have to compile it to get it ingame. It is a bunch of compiler guides here at mmowned. Here is one of them:

[Only admins are allowed to see this link]


Join date : 1970-01-01

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum