| Blockland Forums > Modification Help |
| Registering an input event without a client feild? |
| (1/1) |
| DrenDran:
Basically I want a global event to trigger an input event for all bricks... --- Code: ---registerInputEvent("fxDTSBrick", "onNewDay", "Self fxDTSBrick"); function fxDTSBrick::onNewDay(%obj,%c) { $InputTarget_["Self"] = %obj; %obj.processInputEvent("onNewDay",%c); } --- End code --- This defines the event. And this triggers it as a part of a function... --- Code: --- for(%cs=0;%cs<clientgroup.getcount();%cs++) { %client = clientgroup.getobject(%cs); if(isObject(%client)) { %brickgroup = %client.brickgroup; if(isObject(%brickgroup)) { for(%bs=0;%bs<%brickgroup.getcount();%bs++) { %brick = %brickgroup.getobject(%bs); if(isObject(%brick)) %brick.onNewDay(clientgroup.getobject(0)); } } } } --- End code --- But as you see, I use %brick.onNewDay(clientgroup.getobject(0)); just putting in a random client to get around it, this seems to have no effect as the input event has no client output, but I feel it is bad practice, is there anyway around a client field or will this work? |
| Bauklotz:
I used to create a AIConnection lasting for the duration of the input event function and slightly after the .processInputEvent, and it seems to work nicely. |
| DrenDran:
So how would I do that, anyhow. |
| Bauklotz:
--- Code: ---%cl = new AIConnection() { name = ""; bl_id = -1; }; --- End code --- ... --- Code: ---%cl.delete(); // or %cl.schedule(..., delete); --- End code --- |
| Iban:
GameMode_ZAPT/scripts/function.cs --- Code: ---registerInputEvent("fxDTSBrick", "onZombieSpawned", "Self fxDTSBrick" TAB "Bot Player" TAB "MiniGame MiniGame"TAB "OwnerPlayer Player" TAB "OwnerClient GameConnection"); --- End code --- --- Code: ---function fxDTSBrick::onZombieSpawned(%this, %obj) { $InputTarget_["Self"] = %this; if(zombieBot(%obj)) { $InputTarget_["Bot"] = %obj; } else { $InputTarget_["Bot"] = -1; } $InputTarget_["MiniGame"] = getMiniGameFromObject(%this); if(isObject(%this.getGroup().client)) { if(isObject(%this.getGroup().client.player)) { $InputTarget_["OwnerPlayer"] = %this.getGroup().client.player; } $InputTarget_["OwnerClient"] = %this.getGroup().client; } else { $InputTarget_["OwnerPlayer"] = -1; $InputTarget_["OwnerClient"] = -1; } %this.processInputEvent("onZombieSpawned", %obj); } --- End code --- |
| Navigation |
| Message Index |