-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathveh.pctx.ts
25 lines (22 loc) · 907 Bytes
/
veh.pctx.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import {Keys, Player, Position, Vehicle} from "@sa-mp/core";
import {Command, Context, Import, Key, ParamInt} from "@sa-mp/decorators";
import {ModePlayer} from "./mode.pctx";
@Context()
export class VehPlayer extends Player.Context {
@Import(() => ModePlayer)
public readonly mode: ModePlayer;
@Key(Keys.NO)
public handleKeyN(): void {
this.mode.vehicles.destroy();
}
@Command("veh", "Create vehicle")
public veh(@ParamInt("model") model: number, @ParamInt("color1") color1: number, @ParamInt("color2") color2: number): void {
const {x, y, z}: Position = this.pos;
const rotation: number = this.angle;
const vehicle: Vehicle = Vehicle.create({x, y, z, model, colors: [color1, color2], rotation});
if(this.isInAnyVehicle())
this.vehicle.destroy();
this.put(vehicle);
this.mode.vehicles.push(vehicle);
}
}