Author Topic: So, I cannot get slash cmds to work.  (Read 1052 times)

Code: [Select]
function MessageHud_Edit::eval(%this)
{
   %text = trim(%this.getValue());
   %subcmd = getWords(%text, 1, 50);
   if(%text !$= "")
   {
          if(%subcmd $= "/")
     {
    commandtoserver("'" @ %subcmd @ "'");
  }
      else if(MessageHud.isTeamMsg)
         commandToServer('teamMessageSent', %text);
      else if(%text !$= %subcmd)
              {
         commandToServer('messageSent', %text);
       }
}
   MessageHud.close();
}

I can't see why it won't work.  I had it working on another game before.  :|

Code: [Select]
function MessageHud_Edit::eval(%this)
{
   %text = trim(%this.getValue());
   %subcmd = getWords(%text, 1, 50);
   if(%text !$= "")
   {
          if(%subcmd $= "/")
     {
    commandtoserver("'" SPC %subcmd SPC "'");
  }
      else if(MessageHud.isTeamMsg)
         commandToServer('teamMessageSent', %text);
      else if(%text !$= %subcmd)
              {
         commandToServer('messageSent', %text);
       }
}
   MessageHud.close();
}

I can't see why it won't work.  I had it working on another game before.  :|

Oop's, I thought that was the edit button.  But there is none.   :panda:

well, if you want a function to be able to be used as a slash command, do this:
Code: [Select]
function serverCmdSlashCommand (%client, %arg) {
//do what you want the slash command to do here
}
Change the SlashCommand part to set the name of the command, I.E. serverCmdShoopDaWhoop would make the slash command /shoopdawhoop .
And, %client has stuff about the person who uses it (for admin-based checks, usually) and, keep in mind, it's not too easy to program multiple args in a slash command.

The args can be anything but %client is most common.