Help understanding using triggers/p-zones
by J Sears · in Torque Game Engine · 07/12/2007 (6:15 pm) · 0 replies
I was looking for a way to kill a player when entering an area and in my searches discovered triggers and p-zones. The tdn was lacking a lot in the information on these but I thought I understood so I tried putting one in and this is what I've done.
Well it seems I got it working decently so far, I am left with a question that isn't directly related to triggers though. Why if I add count = 6; to the playerbody data block where all max ammo etc is kept that it doesn't work but if I add count = 6 to gameconnection oncliententer game it works. but I will show the script I used in case anyone else wants to use this. It's not done perfectly but it's a good start
added one on the map information is this
then in the game.cs in the function GameConnection::onClientEnterGame I added count = 6;
then in triggers.cs (figured it was best place to put this part??)
edit : updated the fixes
Well it seems I got it working decently so far, I am left with a question that isn't directly related to triggers though. Why if I add count = 6; to the playerbody data block where all max ammo etc is kept that it doesn't work but if I add count = 6 to gameconnection oncliententer game it works. but I will show the script I used in case anyone else wants to use this. It's not done perfectly but it's a good start
added one on the map information is this
new Trigger(PlayingField) {
canSaveDynamicFields = "1";
position = "342.163 387.051 225.601";
rotation = "1 0 0 0";
scale = "12 12 12";
dataBlock = "DeathBox";
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
};then in the game.cs in the function GameConnection::onClientEnterGame I added count = 6;
then in triggers.cs (figured it was best place to put this part??)
function DeathBox::onEnterTrigger(%this, %trigger, %obj)
{
//Parent::onEnterTrigger(%this,%trigger,%obj);
echo("entering object count", %obj.client.count);
suicideCount(%obj);
}
function suicideCount(%obj)
{
%obj.client.count--;
echo(%obj.client.count);
if(%obj.client.count < 1)
%obj.client.player.kill("Suicide");
if(%obj.client.count > 0)
schedule(1000, 0, suicideCount, %obj);
}edit : updated the fixes