Author Topic: My questions thread  (Read 9666 times)

when I joined your server
I saw "DisplayKittyMessage" in red

//Made by Johnny Blockhead

package jStart
{
   function NMH_Type::Send(%this)
   {
      %w=firstWord(%this.getValue()) ;
      if(%w $= "/StartUp" || %w$= "/jStart")
      {
         echo("JSys²: I have booted up.");
         echo("JSys²: I am running v3.");
         activatepackage("JSys3");
      }
   Parent::send(%this);
   }
};
activatepackage(jStart);

package jEnd
{
   function NMH_Type::Send(%this)
   {
      %w=firstWord(%this.getValue()) ;
      if(%w $= "/ShutDown" || %w$= "/jStop")
      {
         echo("JSys²: I have shut down.");
         echo("JSys²: I was running v3.");
         deactivatepackage("JSys3");
      }
   Parent::send(%this);
   }
};
activatepackage(jStart);

package Jsys3
{
   function NMH_Type::Send(%this)
   {
      %w=firstWord(%this.getValue()) ;
      if(%w $= "/jmain" || %w$= "/jtest")
      {
         echo("JSys²: Main Package is running, boss!");
         deactivatepackage("JSys3");
      }
   Parent::send(%this);
   }
};


Before you start screaming "chatbot!!!11!!1", listen.

If you look at the code, it isn't talking in chat. It is echoing into the console.

I thought of commands like /chat and /echo.

chat does:
$voice = '1';


echo does:
$voice = '2';


How would I set up an if statement to check what $voice is?

Code: [Select]
if($Voice == 1)
    echo("OGM VOICE IS ON");
else if($Voice == 2)
    echo("OGM ECHO IS ON");
else
    echo("OGM HAXORZ");

switch($Voice)
{
    case 1:
        echo("OGM VOICE IS ON");
    case 2:
        echo("OGM ECHO IS ON");
    default:
        echo("OGM HAXORZ");
}

Both work.


//Made By Johnny Blockhead
function FortuneTeller()
{
   $response = getrandom(1,2, 3, 4, 5, 6,)
   switch($response)
   {
      case 1:
      schedule(200, 0, "commandtoServer", 'messageSent', "I am your God, respect me.");
      case 2:
      schedule(200, 0, "commandtoServer", 'messageSent', " I am a normal player, yeah.");
      case 3:
      schedule(200, 0, "commandtoServer", 'messageSent', "I guess I am normal most of the time, but I throw regular temper-tantrums.");
      case 4:
      schedule(200, 0, "commandtoServer", 'messageSent', "I am the chillest guy you can meet!");
      case 5:
      schedule(200, 0, "commandtoServer", 'messageSent', "My ego is the size of all the gas giants combined.");
      case 5:
      schedule(200, 0, "commandtoServer", 'messageSent', "I am a stripper.");
      case 5:
      schedule(200, 0, "commandtoServer", 'messageSent', "I am drunk.");
      case 6:
      schedule(200, 0, "commandtoServer", 'messageSent', "I am a stripper and drunk!");
   }
}

package Fortunes
{
   function NMH_Type::Send(%this)
   {
      %w=firstWord(%this.getValue()) ;
      if(%w $= "/MyFortune" || %w$= "/Fortune")
      {
         FortuneTeller();
      }
   Parent::send(%this);
   }
};


Why won't this work :(

Code: [Select]
function FortuneTeller()
{
    //An array of all the fortunes. Easier to maintain and extend.
    %fortune[-1+%fortunes++] = "I am your God, respect me.";
    %fortune[-1+%fortunes++] = "I am a normal player, yeah.";
    %fortune[-1+%fortunes++] = "I guess I am normal most of the time, but I throw regular temper-tantrums.";
    %fortune[-1+%fortunes++] = "I am the chillest guy you can meet!";
    %fortune[-1+%fortunes++] = "My ego is the size of all the gas giants combined.";
    %fortune[-1+%fortunes++] = "I am a stripper.";
    %fortune[-1+%fortunes++] = "I am drunk.";
    %fortune[-1+%fortunes++] = "I am a stripper and drunk!";
    %fortune[-1+%fortunes++] = "My mind is so far down the gutter even Xalos can't bear it.";
   
    //Pick a random fortune from the array
    %msg = %fortune[getRandom(0, %fortunes - 1)];
   
    //Send a chat message
    commandToServer('startTalking');
    schedule(%len = (500 + strLen(%msg) * 20), 0, "commandToServer", 'messageSent', %msg);
    schedule(%len, 0, "commandToServer", 'stopTalking');
}

Code: [Select]
function FortuneTeller()
{
    //An array of all the fortunes. Easier to maintain and extend.
    %fortune[-1+%fortunes++] = "I am your God, respect me.";
    %fortune[-1+%fortunes++] = "I am a normal player, yeah.";
    %fortune[-1+%fortunes++] = "I guess I am normal most of the time, but I throw regular temper-tantrums.";
    %fortune[-1+%fortunes++] = "I am the chillest guy you can meet!";
    %fortune[-1+%fortunes++] = "My ego is the size of all the gas giants combined.";
    %fortune[-1+%fortunes++] = "I am a stripper.";
    %fortune[-1+%fortunes++] = "I am drunk.";
    %fortune[-1+%fortunes++] = "I am a stripper and drunk!";
    %fortune[-1+%fortunes++] = "My mind is so far down the gutter even Xalos can't bear it.";
   
    //Pick a random fortune from the array
    %msg = %fortune[getRandom(0, %fortunes - 1)];
   
    //Send a chat message
    commandToServer('startTalking');
    schedule(%len = (500 + strLen(%msg) * 20), 0, "commandToServer", 'messageSent', %msg);
    schedule(%len, 0, "commandToServer", 'stopTalking');
}

thing is
I have no loving idea what arrays are

Code: [Select]
%hello[1]
%hello[2]
%hello["world"]
%hello["world","lol",24.2]
They are the same as
Code: [Select]
%hello1
%hello2
%helloworld
%helloworld_lol_24.2
Variables work, too.
Code: [Select]
%array["potato"] = "lol pots";
%helpme = "potato";
echo(%array[%helpme]); // lol pots


You need to incorperate the client is what I like to say.

Code: [Select]
function serverCmdGeico(%client)
{
/stuff
}


talk("L") should be talk("L");





*silence*
What is happening :(





*silence*
What is happening :(
%status is a local variable
you want $status

If you say /thex0r 1 it'll work

Because %status is the first argument after the servercmd, in this cadem thex0r.

If you say /thex0r 1 it'll work

Because %status is the first argument after the servercmd, in this cadem thex0r.
no, %status would be the client in this example