| Blockland Forums > Modification Help |
| Checking if you've killed someone. |
| (1/3) > >> |
| MrPickle:
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: ---function serverCmdSetName(%this, %text){ %this.player.setShapeName(//what they typed here); } --- End code --- So then you'd type /setName HowdyHo and it would set name above you to HowdyDo |
| Space Guy:
Actually, that HowdyHo code would work. Every word in the chat text after "/command" is an argument: --- Code: ---function servercmdEchoArgs(%client,%a,%b,%c,%d,%e) { echo(%client.name," called the function!"); error(%a NL %b NL %c NL %d NL %e); } --- End code --- 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 --- End quote --- ... 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: ---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); } } --- End code --- 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: ---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); --- End code --- I may have been able to use %sourceObject, but I'm unsure whether that is the killer's player or not. |
| MrPickle:
Thanks, Ill Try all this Shizzle now. Thanks for that, The text ones work, Havent tryed the death one yet. |
| VerticalHorizon:
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? |
| MrPickle:
In the add-ons folder. Right click > New > Text Document > Open > Save as > BlahdeBlah.cs |
| Navigation |
| Message Index |
| Next page |