Author Topic: Input Events: Minigame  (Read 737 times)

I'm extremely new to making events and stuff, and I've been having a problem with one thing. Calling a mini-game output through an input event. For example:
Code: [Select]
onInput->Minigame->OutputI decided to create an onBrickTrigger input and brickTrigger output events for practice, and I noticed the error above.

Here's the code:
*Note* I added in echo functions to see if %client.minigame was actually the correct thing. FYI, it is the correct thing. *Note*
Code: [Select]
RegisterInputEvent(fxDtsBrick, "onBrickTrigger", "Self fxDtsBrick" TAB "Player Player" TAB "Client gameConnection" TAB "Minigame Minigame");

registerOutputEvent("fxDtsBrick", "brickTrigger");


function fxDtsBrick::brickTrigger(%this)
{
%client = %this.getGroup().client;
echo(%client.minigame);
$InputTarget_["Self"] = %this;
$InputTarget_["Player"] = %client.player;
$InputTarget_["Client"] = %client;
$InputTarget_["Minigame"] = %client.minigame;
%this.processInputEvent("onBrickTrigger", %this);
}

I've tried to find some resources, used Amade's bot event 'onBotKilled' for some insight on using 'Minigame', I echoed the minigame value on his event and it was the same as mine, but it actually worked.

Code: [Select]
onBotKilled -> Minigame -> chatMsgAll[Blah.] //Works
onBotKilled -> Self -> brickTrigger
onBrickTrigger -> Minigame -> chatMsgAll[Blarg.] //Doesn't work

Code: [Select]
RegisterInputEvent(fxDtsBrick, "onBotKilled", "Self fxDtsBrick" TAB "Killer Player" TAB "Killer(Client) GameConnection" TAB "Corpse Player" TAB "Minigame Minigame");

function armor::onDisabled(%this, %obj)
{
parent::onDisabled(%this, %obj);
if(%obj.getClassName() $= "AIPlayer" && isObject(%brick = %obj.spawnBrick))
{
%obj.setImageTrigger(0, 0);
%obj.setImageTrigger(1, 0);
if(isObject(%obj.client))
{
%obj.client.delete();
}
if(isObject(%client = %obj.lastPusher) && (%obj.lastPushTime + 1000) > getSimTime())
{
%obj.setImageTrigger(0, 0);
%obj.setImageTrigger(1, 0);
%killer = %obj.lastPusher.player;
$InputTarget_["Self"] = %brick;
$InputTarget_["Killer"] = %killer;
$InputTarget_["Killer(Client)"] = %killer.client;
$InputTarget_["Corpse"] = %obj;
$InputTarget_["Minigame"] = %killer.client.minigame;
echo(%killer.client.minigame);
%brick.processInputEvent("onBotKilled", %client);
}
}
}


Thanks in advance.


Quote
%this.processInputEvent("onBrickTrigger", %this);
That last argument should be %client rather than %this.

That last argument should be %client rather than %this.
Thanks! Going to test it now.


EDIT: Works, thanks a bunch :D

Can you explain why exactly it needs that? And what exactly the last argument on that function is?
« Last Edit: May 23, 2010, 02:46:23 PM by HellsHero »

That last argument is sent as the "client" who triggered the event.

For instance, in Brick->spawnProjectile it's used so that the client who clicked whatever button owns the projectiles that are fired. In the minigame ChatMsgAll event it's probably used in a check so that only someone in the minigame can trigger the events - %client.minigame exists as you checked, but %this (a brick) .minigame does not.