Log in
Most Viewed Topics
Latest topics
2000>
Test
Creating Custom Commands
Page 1 of 1
Creating Custom Commands
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]
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
Similar topics
» Creating Custom Commands
» HowTo: Create custom commands. (Trinity)
» Creating a new vendor
» TrinityCore Commands
» TrinityCore Commands
» HowTo: Create custom commands. (Trinity)
» Creating a new vendor
» TrinityCore Commands
» TrinityCore Commands
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Tue Jan 17, 2017 5:58 am by janpara
» SolidWoW BlizzLike 4.0.6-4.3.0 Repack stable UPDATED
Thu Apr 10, 2014 5:39 pm by ycabrerag
» JZY’s Trinity Blizzlike Repack 3.35a (updated)
Sun Dec 01, 2013 8:38 am by Bottscan
» Hello Everyone Well
Thu Jun 27, 2013 12:56 pm by
» ညီမေလး ဖတ္ဖို႔
Thu Jun 13, 2013 6:27 am by