Likes: 0
Results 1 to 5 of 5
Thread: Understanding Custom Commands
-
02-09-08, 02:05 AM #1
Understanding Custom Commands
Register to remove this adCustom Commands are quite tricky to understand, and also difficult to make if you do not know what your doing. We're going to be using a command "#rezz" Author: Dark Alex.
First, just take a look through his script, study it.
Code://--------------------- // Name: Playercommands // Author: Darkalex //--------------------- #include "StdAfx.h" #include "Setup.h" static string rezzcmd = "#rezz"; //Revive Player-command bool rezzon = true; //Will be switchable later ingame via GMCommand void EventPlayerCommands(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc) { //#rezz-Command - Start if(Message == rezzcmd) { if(rezzon) if( rezzon ) { //You can add parameters where reviing is enabled here. e.g. for allowing it only on kalimdor and in Zone 123: (pPlayer->GetMapId() == 1 || pPlayer->GetZoneId() == 123) if (pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE)>=7500) //Will cost 75 Silver (check if enough money) { pPlayer->SetUInt32Value(PLAYER_FIELD_COINAGE,(pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE) - 7500)); //Here 75 Silver is removed sEventMgr.AddEvent(pPlayer, &Player::RemoteRevive, EVENT_PLAYER_REST, 1, 1,0); } else pPlayer->BroadcastMessage("You don't have 75 silver in your backpack."); } else pPlayer->BroadcastMessage("You can't revive here!"); else pPlayer->BroadcastMessage("You can't revive here!."); } //#rezz-Command end. } void SetupPlayerCommands(ScriptMgr * mgr) { mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, (void *) EventPlayerCommands); }
#include "StdAfx.h"
#include "Setup.h"
static string rezzcmd = "#rezz";
bool rezzon = true;
Now You see "#rezz"?? Thats what you type into game. Yes! Sure the scripting is difficult but easy for the players!
Dont need to mess around with true and false there, but say if you wanted to make a command that will enable you to use a command whilst in combat you can type something like Bypasscombat = false will make it so you cant use the command in combat, but placing false with true will make it so you can use it.
void EventPlayerCommands(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
Now this part is everything you need to include for your script (Cant really explain it) But if you didnt want to explain anything You could write void EventPlayerCommands() the () is where you can place thing's like uint32 pPlayer etc.
if(Message == rezzcmd)
{
if(rezzon)
if( rezzon ) {
if (pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE)>=7500
{
Player->SetUInt32Value(PLAYER_FIELD_COINAGE,(pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE) - 7500));
sEventMgr.AddEvent(pPlayer, &Player::RemoteRevive, EVENT_PLAYER_REST, 1, 1,0);
} else pPlayer->BroadcastMessage("You don't have 75 silver in your backpack.");
Your probably thinking wow... I don't understand a word of this.. But it's actually quite simple.
Just ignore this part:
if(Message == rezzcmd)
{
if(rezzon)
if( rezzon ) {
You may add parameters if you wish, but if your a begginer just keep it simple!
if (pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE)>=7500
{
Player->SetUInt32Value(PLAYER_FIELD_COINAGE,(pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE) - 7500));
Now what this part does is tells the system to take 75 silver from your backpack, and throw it into mid-air! Well it just pays for your rezzing cost.
sEventMgr.AddEvent(pPlayer, &Player::RemoteRevive, EVENT_PLAYER_REST, 1, 1,0);
} else pPlayer->BroadcastMessage("You don't have 75 silver in your backpack.");
Oh NO! You don't have 75 silver in your backpack! Now you can't use your command.. That's pretty much what all that garbage does if you didnt have this it would take 75 silver regardless of you having enough money and the command would work!
} else
pPlayer->BroadcastMessage("You can't revive here!");
else
pPlayer->BroadcastMessage("You can't revive here!.");
}
}
This should be pretty simple to understand "You can't revive here!"
And the ending of the script..
void SetupPlayerCommands(ScriptMgr * mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, (void *) EventPlayerCommands);
}
Now.. Where it has PlayerCommands in the script change that to what ever you like! the SERVER_HOOK_EVENT_ON_CHAT will find the "#rezz" command and when you type this in game it will say.. hey that player just said #rezz to me.. I know what to do.. Ill rezz him at no cost to myself but charge him 75 silver !! MWahaaaaa
Now thats all! Post any questions/feedback you have!
› See More: Understanding Custom CommandsLast edited by Crux; 02-09-08 at 02:08 AM.
-
02-09-08, 07:26 AM #2
That's so nice, very usefull for many people. Cus! it is VERY hard to make custom abilities without High-Script Knowledge.
Synth's Scripting
If u need somekind of help scripting? ask me! i'll gladly make u and simple script for free. These script lang's i know. C++ Blua Lua
-
02-09-08, 07:45 AM #3
Thanks for the share.
-
02-09-08, 01:26 PM #4
-
02-09-08, 11:57 PM #5
Register to remove this adThanks for feedback.
EDIT: You may post this guide on any forums as you wish, but don't forget the credits
Last edited by Crux; 03-09-08 at 12:02 AM.