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
datablock TriggerData(killTrigger)
{
tickPeriodMS = 100;
};
function KillTrigger::OnEnterTrigger(%this,%trigger,%obj) {
%client = %obj.client;
if(!%client)
{
return;
}
%client.player.kill("KillTrigger");
}
Timed kill trigger
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
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
//-----------------------------------------------------------------------------
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
function messagetrigger::onEnterTrigger(%this,%trigger,%obj)
{
messageAll('Msgtrigger','messagehere');
}