Skip to content

Instantly share code, notes, and snippets.

@TORISOUP
Created September 25, 2015 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TORISOUP/00f01522b23f18123655 to your computer and use it in GitHub Desktop.
Save TORISOUP/00f01522b23f18123655 to your computer and use it in GitHub Desktop.
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