Author Topic: Event Help  (Read 1401 times)

So I started on this again.

I thought maybe I should change the output event to a player event.

Any reasons as to why this isn't working, the event shows up and all, but when you use the onMaskFalse.  It does nothing.

Code: [Select]
registerOutputEvent(Player, "checkMask");
registerInputEvent(fxDTSBrick, "onMaskTrue", "Self fxDtsBrick\tPlayer Player\tClient GameConnection\tMinigame Minigame");
registerInputEvent(fxDTSBrick, "onMaskFalse", "Self fxDtsBrick\tPlayer Player\tClient GameConnection\tMinigame Minigame");

function fxDTSBrick::onMaskTrue(%this, %obj, %client)
{
$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;
   }
%this.processInputEvent("onMaskTrue", %client);
}

function fxDTSBrick::onMaskFalse(%this, %obj, %client)
{
$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;
   }
%this.processInputEvent("onMaskFalse", %client);
}

function fxDTSBrick::checkMask(%obj,%client)
{
if(%client.Gasmask == 0)
{
%this.onMaskFalse(%client);
}
else
{
%this.onMaskTrue(%client);
}
}

You need to change the first line.

This:
Code: [Select]
registerOutputEvent(Player,"checkMask");
Should have a 1 as the last argument so that it passes the client along to your function:
Code: [Select]
registerOutputEvent(Player,"checkMask","",1);
Source: http://forum.blockland.us/index.php?topic=40631.0

You need to change the first line.

This:
Code: [Select]
registerOutputEvent(Player,"checkMask");
Should have a 1 as the last argument so that it passes the client along to your function:
Code: [Select]
registerOutputEvent(Player,"checkMask","",1);
Source: http://forum.blockland.us/index.php?topic=40631.0

I have been studying that topic like it's an algebra book.  And I did not catch that.  I'm loving too tired.

EDIT: Also, thanks greek

EDIT2: Do I need to change the bottom function from fxDTSBrick too?

@edit2, yes.
otherwise (read:currently) you're applying a brick method to a player object which isn't possible.

you should also be getting console errors.

So before I test this and become sad again,
You guys are saying in theory

This:
Code: [Select]
registerOutputEvent(Player,"checkMask","",1);
registerInputEvent(fxDTSBrick, "onMaskTrue", "Self fxDtsBrick\tPlayer Player\tClient GameConnection\tMinigame Minigame");
registerInputEvent(fxDTSBrick, "onMaskFalse", "Self fxDtsBrick\tPlayer Player\tClient GameConnection\tMinigame Minigame");

function fxDTSBrick::onMaskTrue(%this, %obj, %client)
{
$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;
   }
%this.processInputEvent("onMaskTrue", %client);
}

function fxDTSBrick::onMaskFalse(%this, %obj, %client)
{
$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;
   }
%this.processInputEvent("onMaskFalse", %client);
}

function player::checkMask(%this, %obj, %client)
{
if(%client.Gasmask == 0)
{
%this.onMaskFalse(%client);
}
else
{
%this.onMaskTrue(%client);
}
}

Should work?
EDIT: It doesn't
I get this error

Addons/Event_checkMask/server.cs (49): Unkown command onMaskFalse
   Object (11618) Player -> Player -> Player -> Shapebase -> ShapeBase -> Gamebase
e -> SceneObject -> NetObject -> SimObject
« Last Edit: June 17, 2012, 06:00:37 PM by ¥ola »

you're calling fxDTSBrick::onMaskFalse on the player, not the brick.

function player::checkMask(%this, %obj, %client)
{
   if(%client.Gasmask == 0)
   {
      %this.onMaskFalse(%client);

you're calling fxDTSBrick::onMaskFalse on the player, not the brick.

function player::checkMask(%this, %obj, %client)
{
   if(%client.Gasmask == 0)
   {
      %this.onMaskFalse(%client);

Wait-
What?
I didn't understand you at all mate

function player::checkMask(%this, %obj, %client)
{
   if(%client.Gasmask == 0)
   {
      %this.onMaskFalse(%client);
%this = the player
onMaskFalse is a BRICK not a PLAYER method/function

%this = the player
onMaskFalse is a BRICK not a PLAYER method/function
So I should change onMaskFalse to a player function?
Or I should change checkMask to a brick function?

probably put checkmask back to a brick function.