Jump to content

GM Commands


Guest bobbster1091

Recommended Posts

I was looking at the Chat.cpp and the levelX.cpp files and I was trying to figure out how to make a GM command.

I wanted to make a command called .restore to restore your health to 100%.

I wanted to learn how to make my own, not just post in the "What GM commands you would like to see" thread, so if anyone could just point me in the right direction, that would be awesome.

Link to comment
Share on other sites

making gm-commands is pretty easy, cause you can look at already existing ones and steal their code ;)

add to chat.cpp a line:

{ "restore", SEC_PLAYER, false, &ChatHandler::HandleRestoreCommand, "", NULL },

.restore can now be used with security-level player false means can't be executed in console

and the &Chathandler:handle.. is our functionname

add to chat.h a line

bool HandleRestoreCommand(const char* args);

ok now i'm not very sure, i think Level#Number.cpp is for every security level

so #Number=0 is for sec_player

#Numer=1 moderator

and 2=admin

if my assumption is right, add to

Level0.cpp

bool ChatHandler::HandleRestoreCommand(const char* args)

{

Player* pl = m_session->GetPlayer();

if(pl)

pl->setHealth(pl->getmaxhealth());

}

now you should look at other commands how they get the variables and how they handle it

so you have m_session with which you can get the player who is executing the command and also it's possible to parse some args (like .restore 10 - that you can read the 10 from the command) but this is again something you need to cheat from other commands

if you want to create an errormessage, i think you have to add your errormessage-id to language.h and add an entry in the language-table

if you want documentation about your command add an entry in the commands table

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use