Files

70 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MercanRey5.js — loop() (satır 164)
[← MercanRey5.js](index.md) · [← Master](../../wiki.md)
```javascript
function loop(c, runId)
{
var state = mappet.get(STATE_KEY);
if (state == null || Number(state.runId) !== Number(runId))
{
return;
}
var caster = c.getServer().getEntity(String(state.caster));
if (caster == null || !caster.isPlayer())
{
mappet.set(STATE_KEY, null);
return;
}
var frozen = state.frozen || {};
var ticks = Number(state.ticks || 0) + INTERVAL;
applyPotion(caster, ["speed"], 12, 2);
applyPotion(caster, ["resistance"], 12, 1);
applyPotion(caster, ["night_vision"], 140, 0);
caster.sendActionBar("Jaque Mate: karar penceresi " + Math.max(0, Math.ceil((DURATION - ticks) / 20)) + "s");
for (var uuid in frozen)
{
if (!Object.prototype.hasOwnProperty.call(frozen, uuid))
{
continue;
}
var entity = c.getServer().getEntity(String(uuid));
if (entity != null && entity.isLivingBase())
{
freezeEntity(entity, frozen[uuid]);
}
}
if (ticks >= DURATION)
{
for (var releaseUuid in frozen)
{
if (!Object.prototype.hasOwnProperty.call(frozen, releaseUuid))
{
continue;
}
releaseEntity(c.getServer().getEntity(String(releaseUuid)), frozen[releaseUuid]);
}
caster.send("Jaque Mate, se acabo el juego.");
mappet.set(STATE_KEY, null);
return;
}
saveState(caster, runId, ticks, frozen);
c.scheduleScript(INTERVAL, function (context)
{
loop(context, runId);
});
}
```