Author Topic: Mission editor triggers freebies  (Read 2202 times)

If you dont know what a trigger is, Triggers are purple boxes spawned in f11>f4>mission>trigger. When you go in it, something happens according to the script. Its how Iks made those challenges.

Kill trigger
Code: [Select]
datablock TriggerData(killTrigger)
{
tickPeriodMS = 100;
};

function KillTrigger::OnEnterTrigger(%this,%trigger,%obj) { 
  %client = %obj.client;
  if(!%client)
  {
    return;
  }
  %client.player.kill("KillTrigger");
}

Timed kill trigger

Code: [Select]
datablock TriggerData(timedKillTrigger)
{
tickPeriodMS = 100;
};

function timedKillTrigger::onEnterTrigger(%this,%trigger,%obj)
{
  %client = %obj.client;
  if(!%client)
  {
    return;
  }
  $timekill = %client.player.schedule(3000,"kill");
}
function timedKillTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
  %client = %obj.client;
  if(!%client)
  {
    return;
  }
  cancel($timekill);
}

Speed Trigger

Code: [Select]
datablock TriggerData(Grav)
{
tickPeriodMS = 100;
};

//------------------------------------------------

function Grav::onEnterTrigger(%this,%trigger,%obj)
{
%obj.modifyMaxSpeed(5.0);
schedule(10000,0,"restoreVelocity",%obj);
CommandToClient(%obj.client,'BottomPrint',"You have recived speed boots, your speed is now 5 times as fast as you used to be.",5,1);
///messageClient(%obj.client, 'MsgSpeed', '\c4Speed Up!');
}

function restoreVelocity(%obj)
{
%obj.modifyMaxSpeed(1.0);
commandToClient(%obj.client,'BottomPrint',"Your speed boots have worn out.",5,1);
}


Heal trigger
Code: [Select]
//-----------------------------------------------------------------------------

datablock TriggerData(HealTrigger)
{
// The period is value is used to control how often the console
// onTriggerTick callback is called while there are any objects
// in the trigger. The default value is 100 MS.
tickPeriodMS = 100;
};

function HealTrigger::OnEnterTrigger(%this,%trigger,%obj) {
%healEffect = new StaticShape(healEffect)
    {
       dataBlock = GhostReviveEffect;
    };
    %healEffect.setTransform(%obj.getTransform());

    ServerPlay3D(SpawnInSound,%obj.getTransform());
%checkname = %trigger.getName();
%client = %obj.client;
if(!%client)
{
echo("not a client!");
return;
}

%client.player.healpointing = 1;
CommandToClient(%client,'bottomprint'," Healing activated",5,1);
HealSched(%trigger,%client);
}

function HealSched(%trigger,%client) {
if (%client.player.getDamageLevel() > 0) {
%client.player.setDamageLevel(%client.player.getDamageLevel() - 0.2);
%client.player.healsched = schedule(10,0,"HealSched",%trigger,%client);
} else {
CommandToClient(%client,'bottomprint'," Healing complete",5,1);
%client.player.healpointing = 0;
}
}

function HealTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
%checkname = %trigger.getName();
%client = %obj.client;
if(!%client)
{
return;
}
if (%client.player.healpointing == 1) {
cancel(%client.player.healsched);
CommandToClient(%client,'bottomprint'," Healing stopped...",5,1);
%client.player.healpointing = 0;
} else
%client.player.healpointing = 0;
}


Message Trigger

Code: [Select]
function messagetrigger::onEnterTrigger(%this,%trigger,%obj)
{
messageAll('Msgtrigger','messagehere');

}

« Last Edit: April 28, 2008, 04:53:50 PM by Peaceful War »

Can I ask why he was banned? Is this violating a rule?

Can I ask why he was banned? Is this violating a rule?
« Last Edit: Today at 04:17:24 PM by Peaceful War »

It's been done before, and isn't funny. Badspot really banned someone for it.

Pretty useful resource; I was just messing with triggers the other day.