Author Topic: Request : Output event | Chosing a random player.  (Read 633 times)

Greetings,

I noticed that most of gamemode like Falling Platform or Deathcube got the same problem. If the "Boss" left the game, the game stop until an admin come to repair that. Is there an output event that can choose a random player if the boss left ?

I already googled that, but i just founds some random script but i don't know how to integrate that for the game.



Exemple:

OnActivate -> Minigame -> VCE_Ifvalue [<var:mg:teamMembers>] [<] [1]
OnVariableTrue -> Minigame -> SelectRandomPlayer
OnRamdomPlayerSelected -> Client > JoinTeam [Boss]

Wouldn't it better to have a random play selected as the target, rather than the output event?

Wouldn't it better to have a random play selected as the target, rather than the output event?
What do you mean by "random play selected" ?
« Last Edit: August 22, 2014, 09:08:23 AM by Rammboy »

Meant random player. So for instance OnVariableTrue>RandomClient>joinTeam [Boss] or onVariableTrue>RandomPlayer>DoPlayerTeleport [blah blah]

Meant random player. So for instance OnVariableTrue>RandomClient>joinTeam [Boss] or onVariableTrue>RandomPlayer>DoPlayerTeleport [blah blah]

Yes, that a great idea, but i don't know how to script this.

If I knew how to properly register target events I'd be able to do it, but I've only ever done output events, not even input events.

If I knew how to properly register target events I'd be able to do it, but I've only ever done output events, not even input events.
The event system isn't meant to work like that. You'll have to inject the new target for all input events that should support it and then apply a hacky solution to set it to a random player before the input event is procesed.

The event system isn't meant to work like that. You'll have to inject the new target for all input events that should support it and then apply a hacky solution to set it to a random player before the input event is procesed.

It looks complicated.

It looks complicated.

It isn't, you just have to modify some variables and package processInputEvent to set the target. The problem is if you have multiple add-ons trying that you'll most likely get a mess in the end.

For example something like this could work.

Quote

//Add target to all existing events
function addRandomPlayerTarget()
{
   for(%i = 0; %i < $InputEvent_Count["fxDTSbrick"]; %i++)
   {
      %list = $InputEvent_TargetList["fxDTSBrick", %i];

      //Don't add if already exists for whatever reason
      %skip = 0;

      for(%j = 0; %j < getFieldCount(%list); %j++)
         if(getField(%list, %j) $= "RandomPlayer Player")
            %skip = 1;

      if(!%skip)
         $InputEvent_TargetList["fxDTSBrick", %i] = %list TAB "RandomPlayer Player";
   }
}

addRandomPlayerTarget();

package RandomPlayerTarget
{
   //Add target to all future events
   function registerInputEvent(%class, %name, %targetList, %adminOnly)
   {
      return parent::registerInputEvent(%class, %name, %targetList TAB "RandomPlayer Player", %adminOnly);
   }

   //Set target to random player
   SimObject::processInputEvent(%obj, %EventName, %client)
   {
      $InputTarget_["RandomPlayer"] = ClientGroup.getObject(getRandom(0, ClientGroup.getCount() -1)).player;

      return parent::processInputEvent(%obj, %EventName, %client);
   }
};
activatePackage(RandomPlayerTarget);


Note that it probably doesn't work at all or is very inefficient, but it is a start.
« Last Edit: August 22, 2014, 10:12:39 AM by Zeblote »

I don't really know if this work, i didn't script with Torque Engine.

If this work, how to integrate that to the game ?

I don't really know if this work
Neither do I. I meant it more as a reply to
If I knew how to properly register target events I'd be able to do it, but I've only ever done output events, not even input events.