Author Topic: How'd they make the #commands not show up in the chat menu?  (Read 8866 times)

0 Members and 1 Guest are viewing this topic.

bigbigger9

  • Gnoll Fighter
  • **
  • Posts: 73
  • Reputation: +0/-0
How'd they make the #commands not show up in the chat menu?
« on: September 18, 2003 06:11 pm CDT »
My long title pretty much says it all, How'd they make the #commands not show up in the chat menu?

Hope you can fill me in on this neat trick.
« Last Edit: December 31, 1969 06:00 pm CST by bigbigger9 »
~bigbigger9

Hersh

  • Elvin Legion
  • *****
  • Posts: 413
  • Reputation: +0/-0
(No subject)
« Reply #1 on: September 18, 2003 06:52 pm CDT »
I'm geussing it has a lot to do with this. (From comchat.cs)

Code: [Select]
if(String::getSubStr(%message, 0, 1) == "#")
%isCommand = True;
So every time someone says something with # at the begining it calls it a Command.

Code: [Select]
%w1 = GetWord(%message, 0);
%cropped = String::NEWgetSubStr(%message, (String::len(%w1)+1), 99999);

if(%isCommand)
{
if(%w1 == "#Whatever")
{
                        Do Something
                                }
                }



The first part is just finding the key words.
But if(%isCommand) goes back up to the other code, where it starts with #. Well, typing in one of the words that equal %w1 will do "whatever" They won't return to the chat box. (They do whats in the if.) Searching for and finding the # on the beginning stops it from being normal chat.

Hersh
« Last Edit: December 31, 1969 06:00 pm CST by Hersh »

I kissed a drunk girl on the lips.
This post, by its very length, defends itself against the risk of being read.

bigbigger9

  • Gnoll Fighter
  • **
  • Posts: 73
  • Reputation: +0/-0
(No subject)
« Reply #2 on: September 18, 2003 07:21 pm CDT »
Yea, but how did they get it so it doesn't show up in the chat window?

Edit: Erm, just need further explaination.
« Last Edit: December 31, 1969 06:00 pm CST by bigbigger9 »
~bigbigger9

UnderGod

  • Centurian Lord
  • ********
  • Posts: 2,691
  • Reputation: +0/-0
(No subject)
« Reply #3 on: September 18, 2003 07:35 pm CDT »
If you look in the remotesay function in comchat.cs it explains everything. If the message contains "#" at the beginning, %iscommand = True. In the function it basicly says to overide the rest of the chat function if %iscommand = True. If %iscommand = True, it checks the list of commands for what to do. If it isn't in the list of commands, then it just returns false doing nothing at all.
« Last Edit: December 31, 1969 06:00 pm CST by UnderGod »
"The right man in the wrong place can make all the difference in the world"

Dragoon

  • Gnoll Fighter
  • **
  • Posts: 52
  • Reputation: +0/-0
(No subject)
« Reply #4 on: September 18, 2003 07:54 pm CDT »
actually, it's the return;

if you run a command through, and then you put return; before the command is over, it won't show up in the chat window.

Code: [Select]
if(%w1 == "#news")
{
Client::sendMessage(%TrueClientId, 3, $Server::NewsOfTheDay);
return;
}


that would show up in only the client's chat window of the client who called for the news, because the return stops the message from going anywhere else.
« Last Edit: December 31, 1969 06:00 pm CST by Dragoon »
I r Dragoon.

UnderGod

  • Centurian Lord
  • ********
  • Posts: 2,691
  • Reputation: +0/-0
(No subject)
« Reply #5 on: September 18, 2003 07:57 pm CDT »
That is almost exactly what I said.
« Last Edit: December 31, 1969 06:00 pm CST by UnderGod »
"The right man in the wrong place can make all the difference in the world"

Dragoon

  • Gnoll Fighter
  • **
  • Posts: 52
  • Reputation: +0/-0
(No subject)
« Reply #6 on: September 18, 2003 08:00 pm CDT »
don't write things out when visuals make it easier to see.
« Last Edit: December 31, 1969 06:00 pm CST by Dragoon »
I r Dragoon.

UnderGod

  • Centurian Lord
  • ********
  • Posts: 2,691
  • Reputation: +0/-0
(No subject)
« Reply #7 on: September 18, 2003 08:02 pm CDT »
He asked for explaination =)
« Last Edit: December 31, 1969 06:00 pm CST by UnderGod »
"The right man in the wrong place can make all the difference in the world"

bigbigger9

  • Gnoll Fighter
  • **
  • Posts: 73
  • Reputation: +0/-0
(No subject)
« Reply #8 on: September 18, 2003 08:13 pm CDT »
heh, Undergod helped more. :P)

Thanks in advance. :)
« Last Edit: December 31, 1969 06:00 pm CST by bigbigger9 »
~bigbigger9

Silvanoshei

  • Centurian Lord
  • ********
  • Posts: 1,804
  • Reputation: +0/-0
(No subject)
« Reply #9 on: September 18, 2003 08:19 pm CDT »
Out of curiosity, um... Why?
« Last Edit: December 31, 1969 06:00 pm CST by Silvanoshei »

The DoDoDo.

Your opinion is worthless unless you can support it.
We are not responsible for your stupidity.
I don't take sides. I take action.

Currently Playing:  Warcraft III [PC]

UnderGod

  • Centurian Lord
  • ********
  • Posts: 2,691
  • Reputation: +0/-0
(No subject)
« Reply #10 on: September 18, 2003 08:23 pm CDT »
Post the entire remotesay function from base tribes, adn i'll show you
« Last Edit: December 31, 1969 06:00 pm CST by UnderGod »
"The right man in the wrong place can make all the difference in the world"

Hersh

  • Elvin Legion
  • *****
  • Posts: 413
  • Reputation: +0/-0
(No subject)
« Reply #11 on: September 18, 2003 10:12 pm CDT »
99% sure its base, and either way, its not RPG.

Hersh
Code: [Select]

function remoteSay(%clientId, %team, %message)
{
   %msg = %clientId @ " \"" @ escapeString(%message) @ "\"";

   // check for flooding if it's a broadcast OR if it's team in FFA
   if($Server::FloodProtectionEnabled && (!$Server::TourneyMode || !%team))
   {
      // we use getIntTime here because getSimTime gets reset.
      // time is measured in 32 ms chunks... so approx 32 to the sec
      %time = getIntegerTime(true) >> 5;
      if(%clientId.floodMute)
      {
         %delta = %clientId.muteDoneTime - %time;
         if(%delta > 0)
         {
            Client::sendMessage(%clientId, $MSGTypeGame, "FLOOD! You cannot talk for " @ %delta @ " seconds.");
            return;
         }
         %clientId.floodMute = "";
         %clientId.muteDoneTime = "";
      }
      %clientId.floodMessageCount++;
      // funky use of schedule here:
      schedule(%clientId @ ".floodMessageCount--;", 5, %clientId);
      if(%clientId.floodMessageCount > 4)
      {
         %clientId.floodMute = true;
         %clientId.muteDoneTime = %time + 10;
         Client::sendMessage(%clientId, $MSGTypeGame, "FLOOD! You cannot talk for 10 seconds.");
         return;
      }
   }

   if(%team)
   {
      if($dedicated)
         echo("SAYTEAM: " @ %msg);
      %team = Client::getTeam(%clientId);
      for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
         if(Client::getTeam(%cl) == %team && !%cl.muted[%clientId])
            Client::sendMessage(%cl, $MsgTypeTeamChat, %message, %clientId);
   }
   else
   {
      if($dedicated)
         echo("SAY: " @ %msg);
      for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
         if(!%cl.muted[%clientId])
            Client::sendMessage(%cl, $MsgTypeChat, %message, %clientId);
   }
}
« Last Edit: December 31, 1969 06:00 pm CST by Hersh »

I kissed a drunk girl on the lips.
This post, by its very length, defends itself against the risk of being read.

UnderGod

  • Centurian Lord
  • ********
  • Posts: 2,691
  • Reputation: +0/-0
(No subject)
« Reply #12 on: September 18, 2003 11:25 pm CDT »
Ok... First off we are going to need a character to start the command.. TRPG uses #. We will use ! for this purpose.

Code: [Select]
function remoteSay(%clientId, %team, %message)
{
   %msg = %clientId @ " \"" @ escapeString(%message) @ "\"";

   // check for flooding if it's a broadcast OR if it's team in FFA
   if($Server::FloodProtectionEnabled && (!$Server::TourneyMode || !%team))
   {
      // we use getIntTime here because getSimTime gets reset.
      // time is measured in 32 ms chunks... so approx 32 to the sec
      %time = getIntegerTime(true) >> 5;
      if(%clientId.floodMute)
      {
         %delta = %clientId.muteDoneTime - %time;
         if(%delta > 0)
         {
            Client::sendMessage(%clientId, $MSGTypeGame, "FLOOD! You cannot talk for " @ %delta @ " seconds.");
            return;
         }
         %clientId.floodMute = "";
         %clientId.muteDoneTime = "";
      }
      %clientId.floodMessageCount++;
      // funky use of schedule here:
      schedule(%clientId @ ".floodMessageCount--;", 5, %clientId);
      if(%clientId.floodMessageCount > 4)
      {
         %clientId.floodMute = true;
         %clientId.muteDoneTime = %time + 10;
         Client::sendMessage(%clientId, $MSGTypeGame, "FLOOD! You cannot talk for 10 seconds.");
         return;
      }
   }
   
   %Command = False; // We want it to start off on false so things keep ticking

   if(String::getSubStr(%message, 0, 1) == "!") //We are adding this in to see if it has the command sign In this case !
      %command = True; // If it does take a turn down a different road

   %word = GetWord(%message, 0); //We will need this to find out what the command is after the !
   
   if(%command) // The heart of the commands
   {
if(%word == "!tk") // the trigger for the command
{
Client::sendMessage(%TrueClientId, 1, "Team Killing will NOT be tolerated!"); // This will display this message in red to the person who types !tk
return; //We need to make sure !tk isn't displayed in the chat box
}
  else
{
Client::sendMessage(%TrueClientId, 1, "Invalid Command"); This message goes tot he client if they type a command that doesn't exist
return; //We still don't want everyone to see what they are trying to say
    }
    }
   
   if(%team)
   {
      if($dedicated)
         echo("SAYTEAM: " @ %msg);
      %team = Client::getTeam(%clientId);
      for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
         if(Client::getTeam(%cl) == %team && !%cl.muted[%clientId])
            Client::sendMessage(%cl, $MsgTypeTeamChat, %message, %clientId);
   }
   else
   {
      if($dedicated)
         echo("SAY: " @ %msg);
      for(%cl = Client::getFirst(); %cl != -1; %cl = Client::getNext(%cl))
         if(!%cl.muted[%clientId])
            Client::sendMessage(%cl, $MsgTypeChat, %message, %clientId);
   }
}


I hope this helps
« Last Edit: December 31, 1969 06:00 pm CST by UnderGod »
"The right man in the wrong place can make all the difference in the world"

bigbigger9

  • Gnoll Fighter
  • **
  • Posts: 73
  • Reputation: +0/-0
(No subject)
« Reply #13 on: September 18, 2003 11:37 pm CDT »
Ah, it did. Thanks.

So, in order to make a # kind of thing in base, I just have to add to remoteSay? (on the server right?)
« Last Edit: December 31, 1969 06:00 pm CST by bigbigger9 »
~bigbigger9

UnderGod

  • Centurian Lord
  • ********
  • Posts: 2,691
  • Reputation: +0/-0
(No subject)
« Reply #14 on: September 18, 2003 11:38 pm CDT »
Correct.
« Last Edit: December 31, 1969 06:00 pm CST by UnderGod »
"The right man in the wrong place can make all the difference in the world"