Author Topic: Disappearing variable! [SOLVED]  (Read 489 times)

When running Team Deathmatch, I'm trying to make a simple way of having a brick as 'capturable' by teams which then triggers events. However, I'm running into some obscure problem I cannot figure out...

Code: [Select]
function TDMPointTriggerData::onTickTrigger(%this,%trigger)
{
 %brick = %trigger.spawnBrick;

 //... code cut out
 
 if(%brick.tdmCaptureNum[%atkTeam] == 0)
 {
  if(%brick.tdmIsCaptured)
   return;
  %brick.setTeamAllied(%defTeam+1,%defClient);
 }
 else if(%brick.tdmCaptureNum[%atkTeam] == 100)
 {
  if(%brick.tdmIsCaptured)
   return;
  echo("-> POINT CAPTURED: " @ %atkclient SPC "(" @ %atkclient.name @ ")");
  $cl = %atkclient;
  %brick.setTeamAllied(%atkTeam+1,%atkClient);
 }
 else if(%brick.tdmIsCaptured)
 {
  %brick.tdmIsCaptured = 0;
  %colAv = vectorScale(vectorAdd(%atkCol,%defCol),0.5) SPC 1;
  %brick.setColor(getClosestPaintColor(%colAv));
 }
}

This code works fine, and teams can capture the control points by standing on a brick created with it. The code echoes this when on Team 1 I capture a Team 2 control point:
Quote
-> POINT CAPTURED: 7316 (Space Guy)

... which indicates that everything is fine. $cl is saved for debugging, as is below. It then calls %brick.setTeamAllied with that same variable (%atkClient, here 7316)...

Code: [Select]
registerOutputEvent(fxDTSBrick,"setTeamAllied","list NONE 0 PLAYER 7 1 1 2 2 3 3 4 4 5 5 6 6",1);
function fxDTSBrick::setTeamAllied(%this,%team,%client)
{
 echo("-> SET TEAM ALLIED: " @ %client SPC "(" @ %client.name @ ")");
 echo("-> SAVED CLIENT = " @ $cl SPC "(" @ $cl.name @ ")");

 //... code cut out
}

Immediately, at the start of the function, I echo the same variables that I just showed. But what I get...
Quote
-> SET TEAM ALLIED:  ()
-> SAVED CLIENT = 7316 (Space Guy)

%client has disappeared, even though it should be the same as %atkclient I passed to the function. $cl still shows up as the correct value. What happened to it? Is it to do with the registerOutputEvent call? (I've set 'append client' to 1 which is used when I call it as an event, but that shouldn't affect it here)
« Last Edit: February 01, 2009, 04:18:25 PM by Space Guy »

Yeah I've had args going blank on me back in v0002. Not sure what happened.

First you could try commenting out the registerOutputEvent call and seeing what happens, or try tracing to see what's being sent.

I figured it out from the trace (removing registerOutputEvent didn't fix it) - the package I used for the Capture The Flag game mode on top of fxDTSBrick::setTeamAllied didn't have the Client argument, so was breaking it. Thanks for helping!

Solved.