Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
F7キーを押したら車を生成する
using System;
using System.Windows.Forms;
using GTA;
using GTA.Math;
using GTA.Native;
/// <summary>
/// F7キーが押された時にブリスタをプレイヤの近くに出現させる
/// </summary>
public class VehicleSpanwer : Script
{
public VehicleSpanwer()
{
//キー入力イベントにHook
KeyDown += VehicleSpanwerKeyDown;
}
private void VehicleSpanwerKeyDown(object sender, KeyEventArgs e)
{
//押されたキーがF7以外なら何もしない
if (e.KeyCode != Keys.F7) return;
//プレイヤを取得
var player = Game.Player.Character;
//プレイヤの現在座標を取得
var currentPlayerPosition = player.Position;
//プレイヤの5m隣にブリスタを出現させる
World.CreateVehicle(new Model(VehicleHash.Blista), currentPlayerPosition + new Vector3(5, 0, 0));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment