Author Topic: Detecting client/server status cleanly  (Read 1494 times)

I want to check the following stuff:

  • Am I a client program or a dedi?
  • If I'm a client, am I in a game?
  • If I'm a client in a game, am I host?
  • If I'm a hosting client (listen server), is it LAN or internet?

Ideally these checks will have no known bugs or crashes. I don't want something crashing if I start a server and then go back to the main menu.

Rather than figure this out on my own I figured I would see what the forum has to say. Whadya think guys?

if($Server::Dedicated)
if(!$Server::Dedicated && isObject(ServerConnection))
if(!$Server::Dedicated && isObject(LocalClientConnection))
if($Server::LAN && !$Server::Dedicated && isObject(LocalClientConnection))

Thanks, here's a cookie.  :cookie:

Thanks, here's a cookie.  :cookie:
Better take it before the Cookie Monster steals it! :cookieMonster:

Is $Server::LAN true when I'm a client connected to a LAN host?

Is $Server::LAN true when I'm a client connected to a LAN host?
No. Only when hosting. If you want to see if the server is LAN, the best I can think of is:
if(getSubStr(ServerConnection.getRawIP(),0,3) $= "192")

However, that will not work if the host is on a different subnet.

I figured out how:
If I'm a non-host client and the BL_IDs in the F2 screen are "LAN", then I must be a non-host on a LAN.  :nes:


if(isObject(ClientGroup))

whats this for?
I'm redoing walletbot from scratch using data management I learned in my intro computer science class.

When I learned it I was like, "yeah, duh." Then I was like "OMG WHY ISN'T MY BOT DOING THAT" so now he's gonna be way faster hopefully.

I'm redoing walletbot from scratch using data management I learned in my intro computer science class.

When I learned it I was like, "yeah, duh." Then I was like "OMG WHY ISN'T MY BOT DOING THAT" so now he's gonna be way faster hopefully.

What does walletbot do?

markov chat bot. in most versions he's been 2nd order but this one will start 1st order while I get it working.

In english that refers to how handicapped he acts

edit: so yeah the reason I'm doing this is that some version have been client side and some have been server side but now I'm just gonna make one universal version that works in all cases.
« Last Edit: November 22, 2012, 01:16:00 AM by Mr. Wallet »

I once made a Markov Chatbot

//Code by Brian Smith
//Please give credit if used
//Version 1.0
function getChar(%this,%n)
{
   return getSubStr(%this,%n,%n);
}
function Markov::addLine(%this,%line)
{
   %lastWord = "";
   //%line = stripBad(%line);
   for(%i=0;%i<getWordCount(%line);%i++)
   {
      %word = getWord(%line,%i);
      if(%lastWord $= "")
      {
         if(strPos(%this.startNodes,%word) < 0)
            %this.startNodes = trim(%this.startNodes SPC %word);
      }
      else
      {
         %nodeStr = %this.node[%lastWord];
         if(strPos(%nodeStr,%word) < 0)
            %this.node[%lastWord] = trim(%this.node[%lastWord] SPC %word);
      }
      %lastWord = %word;
   }
   if(%i > %this.max)
      %this.max = %i;
}
function getRandomWord(%line)
{
   %cnt = getWordCount(%line);
   %num = getRandom(0,%cnt);
   if(%num >= %cnt)
      %num--;
   //echo(%cnt SPC %num);
   return getWord(%line,%num);
}
function Markov::generateLine(%this,%len)
{
   if(%len < 2)
      return -1;
   else
   {
      %startNode = getRandomWord(%this.startNodes);
      //echo(%startNode);
      %lastWord = %startNode;
      %str = %startNode;
      for(%i=0;%i<%len - 1;%i++)
      {
         %nodeStr = %this.node[%lastWord];
         //echo(%nodestr);
         if(strLen(%nodeStr) > 0)
            %word = getRandomWord(%nodeStr);
         else
         {
            break;
            //%word = "." SPC getRandomWord(%this.startNodes); //%nodeStr);//
            //%len = %len + 3;
         }
         //echo(%word);
         %lastWord = %word;
         %str = %str SPC %word;
         //echo(%str);
      }
   }
   return %str;
}


this is the thing i made

Mine is 600-700 lines so I can't just copy-paste.
But it is much smaller than my old sloppy implementation.
More configurable too since I'll probably share or maybe even release it.

The problem with releasing it though is regulating chat frequency. He's not annoying right now at 1 bot per server. 1 per player, on the other hand...

Mine is 600-700 lines so I can't just copy-paste.
But it is much smaller than my old sloppy implementation.
More configurable too since I'll probably share or maybe even release it.

The problem with releasing it though is regulating chat frequency. He's not annoying right now at 1 bot per server. 1 per player, on the other hand...

Not sure what the point is anyways..