Author Topic: Problem with onLeave in a trigger  (Read 3165 times)

I'm making a trigger that kills you when you leave it, but it's not working.

This is the code for the trigger.
Code: [Select]
datablock TriggerData(GameArena)
{
   tickPeriodMS = 100;
};
function GameArena::onEnterTrigger(%this,%trigger,%obj)
{
//lol nothing to do here
}
function GameArena::onLeaveTrigger(%this,%trigger,%obj)
{
%obj.client.kill();
bottomprint(%obj.client,'',"\c2Do not leave the game arena",5);
}

But when i stand inside the trigger, i just get my console spammed with.
Code: [Select]
TriggerData::onTickTrigger - wrong number of arguments.
usage: (Trigger t)

And when i leave the trigger, i get '104' bottomprinted, and then i get
Code: [Select]
Unknown command kill.
  Object LocalClientConnection(4852) GameConnection -> GameConnection -> NetConnection -> SimGroup -> SimSet -> SimObject

Can anyone help?

This works.

Code: [Select]
datablock TriggerData(GameArena)
{
   tickPeriodMS = 100;
};
function GameArena::onEnterTrigger(%this,%trigger,%obj)
{
//lol nothing to do here
}
function GameArena::onLeaveTrigger(%this,%trigger,%obj)
{
%obj.player.client.kill();
bottomprint(%obj.client,"\c2Do not leave the game arena",5);
}

You should add a check to see if the %obj is a player by doing if(%obj.client)

This works.

Code: [Select]
datablock TriggerData(GameArena)
{
   tickPeriodMS = 100;
};
function GameArena::onEnterTrigger(%this,%trigger,%obj)
{
//lol nothing to do here
}
function GameArena::onLeaveTrigger(%this,%trigger,%obj)
{
%obj.player.client.kill();
bottomprint(%obj.client,"\c2Do not leave the game arena",5);
}

I still get the
TriggerData::onTickTrigger - wrong number of arguments.
usage: (Trigger t)
spam, the bottomprint works now, but i don't get killed, it just says.
Unable to find function '' attempting to call function 'kill'

My bad. "%obj.player.client.kill();" should be "%obj.kill();"

Ah, right, thanks. The killing and the bottomprinting works now, but i still get the error message, so I have the feeling i'm doing something wrong.

Try it without the onEnter command

The trigger works fine now, removing that didn't do anything, but i still get spammed by that trigger usage line =\

I get that with my non-admin killing trigger aswell, (The wrong amount of arguments)

Badspot

  • Administrator
Even if you're not using it, you have to define an onTickTrigger method for your trigger like so:

Code: [Select]
function GameArena::onTickTrigger(%this,%trigger, %obj)

   Parent::onTickTrigger(%this,%trigger);
}