Author Topic: how do I make it so when I type in something in the chat, something happens  (Read 3477 times)

I want to make a mod for blockland that requires this.
and also, do any of you know a helpful coding website?

You mean / commands? Server sided? Client sided?

The Blockland forums is the best coding website in the world for TorqueScript, and it has the best TS coders. If you mean programming in general, just google stuff. If you're just starting out, i'd recommend learning JavaScript, as its fairly simple at first, quite similar to TorqueScript, easy to test, fast to see results from, and most importantly there are thousands of teaching resources.

You mean / commands? Server sided? Client sided?

The Blockland forums is the best coding website in the world for TorqueScript, and it has the best TS coders. If you mean programming in general, just google stuff. If you're just starting out, i'd recommend learning JavaScript, as its fairly simple at first, quite similar to TorqueScript, easy to test, fast to see results from, and most importantly there are thousands of teaching resources.
server sided please
Java was the 1st coding language i started to learn

If you mean a slash command:
Code: [Select]
function serverCmdSneeze(%client, %word1, %word2, %word3, %word4, %etc)
{
        %client.player.addVelocity("0 0 5");
        messageAll('', %client.name SPC "sneezed!");
}
If you don't:
Code: [Select]
package MySneeze
{
        function serverCmdMessageSent(%client, %msg)
        {
                parent::serverCmdMessageSent(%client, %msg);

                if(%msg $= "hi")
                {
                        %client.player.kill();
                        messageClient(%client, '', "No.");
                }
        }
};
activatePackage(MySneeze);

If you mean a slash command:
Code: [Select]
function serverCmdSneeze(%client, %word1, %word2, %word3, %word4, %etc)
{
        %client.player.addVelocity("0 0 5");
        messageAll('', %client.name SPC "sneezed!");
}
If you don't:
Code: [Select]
package MySneeze
{
        function serverCmdMessageSent(%client, %msg)
        {
                parent::serverCmdMessageSent(%client, %msg);

                if(%msg $= "hi")
                {
                        %client.player.kill();
                        messageClient(%client, '', "No.");
                }
        }
};
activatePackage(MySneeze);
Im a bit confued on the %client.player.addVelocity("0 0 5"); part in the / command part, whats it for?
Also, thanks!
« Last Edit: August 15, 2015, 11:45:08 AM by Bow »

Im a bit confued on the %client.player.addVelocity("0 0 5"); part in the / command part, whats it for?
Also, thanks!
since you didn't describe what you were trying to accomplish he just created little useless commands to help show you how they worked
serverCmdSneeze will make it so that when a player types /sneeze their player is bounced into the air with a force of '5' whatever torque uses as force measurement

also when interacting with players make sure you check that the exist

Code: [Select]
function serverCmdSneeze(%client, %word1, %word2, %word3, %word4, %etc)
{
        if(isObject(%client.player))
        {
                %client.player.addVelocity("0 0 5");
        }
        messageAll('', %client.getPlayerName() SPC "sneezed!");
}

Code: [Select]
package MySneeze
{
        function serverCmdMessageSent(%client, %msg)
        {
                parent::serverCmdMessageSent(%client, %msg);

                if(%msg $= "hi")
                {
                        if(isObject(%client.player))
                        {
                                %client.player.kill();
                        }
                        messageClient(%client, '', "No.");
                }
        }
};
activatePackage(MySneeze);

jes00:
don't forget that %client.name is deprecated and %client.getPlayerName() should be used instead

jes00:
don't forget that %client.name is deprecated and %client.getPlayerName() should be used instead
Bleh. Too lazy.

Java was the 1st coding language i started to learn
for java help, try googling your problems and something on stackoverflow should help you

since you didn't describe what you were trying to accomplish he just created little useless commands to help show you how they worked
serverCmdSneeze will make it so that when a player types /sneeze their player is bounced into the air with a force of '5' whatever torque uses as force measurement

also when interacting with players make sure you check that the exist

Code: [Select]
function serverCmdSneeze(%client, %word1, %word2, %word3, %word4, %etc)
{
        if(isObject(%client.player))
        {
                %client.player.addVelocity("0 0 5");
        }
        messageAll('', %client.getPlayerName() SPC "sneezed!");
}

Code: [Select]
package MySneeze
{
        function serverCmdMessageSent(%client, %msg)
        {
                parent::serverCmdMessageSent(%client, %msg);

                if(%msg $= "hi")
                {
                        if(isObject(%client.player))
                        {
                                %client.player.kill();
                        }
                        messageClient(%client, '', "No.");
                }
        }
};
activatePackage(MySneeze);

jes00:
don't forget that %client.name is deprecated and %client.getPlayerName() should be used instead
Ahh, I see...



lol

since you didn't describe what you were trying to accomplish he just created little useless commands to help show you how they worked
serverCmdSneeze will make it so that when a player types /sneeze their player is bounced into the air with a force of '5' whatever torque uses as force measurement

also when interacting with players make sure you check that the exist

Code: [Select]
function serverCmdSneeze(%client, %word1, %word2, %word3, %word4, %etc)
{
        if(isObject(%client.player))
        {
                %client.player.addVelocity("0 0 5");
        }
        messageAll('', %client.getPlayerName() SPC "sneezed!");
}

Code: [Select]
package MySneeze
{
        function serverCmdMessageSent(%client, %msg)
        {
                parent::serverCmdMessageSent(%client, %msg);

                if(%msg $= "hi")
                {
                        if(isObject(%client.player))
                        {
                                %client.player.kill();
                        }
                        messageClient(%client, '', "No.");
                }
        }
};
activatePackage(MySneeze);

jes00:
don't forget that %client.name is deprecated and %client.getPlayerName() should be used instead
Is there anyway to make it so that if you were an admin and say a players name and then a command (Ban,kick) and then that action would be preformed?

Yeah. You can use getWord(string, int) to check if their message is "kick Crown" and if it is, try to find a client with the second word then call the function. So

%target = findClientByName(getWord(%msg, 1));

Note that it's 1 not 2 because it starts at 0, so the first word in the string is 0.
Then you can check if it's a real client and if it is kick them.

if(isObject(%target))
    serverCmdKick(%client, %target);


I believe kick uses the client's object not their name so it wouldn't be .getPlayerName()

if you're using servercmdkick, that's just like doing /kick ID
pretty sure it would be %target.getBLID() or something

I know the ban function uses the BLID or name, not sure which

whatever torque uses as force measurement

Torque Units Per Second. A single brick is 0.5x0.5x0.6 TU, which makes a plate 0.5x0.5x0.2 TU.

I know the ban function uses the BLID or name, not sure which
BLID.

Yeah. You can use getWord(string, int) to check if their message is "kick Crown" and if it is, try to find a client with the second word then call the function. So

%target = findClientByName(getWord(%msg, 1));

Note that it's 1 not 2 because it starts at 0, so the first word in the string is 0.
Then you can check if it's a real client and if it is kick them.

if(isObject(%target))
    serverCmdKick(%client, %target);


I believe kick uses the client's object not their name so it wouldn't be .getPlayerName()
Ok, this may sound stupid, but where do I place this code in the cs file
here is where I placed it
Code: [Select]
function serverCmdFling(%client, %word1, %word2, %word3, %word4, %etc)
{
        if(isObject(%client.player))
        {
if(client.isadmin)
{
               
getWord(string, int)
%target = findClientByName(getWord(%msg, 1));
if(isObject(%target))
    %client.player.addVelocity("0 0 5"(%client, %target));

        }
        messageAll('', %client.getPlayerName() SPC "Has been flung by one of the admins!");
}
« Last Edit: August 15, 2015, 04:19:02 PM by Bow »