RinaV

Genel => Araştırma & Geliştirme => Okunmuş AR&GE => Konuyu başlatan: Hybris - 06 Şubat 2025, 15:03:58

Başlık: Basketbol sistemi
Gönderen: Hybris - 06 Şubat 2025, 15:03:58
Sunucuda basketbol sistemi olsa rollerin çeşitleneceğini düşünüyorum haritada birçok yerde basketbol sahaları var ama hepsi boş kullanılmıyor bu sistemin gelmesi ile birlikte sokak basketbolunun artacağını düşünüyorum ve insanlar bahisli basketbol bile oynayabilir aşşağıya fikir olması için kısa bir kod bırakacağım :)

(https://forum-cfx-re.akamaized.net/original/4X/f/7/7/f77c8dd27e5a3cd8b2d2ea22e97aa563432ac2bd.jpeg)

mp.objects.new(
  'prop_hoop_01', // Pota model hash'i (GTA V objesi)
  new mp.Vector3(-265.8, -930.4, 91.2), // Konum
  {
    rotation: new mp.Vector3(0, 0, 0),
    dimension: 0
  }
);

// Basketbol topu oluştur
const basketball = mp.objects.new(
  'prop_bskball_01', // Basketbol topu model hash'i
  new mp.Vector3(-265.8, -930.4, 92.0), // Potanın önüne yerleştir
  {
    dimension: 0
  }
);

let isHoldingBall = false;
let basketballEntity = null;

// Topu alma tuşu (E)
mp.keys.bind(0x45, true, () => {
  if (!isHoldingBall) {
    // Topa yakınsa al
    const playerPos = mp.players.local.position;
    const ballPos = basketballEntity.position;
   
    if (playerPos.distanceTo(ballPos) < 2.0) {
      isHoldingBall = true;
      mp.events.callRemote('pickup_basketball');
    }
  }
});

// Atış yapma (Fare sol tık)
mp.keys.bind(0x01, false, () => {
  if (isHoldingBall) {
    // Topu fırlat
    const force = 15.0; // Atış gücü
    mp.events.callRemote('shoot_basketball', force);
    isHoldingBall = false;
  }
});

// Sunucu tarafında
mp.events.add('shoot_basketball', (player, force) => {
  // Topun pozisyonunu sürekli kontrol et
  const ballInterval = setInterval(() => {
    const ballPos = basketball.position;
    const hoopPos = new mp.Vector3(-265.8, -930.4, 91.2); // Pota konumu

    // Top potanın içinden geçti mi?
    if (
      ballPos.x > hoopPos.x - 0.5 &&
      ballPos.x < hoopPos.x + 0.5 &&
      ballPos.y > hoopPos.y - 0.5 &&
      ballPos.y < hoopPos.y + 0.5 &&
      ballPos.z > hoopPos.z
    ) {
      clearInterval(ballInterval);
      player.call('add_score'); // Skor artır
      player.outputChatBox('⚡ Sayı! +3 Puan!');
    }
  }, 100);
});

// Sunucu tarafında
mp.events.add('shoot_basketball', (player, force) => {
  const playerPos = player.position;
  const forwardVector = player.getForwardVector(); // Oyuncunun baktığı yön

  // Topa fiziksel kuvvet uygula
  basketball.velocity = new mp.Vector3(
    forwardVector.x * force,
    forwardVector.y * force,
    forwardVector.z * force + 5.0 // Yukarı doğru hafif bir kuvvet
  );
});

<!-- client/cef/score.html -->
<div id="scoreboard">
  <p>Skor: <span id="score">0</span></p>
</div>

<script>
  document.addEventListener('DOMContentLoaded', () => {
    mp.events.add('update_score', (score) => {
      document.getElementById('score').textContent = score;
    });
  });
</script>
 
Başlık: Ynt: Basketbol sistemi
Gönderen: Sizophrens - 06 Şubat 2025, 17:04:11
Olabilir, çıtır etkinlikler iyidir.

Başlık: Ynt: Basketbol sistemi
Gönderen: Garen - 06 Şubat 2025, 17:06:32
:like:
Başlık: Ynt: Basketbol sistemi
Gönderen: notime2cry - 06 Şubat 2025, 19:04:04
 :like:
Başlık: Ynt: Basketbol sistemi
Gönderen: Patron Bebek - 06 Şubat 2025, 21:01:20
şu kodu çalıştırıp atsana merak ettim
Başlık: Ynt: Basketbol sistemi
Gönderen: Bill_Twisted - 08 Şubat 2025, 21:03:59
olur
Başlık: Ynt: Basketbol sistemi
Gönderen: ar.tun - 08 Şubat 2025, 21:16:13
Çeteler arasında sosyal bir rol yaratmak için güzel bir sistem, destek.
Başlık: Ynt: Basketbol sistemi
Gönderen: unvoidead - 10 Şubat 2025, 07:49:52
harıka olur
Başlık: Ynt: Basketbol sistemi
Gönderen: Police Sergeant II Richard Hawkings - 10 Şubat 2025, 15:47:39
Animasyonlu sistemi pek mümkün değil fakat rolsel olarak /dene sistemiyle daha önce rollerini yapıyordum şahsen. /dene sistemi ile yapılması yerine belirli bir düzende, kuralları ile birlikte; sistemsel yapılması çok iyi olacaktır.
Tam destek!