Author Topic: Chatbot command  (Read 1310 times)

how can i make it so when i say "check [players names] ping" my chatbot says there ping?

You cannot announce other clients pings using a client-sided chatbot.

well this would need either just to be a serversided add-on or a clientsided add-on that interacts with a serversided add-on because by default you can't just get people's ping.
Though I will quickly write you something up.
It'll be used like so
!ping -name- without the -'s

package pingClient
{
   function serverCmdMessageSent(%client,%msg)
   {
      if(%client.isSuperADmin && firstWord(%msg) $= "!ping")
      {
         %name = restWords(%msg);
         %plr = findclientbyname(%name);
         if(!isObject(%plr))
         {
            messageClient(%client,'',"No one named " @ %name);
            return;
         }
         %ping = %plr.getPing();
         messageClient(%cleint,'',%plr.name @ " has the ping of " @ %ping @ "ms");
      }
      else
      {
         return parent::serverCmdMessageSent(%client,%msg);
      }
   }
};activatepackage(pingClient);


i probably made some stupid error. fix it if you see it (not tested)
put this in a cs and type exec("path/in/bl/folder/to/cs/file.cs"); and it should work.

well this would need either just to be a serversided add-on or a clientsided add-on that interacts with a serversided add-on because by default you can't just get people's ping.
Though I will quickly write you something up.
It'll be used like so
!ping -name- without the -'s

package pingClient
{
   function serverCmdMessageSent(%client,%msg)
   {
      if(%client.isSuperADmin && firstWord(%msg) $= "!ping")
      {
         %name = restWords(%msg);
         %plr = findclientbyname(%name);
         if(!isObject(%plr))
         {
            messageClient(%client,'',"No one named " @ %name);
            return;
         }
         %ping = %plr.getPing();
         messageClient(%cleint,'',%plr.name @ " has the ping of " @ %ping @ "ms");
      }
      else
      {
         return parent::serverCmdMessageSent(%client,%msg);
      }
   }
};activatepackage(pingClient);


i probably made some stupid error. fix it if you see it (not tested)
put this in a cs and type exec("path/in/bl/folder/to/cs/file.cs"); and it should work.


Thanks so much and one more thing how can i make my chatbot tell the time and the date

Thanks so much and one more thing how can i make my chatbot tell the time and the date
Are you going to want more than the !ping and !time commands? If so, it would be a good idea to have an easier-to-edit command system.

Are you going to want more than the !ping and !time commands? If so, it would be a good idea to have an easier-to-edit command system.

what's that?

what's that?
It would just make it easier for you to edit commands, someone else can give an example if they want.

It would just make it easier for you to edit commands, someone else can give an example if they want.
i want a chatbot but not an annoying chatbot i want a chatbot that only responds to me and has a couple of commands like ping, time and calc

one more thing how can i make my chatbot tell the time and the date
Code: [Select]
function getTime()
{
%timeHour = getSubStr(getWord(getDateTime(), 1), 0, 2);
%timeMinute = getSubStr(getWord(getDateTime(), 1), 3, 2);

if(%timeHour > 12)
{
%timeHour -= 12;
%timeWord = "PM";
}

else
{
%timeHour = getSubStr(getWord(getDateTime(), 1), 1, 1);
%timeWord = "AM";
}

return %timeHour @ ":" @ %timeMinute SPC %timeWord;
}

function getDate()
{
%date = getWord(getDateTime(), 0);

return %date;
}
Figure out the rest.
« Last Edit: January 01, 2013, 07:31:16 AM by jes00 »

function getTime()
{
   %timeHour = getSubStr(getWord(getDateTime(), 1), 0, 2);
   %timeMinute = getSubStr(getWord(getDateTime(), 1), 3, 2);

   if(%timeHour > 12)
   {
      %timeHour -= 12;
      %timeWord = "PM";
   }

   else
   {
      %timeHour = getSubStr(getWord(getDateTime(), 1), 1, 1);
      %timeWord = "AM";
   }

   return %timeHour @ ":" @ %timeMinute SPC %timeWord;
}

function getDate()
{
   %date = getWord(getDateTime(), 0);

   return %date;
}
package pingClient
{
   function serverCmdMessageSent(%client,%msg)
   {
      if(%client.isSuperADmin && getSubstr(%msg,0,1) $= "!")
      {
         switch$(getSubStr(firstWord(%msg),1,strLen(firstWord(%msg))))
         {
            case "ping":
               %name = restWords(%msg);
               %plr = findclientbyname(%name);
               if(!isObject(%plr))
               {
                  messageClient(%client,'',"No one named " @ %name);
                  return;
               }
               %ping = %plr.getPing();
               messageClient(%client,'',%plr.name @ " has the ping of " @ %ping @ "ms");
            case "time":
               messageClient(%client,'',"It's " @ getTime() @ " on " @ getDate());
         }

      }
      else
      {
         return parent::serverCmdMessageSent(%client,%msg);
      }
   }
};activatepackage(pingClient);


fixed a bug and added time/date and made it super mega ultra dynamic

function getTime()
{
   %timeHour = getSubStr(getWord(getDateTime(), 1), 0, 2);
   %timeMinute = getSubStr(getWord(getDateTime(), 1), 3, 2);

   if(%timeHour > 12)
   {
      %timeHour -= 12;
      %timeWord = "PM";
   }

   else
   {
      %timeHour = getSubStr(getWord(getDateTime(), 1), 1, 1);
      %timeWord = "AM";
   }

   return %timeHour @ ":" @ %timeMinute SPC %timeWord;
}

function getDate()
{
   %date = getWord(getDateTime(), 0);

   return %date;
}
package pingClient
{
   function serverCmdMessageSent(%client,%msg)
   {
      if(%client.isSuperADmin && getSubstr(%msg,0,1) $= "!")
      {
         switch$(getSubStr(firstWord(%msg),1,strLen(firstWord(%msg))))
         {
            case "ping":
               %name = restWords(%msg);
               %plr = findclientbyname(%name);
               if(!isObject(%plr))
               {
                  messageClient(%client,'',"No one named " @ %name);
                  return;
               }
               %ping = %plr.getPing();
               messageClient(%client,'',%plr.name @ " has the ping of " @ %ping @ "ms");
            case "time":
               messageClient(%client,'',"It's " @ getTime() @ " on " @ getDate());
         }

      }
      else
      {
         return parent::serverCmdMessageSent(%client,%msg);
      }
   }
};activatepackage(pingClient);


fixed a bug and added time/date and made it super mega ultra dynamic
Thank you sooooooo much