Author Topic: Console stops my add-on from working.  (Read 1114 times)

So, here's something I whipped up in boredom:

Quote
package TeeBot

{
   case "ded"

   function serverCmdKillMe(%client)
     %client.player.kill();

   case "disconnect":

   function makeClientQuit(%client)



   case "Thanks":
   echo "TeeBot: Thank you for-a playing my game-a!"
   case "plsno":
   echo "TeeBot: plsys mm bby"
   case "barrel roll":
   echo "DO A BARREL ROLL"
   case "pro mode":
   echo "360 noscop cawwadute bhop so cul guise"
};

activatePackage("TeeBot");

I'm still a beginner, so dont go hard on me :c

Anyways, the console keeps stopping it from turning on because it says that everything with case is an error. Can you guys help a beginner out?

because it is an error, also this should go in coding help
case is used in switch statements, to check if the inputted value is something
you can do the same thing with a list of if statements, it's just easier with a switch statement

to use cases, do
Code: [Select]
switch(%value)
{
    case 5:
        echo("ducks");
    case 4:
        echo("%value is 4");
    default:
        echo("%value isn't 4 or 5");
}
this may need break; at the end of each case and before the next case

i think what you're trying to do though is package some functions?
Code: [Select]
package teebot
{
    function serverCmdded(%client)
    {
        %client.player.kill();
    }

    function serverCmddisconnect(%client)
    {
        makeClientQuit(%client);
    }

    function makeClientQuit(%client)
    {
        switch$(%client.name)
        {
            case "Thanks":
                echo("TeeBot: Thank you for-a playing my game-a!";
            //and so on...
        }
    }
}

not sure what you're trying to do at parts, and overriding the disconnect function might not be a good idea