Files

55 lines
1.8 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.
# ezoic_radyasyon.js — boyun_kir() (satır 95)
[← ezoic_radyasyon.js](index.md) · [← Master](../../wiki.md)
```javascript
function boyun_kir(c) {
var player = c.getSubject();
if (!checkPermission(player)) return;
var pos = player.getPosition();
var players = c.getServer().getEntities("@a");
var target = null;
var minDist = Config.CameraLockRadius;
for each (var p in players) {
if (p.getName() === player.getName()) continue;
var pPos = p.getPosition();
var dist = Math.sqrt(Math.pow(pos.x-pPos.x,2) + Math.pow(pos.y-pPos.y,2) + Math.pow(pos.z-pPos.z,2));
if (dist < minDist) {
minDist = dist;
target = p;
}
}
if (!target) {
player.send("§cYakında kilitlenecek oyuncu yok!");
return;
}
player.send("§a" + target.getName() + " adlı oyuncunun boynu kırıldı ve sana kilitlendi!");
target.send("§cBirisi boynunu kilitledi! Ona bakmaktan kendini alamıyorsun.");
var ticks = 0;
function lockLoop(context) {
if (ticks > Config.CameraLockDuration) return;
ticks++;
try {
var myPos = player.getPosition();
var tPos = target.getPosition();
var dx = myPos.x - tPos.x;
var dy = (myPos.y + player.getEyeHeight()) - (tPos.y + target.getEyeHeight());
var dz = myPos.z - tPos.z;
var yaw = Math.atan2(dz, dx) * 180 / Math.PI - 90;
var distXZ = Math.sqrt(dx*dx + dz*dz);
var pitch = -Math.atan2(dy, distXZ) * 180 / Math.PI;
target.setRotations(pitch, yaw, yaw);
} catch(e) {}
context.scheduleScript(1, lockLoop);
}
c.scheduleScript(1, lockLoop);
}
```