Author Topic: My questions thread  (Read 9637 times)

you mean like the talking animation?
He was mentioning this on rtb. Now I know what he means.

Use

%client.player.playThread(3,"talk");
%client.player.schedule(1000,playThread,3,"root");

Is it possible to execute something from my desktop?
Something like
exec("pc/desktop/server.cs");

no blockland only has access to anything in the blockland directory


//Made by Johnny Blockhead
//For release by Johnny Blockhead only
//Yes I am immature

package PumpkinPieIsBeast
{
    function servercmdTwerk(%client)
    {
            %client.player.playThread(3,"talk");
         %client.player.schedule(5000,playThread,3,"root");
            messageClient(%client,'',"<color:FFFFFF>Hote");
    }
   
   function servercmdHump(%client)
   {
         %client.player.playThread(3,"crouchBack");
         messageClient(%client,'',"<color:FFFFFF>omg");
         %client.player.schedule(5000,playThread,3,"root");
   }
   
   function servercmdNormal
   {
         %client.player.playThread(3,"activate");
         %client.player.schedule(33,playThread,3,"root");
   }
   
   
};
activatepackage(PumpkinPieIsBeast);


the devil made me do it



anyways /normal isn't working

you forgot the () and paramaters

I get the parameters part, but what do you mean by the parenthesis?
also, to totally avoid /normal

function servercmdHump(%client)
   {
         %client.player.playThread(3,"crouchBack");
         messageClient(%client,'',"<color:FFFFFF>omg");
         %client.player.schedule(5000,playThread,3,"root");
   }

Why doesn't this stop after a while, like twerk



That's strange, the code you posted is completely valid as far as I'm aware and I had no issue with it not stopping the dryhump animation when testing it on my server. If no one else figures it out tomorrow I'll keep fiddling with it.



I get the parameters part, but what do you mean by the parenthesis?

He means you forgot to add parentheses and parameters inside after your function name.

function servercmdNormal(%client)
{
      %client.player.playThread(3,"activate");
      %client.player.schedule(33,playThread,3,"root");
}

If you open a parentheses or bracket in TorqueScript and forgot to close it, the TorqueScript interpreter won't understand your code when it comes the time to read it and therefore it won't be able to run. You'll also get something like this output to your console:



This is what's called a syntax error. Another example of one would be because I opened a parentheses after "theWrongWay", put in a parameter, and didn't close it. Oops, I also forgot an opening bracket! stuff!:

Code: [Select]
function theWrongWay( %something // <<< no closing parentheses )-:
{
                       doTheRightThing();
}

function alsoIncorrent( %something ) // <<< no opening bracket :-{
                       return %something SPC "Where is that opening bracket?!!";
}

This code however, is good to go, because I closed the parentheses and brackets:

Code: [Select]
function theWrongWay( %something )
{
                       doTheRightThing();
}

function alsoIncorrent( %something )
{
                       return %something SPC "Where is that opening bracket?!!";
}



Also, while I'm at it, I'd like to point out that it's good practice to check if an object exist before you call methods on it. Otherwise the console will complain about a missing object that has been referenced somewhere in your code. Let's put this into a simple example, lets say I declared a server command called "superSizeMe", and as the name implies, when it gets invoked, the invoking client's player will become big.

You could just write it like this:

Code: [Select]
function serverCmdSupersizeMe( %client )
{
         %client.player.setScale( "5 5 5" );
}

But what if the person who typed the command is still in the loading phase, or is dead? Well you'd see something like this output to your console:



This happens because you're trying to called setScale (A method) on a player (an object) which doesn't exist.

So... how would you fix this? Well, that's simple, you would use the "isObject" function. You pass this function something that could be an object-id or object name and it will return true if what you passed it is an object, and false if it's not. So let's re-implement our "superSizeMe" server command:

Code: [Select]
function serverCmdSupersizeMe( %client )
{
        if( isObject( %player = %client.player ))
        {
                %player.setScale( "5 5 5" );
        }
}

Boom! Now the code wont spam my console if something doesn't go the way I expected it to!



%client.player isn't a function, no () after it.
woops thanks for catching that!
« Last Edit: October 26, 2013, 10:23:53 AM by Zelothix »

Code: [Select]
function serverCmdSupersizeMe( %client )
{
        if( isObject( %player = %client.player() ))
        {
                %player.setScale( "5 5 5" );
        }
}

Boom! Now the code wont spam my console if something doesn't go the way I expected it to!
%client.player isn't a function, no () after it.

Waiting for a response on previous issue, but in the meantime...


   

    //Made by Johnny Blockhead
    package HubJoin
    {
     
    function gameConnection::autoAdminCheck(%this)
    {
      displayHubMessage(%this);
      return parent::autoAdminCheck(%this);
    }
     
    function displayHubMessage(%client)
    {
            messageClient(%client,'',"DisplayHubMessage");
    }
     
    function HubMessage(%client)
    {
            messageClient(%client,'',"HubMessage");
    }
     
    };
    activatepackage(HubJoin);


Trying to make it so when a player joins, it says stuff
but for the example you guys gave me you did DisplayHubMessage;
would the function that messages the client be hubMessage or Displayhubmessage
also when Marble Man joined my server it said nothing to him, hubmessage or displayhubmessage didn't pop up.
« Last Edit: October 27, 2013, 05:35:15 PM by Johnny Blockhead »







What is marble talking about
the server was passworded btw







What is marble talking about
the server was passworded btw
He's crazy.

    //Made by Johnny Blockhead
    package HubJoin
    {
    
    function gameConnection::autoAdminCheck(%this)
    {
      displayHubMessage(%this);
      return parent::autoAdminCheck(%this);
    }
    
    function displayHubMessage(%client)
    {
            messageClient(%client,'',"DisplayHubMessage");
    }
    
    function HubMessage(%client)
    {
            messageClient(%client,'',"HubMessage");
    }
    
    };
    activatepackage(HubJoin);


Trying to make it so when a player joins, it says stuff
but for the example you guys gave me you did DisplayHubMessage;
would the function that messages the client be hubMessage or Displayhubmessage
also when Marble Man joined my server it said nothing to him, hubmessage or displayhubmessage didn't pop up.
Don't create a function if your just going to call one one thing in that function.
Just do this:
Code: [Select]
//Made by Johnny Blockhead
package HubJoin
{
        function gameConnection::autoAdminCheck(%client)
        {
                messageClient(%client, '', "DisplayHubMessage");
                return parent::autoAdminCheck(%client);
        }
};
activatepackage(HubJoin);
« Last Edit: October 27, 2013, 09:44:51 PM by jes00 »