FAQ  •  Register  •  Login

Adding Server-Side Commands

Forum rules
This forum is for technical discussion only. If you are interested in gameplay or client-side issues, please post in Bitfighter Features.
<<

CrazyLinuxNerd

User avatar

Posts: 40

Joined: Mon Feb 07, 2011 4:43 pm

Location: England

Post Fri Feb 25, 2011 2:32 pm

Adding Server-Side Commands

Warning: This post may contain nerdy or geeky talk, you have been warned!

Hi,

Well I'm a little confused at the moment!

I am in a crazed attempt trying to add an extra command to bitfighter, it looked fairly easy when I started.. But I was wrong, oh so wrong!

I figured to add my command for testing purposes, to simply print text (hello world!) all I would need to modify was these files:

  • UIGame.cpp
  • UIGame.h
  • gameType.cpp

This semi works. BUT. Only when I also add the command to the client as-well does it work.

Older clients cannot use the new command I figured this is where gameType.cpp stepped in and forwarded stuff

(for example old clients, don't got /addbot, but yet can use it)

But I appear to have been wrong, oh so wrong.

I gathered what I needed to modify by various google code changelogs. But I seem to be missing something!

So I am here to ask you.. what have I done wrong? :-D. Modified code can be found below :-).

UIGame.cpp: Line 1660
  Code:
{ "mycommand",                  GameUserInterface::mycommandHandler,                  { INT },     1,    ADMIN_COMMANDS, 1, {"<value>"},              "Test command. Reissue to disable." },


UIGame.h: Line 330
  Code:
 static void mycommandHandler(GameUserInterface *gui, const Vector<string> &words);


gameType.cpp: Lines 2853 through 2866
  Code:
  else if(!stricmp(cmd, "mycommand"))
   {
      if(!clientRef->clientConnection->isAdmin())  
         clientRef->clientConnection->s2cDisplayMessage(GameConnection::ColorRed, SFXNone, "!!! You don't have permission to");
      else
      {
          clientRef->clientConnection->s2cDisplayMessage(GameConnection::ColorRed, SFXNone, "!!! Hello World !!!");
      }
   }
   else
   {
      // Command not found, tell the client
      clientRef->clientConnection->s2cDisplayMessage(GameConnection::ColorRed, SFXNone, "!!! Invalid Command");
   }


So, my question is quite simple. What am I missing? :-D

PS: I'm not a pro c++ programmer in anyway what-so-ever I'm kinda making it up as I go along and seeing if it compiles lmao.
<<

watusimoto

Site Admin

Posts: 1558

Joined: Tue Feb 23, 2010 7:07 pm

Location: Quartz's mom's house

Post Sat Feb 26, 2011 10:06 pm

Re: Adding Server-Side Commands

Download the latest source (what you have may be good enough), and follow the model of "gmute".
<<

CrazyLinuxNerd

User avatar

Posts: 40

Joined: Mon Feb 07, 2011 4:43 pm

Location: England

Post Sun Feb 27, 2011 3:12 pm

Re: Adding Server-Side Commands

watusimoto wrote:Download the latest source (what you have may be good enough), and follow the model of "gmute".
Thanks. Looking through gmute I figured out where I went wrong :-). Seems to have 'just worked' without actually using UIGame bits :-).

Thanks again :-).

Return to Technical Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron