Author Topic: Checking if you've killed someone.  (Read 2291 times)

Yeah so is there a way to check if you have killed someone without < and all that shizzle.

Also, How would you check for something in someones text Example:

Code: [Select]
function serverCmdSetName(%this, %text){
%this.player.setShapeName(//what they typed here);
}

So then you'd type /setName HowdyHo and it would set name above you to HowdyDo
« Last Edit: June 20, 2007, 10:26:52 AM by MrPickel »

Actually, that HowdyHo code would work. Every word in the chat text after "/command" is an argument:

Code: [Select]
function servercmdEchoArgs(%client,%a,%b,%c,%d,%e)
{
 echo(%client.name," called the function!");
 error(%a NL %b NL %c NL %d NL %e);
}

If I typed "/EchoArgs 1 2 AAAAA 4 V MoreArgs Lots" I would get:

Quote
Space Guy called the function!
1
2
AAAAA
4
V

... Because the function doesn't have more arguments it will ignore the ones after %e ("V") but still use the rest. Your function might be:

Code: [Select]
function serverCmdSetName(%this, %t1,%t2,%t3,%t4,%t5,%t6)
{
 if(isObject(%this.player))
 {
   %text = %t1 SPC %t2 SPC %t3 SPC %t4 SPC %t5 SPC %t6;
   %this.player.setShapeName(%text);
 }
}

The long line could be replaced with a for loop like for(%i = 0;%t[%i] !$= "";%i++){%str = %str SPC %t[%i];} - looping through arguments with arrays and allowing easy addition of more. (%t7,%t8,etc)

The only other method I know of an on death check still uses packages but no > <:
Code: [Select]
package DeathCheck
{
 function GameConnection::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc)
 {
  if(isObject(%sourceClient.player))
  {
   %sourceClient.player.mountImage(0,wrenchImage);
  }
  Parent::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc);
 }
};
activatePackage(DeathCheck);

I may have been able to use %sourceObject, but I'm unsure whether that is the killer's player or not.

Thanks, Ill Try all this Shizzle now.

Thanks for that, The text ones work, Havent tryed the death one yet.
« Last Edit: June 20, 2007, 10:49:36 AM by MrPickel »

I have been looking through coding discussions trying to get a better idea on how to understand Torque Script, and I've seen bunches like this, and I'm wondering; where do you put these type of scripts?

In the add-ons folder. Right click > New > Text Document > Open > Save as > BlahdeBlah.cs

I know how to make .cs files, but I mean:
Do you just paste scripts into one, enabled it and it changes the servers behavior?

Yeah. For example the Death Package.

Code: [Select]
package DeathCheck
{
function GameConnection::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc)
{
  if(isObject(%sourceClient.player))
  {
   %sourceClient.player.mountImage(0,wrenchImage);
  }
  Parent::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc);
}
};
activatePackage(DeathCheck);

Once thats enabled on the check list bit when ever you kill someone you will mount the wrench.

Its a package activatePackage(DeathCheck); tells TGE to start running the pakcage. deactivatePackage(DeathCheck); would tell it to stop running that script.

Oh ok cool now I understand, thanks. :D


Wow this is great, thanks, this will help me out alot.