Author Topic: [SOLVED] processInputEvent not working  (Read 739 times)

Code: [Select]
registerInputEvent("fxDTSbrick","KB_onKill", "Self fxDTSbrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame MiniGame");

function fxDTSbrick::KB_onKill(%obj, %client)
{
echo("Brick is being killed!");
//player = person who destroyed it
   $InputTarget_["Self"]   = %obj;
   $InputTarget_["Player"] = %client.player;
   $InputTarget_["Client"] = %client;

   if($Server::LAN)
   {
 $InputTarget_["MiniGame"] = getMiniGameFromObject(%client);
   }
   else
   {
 if(getMiniGameFromObject(%obj) == getMiniGameFromObject(%client))
$InputTarget_["MiniGame"] = getMiniGameFromObject(%obj);
 else
$InputTarget_["MiniGame"] = 0;
   }
   //process the event
%obj.processInputEvent("KB_OnKill", %client);
}

I can use the event with the brick like:

KB_onKill >> Client >> CenterPrint >> Message

and it even prints in the console ("Brick is being killed");
but it doesn't CenterPrint.

What am I doing wrong?
« Last Edit: August 07, 2016, 01:04:28 AM by KozzyMoto »

What calls KB_onKill?
Also try to echo the %client and see if anything pops up

Yeah, post the code where you call KB_onKill.

Code: [Select]
registerOutputEvent("fxDTSbrick","permaKill", "", 0);
registerInputEvent("fxDTSbrick","KB_onKill", "Self fxDTSbrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame MiniGame");

function fxDTSbrick::KB_onKill(%obj, %client)
{
echo("Brick is being killed!");
//player = person who destroyed it
   $InputTarget_["Self"]   = %obj;
   $InputTarget_["Player"] = %client.player;
   $InputTarget_["Client"] = %client;

   if($Server::LAN)
   {
  $InputTarget_["MiniGame"] = getMiniGameFromObject(%client);
   }
   else
   {
  if(getMiniGameFromObject(%obj) == getMiniGameFromObject(%client))
$InputTarget_["MiniGame"] = getMiniGameFromObject(%obj);
  else
$InputTarget_["MiniGame"] = 0;
   }
   //process the event
%obj.processInputEvent("KB_OnKill", %client);
}

function fxDTSbrick::KB_destroy(%obj)
{
if(isObject(%obj))
{
%obj.KB_onKill();
%obj.killBrick();
}
}

function fxDTSbrick::KB_setHealth(%brick,%hp)
{

%brick.Health = %hp;
if(%brick.Health < 0)
%brick.KB_destroy();

}
registerOutputEvent("fxDTSbrick","setHealth","int -1000000 1000000", 0);

function fxDTSbrick::KB_incHealth(%brick,%amt)
{
if(%brick.Health)
%brick.Health+=%amt;
else
%brick.Health = %amt;
if(%brick.Health < 0)
%brick.KB_destroy();
}
registerOutputEvent("fxDTSbrick","incHealth","int -1000000 1000000",0);

By the way the other events work fine. After using them I would echo the bricks "health" and it would show the correct value.

It's because when the function gets called, %client is blank.

Code: [Select]
$version = "0.1.6";
warn("Now loading KB Event Pack v" @ $version);

registerOutputEvent("fxDTSbrick","KB_destroy", "", 1);
registerInputEvent("fxDTSbrick","KB_onKill", "Self fxDTSbrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame MiniGame");

function fxDTSbrick::KB_onKill(%obj, %client)
{
echo("Brick is being killed!");
//player = person who destroyed it
%client.dump(); // <<<<<<<<<<<<<<<<
   $InputTarget_["Self"]   = %obj;
   $InputTarget_["Player"] = %client.player;
   $InputTarget_["Client"] = %client;

   if($Server::LAN)
   {
  $InputTarget_["MiniGame"] = getMiniGameFromObject(%client);
   }
   else
   {
  if(getMiniGameFromObject(%obj) == getMiniGameFromObject(%client))
$InputTarget_["MiniGame"] = getMiniGameFromObject(%obj);
  else
$InputTarget_["MiniGame"] = 0;
   }
   //process the event
%obj.processInputEvent("KB_OnKill", %client);
}

function fxDTSbrick::KB_destroy(%obj, %client)
{
if(isObject(%obj))
{
%obj.KB_onKill(%obj, %client);
%obj.killBrick();
}
}

function fxDTSbrick::KB_setHealth(%brick,%hp,%client)
{

%brick.Health = %hp;
if(%brick.Health < 0)
%brick.KB_destroy(%client);

}
registerOutputEvent("fxDTSbrick","setHealth","int -1000000 1000000", 1);

function fxDTSbrick::KB_incHealth(%brick,%amt,%client)
{
if(%brick.Health)
%brick.Health+=%amt;
else
%brick.Health = %amt;
if(%brick.Health < 0)
%brick.KB_destroy(%client);
}
registerOutputEvent("fxDTSbrick","incHealth","int -1000000 1000000",1);

It dumps %client and it seems that %client is a brick, not the client.
What is happening?

dataBlock = "brick2x2data"; Why is the brick being passed to the %client parameter?

function fxDTSbrick::KB_destroy(%obj, %client)
{
   if(isObject(%obj))
   {
      %obj.KB_onKill(%obj, %client);
      %obj.killBrick();
   }
}
The bolded argument shouldn't be included since %obj is the method's namespace.

Thank you!
It's working perfectly now. Thanks to everyone who helped me!