weaponschein fertig
This commit is contained in:
41
ReallifeGamemode.Client/Gui/policedepartment.ts
Normal file
41
ReallifeGamemode.Client/Gui/policedepartment.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import game from "..";
|
||||||
|
import { Key } from "../game";
|
||||||
|
import { Menu, Point, UIMenuItem } from "../libs/NativeUI";
|
||||||
|
import { createMenuItem } from "../util";
|
||||||
|
import moneyformat from "../moneyformat";
|
||||||
|
|
||||||
|
var menu: Menu = new Menu("Polizeirevier", "Die Hilfestelle der Polizei", new Point(50, 50));
|
||||||
|
|
||||||
|
menu.AddItem(createMenuItem("Waffenschein kaufen", "Erwerbe einen Waffenschein", (item) => {
|
||||||
|
item.SetRightLabel("$" + moneyformat(5000));
|
||||||
|
}));
|
||||||
|
|
||||||
|
menu.Close();
|
||||||
|
|
||||||
|
menu.ItemSelect.on((item, index: number) => {
|
||||||
|
game.events.callServer("PoliceDepartment_MenuSelect", index);
|
||||||
|
menu.Close();
|
||||||
|
});
|
||||||
|
|
||||||
|
menu.MenuClose.on(() => {
|
||||||
|
game.ui.inMenu = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
game.events.add("SERVER:PoliceDepartment_EnterColShape", () => {
|
||||||
|
game.ui.setHelpText("Drücke ~INPUT_CONTEXT~, um das Menü des Polizeireviers zu öffnen");
|
||||||
|
|
||||||
|
game.events.bindKey(Key.E, false, keyPressHandler);
|
||||||
|
});
|
||||||
|
|
||||||
|
game.events.add("SERVER:PoliceDepartment_ExitColShape", () => {
|
||||||
|
game.ui.clearHelpText();
|
||||||
|
game.events.unbindKey(Key.E, false, keyPressHandler);
|
||||||
|
|
||||||
|
menu.Close();
|
||||||
|
});
|
||||||
|
|
||||||
|
function keyPressHandler() {
|
||||||
|
game.ui.clearHelpText();
|
||||||
|
game.ui.inMenu = true;
|
||||||
|
menu.Open();
|
||||||
|
}
|
||||||
@@ -141,6 +141,7 @@ export default function keys(globalData: GlobalData) {
|
|||||||
|
|
||||||
//2 // Job Starten
|
//2 // Job Starten
|
||||||
mp.keys.bind(0x4A, false, () => {
|
mp.keys.bind(0x4A, false, () => {
|
||||||
|
mp.gui.chat.push("inchat: " + globalData.InChat + " inInput: " + globalData.InInput + " inMenu: " + globalData.InMenu + " LoggedIn: " + globalData.LoggedIn);
|
||||||
if (!globalData.InChat && !globalData.InInput && !globalData.InMenu && globalData.LoggedIn) {
|
if (!globalData.InChat && !globalData.InInput && !globalData.InMenu && globalData.LoggedIn) {
|
||||||
mp.events.callRemote("CLIENT:JobManager_ShowJobMenu");
|
mp.events.callRemote("CLIENT:JobManager_ShowJobMenu");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<p id="0"></p>
|
<p id="0"></p>
|
||||||
<p id="1"></p>
|
<p id="1"></p>
|
||||||
<p id="2"></p>
|
<p id="2"></p>
|
||||||
|
<p id="3"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,15 @@ function add_licenses(info) {
|
|||||||
console.log(infoArr);
|
console.log(infoArr);
|
||||||
for (var i = 0; i < infoArr.length; i++) {
|
for (var i = 0; i < infoArr.length; i++) {
|
||||||
var Schein = "";
|
var Schein = "";
|
||||||
if (infoArr[i] == true) {
|
if (infoArr[i] === true) {
|
||||||
if (i == 0) {
|
if (i === 0) {
|
||||||
Schein = "Auto";
|
Schein = "Auto";
|
||||||
} else if (i == 1) {
|
} else if (i === 1) {
|
||||||
Schein = "Motorrad";
|
Schein = "Motorrad";
|
||||||
} else if (i == 2) {
|
} else if (i === 2) {
|
||||||
Schein = "Flugzeug";
|
Schein = "Flugzeug";
|
||||||
|
} else if (i === 3) {
|
||||||
|
Schein = "Waffen";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$('#'+i).append(""+Schein);
|
$('#'+i).append(""+Schein);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default class RageEvents implements IEvents {
|
|||||||
}
|
}
|
||||||
|
|
||||||
callServer(event: string, args?: any[] | any): void {
|
callServer(event: string, args?: any[] | any): void {
|
||||||
if (args) {
|
if (args !== null) {
|
||||||
if (typeof args === 'object') {
|
if (typeof args === 'object') {
|
||||||
args.push(event);
|
args.push(event);
|
||||||
} else {
|
} else {
|
||||||
@@ -41,7 +41,10 @@ export default class RageEvents implements IEvents {
|
|||||||
} else {
|
} else {
|
||||||
args = [event];
|
args = [event];
|
||||||
}
|
}
|
||||||
mp.events.callRemote('CLIENT:Event', JSON.stringify(args));
|
|
||||||
|
var params = JSON.stringify(args);
|
||||||
|
|
||||||
|
mp.events.callRemote('CLIENT:Event', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
bindKey(key: Key, hold: boolean, callback: Function) {
|
bindKey(key: Key, hold: boolean, callback: Function) {
|
||||||
|
|||||||
@@ -2,6 +2,14 @@ import { IUi, IBrowser } from "../../game";
|
|||||||
import { Menu } from "../../libs/NativeUI/index";
|
import { Menu } from "../../libs/NativeUI/index";
|
||||||
|
|
||||||
export default class RageUi implements IUi {
|
export default class RageUi implements IUi {
|
||||||
|
setHelpText(text: string): void {
|
||||||
|
mp.game.ui.setTextComponentFormat('STRING');
|
||||||
|
mp.game.ui.addTextComponentSubstringPlayerName(text);
|
||||||
|
mp.game.ui.displayHelpTextFromStringLabel(0, true, true, -1);
|
||||||
|
}
|
||||||
|
clearHelpText(): void {
|
||||||
|
mp.game.ui.clearHelp(true);
|
||||||
|
}
|
||||||
private _inMenu: boolean = false;
|
private _inMenu: boolean = false;
|
||||||
private _activeMenu: Menu = null;
|
private _activeMenu: Menu = null;
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ interface IUi {
|
|||||||
openBrower(path: string): IBrowser;
|
openBrower(path: string): IBrowser;
|
||||||
setCursor(freeze: boolean, show: boolean): void;
|
setCursor(freeze: boolean, show: boolean): void;
|
||||||
toggleChat(toggle: boolean): void;
|
toggleChat(toggle: boolean): void;
|
||||||
|
setHelpText(text: string): void;
|
||||||
|
clearHelpText(): void;
|
||||||
inMenu: boolean;
|
inMenu: boolean;
|
||||||
inChat: boolean;
|
inChat: boolean;
|
||||||
}
|
}
|
||||||
@@ -98,7 +100,8 @@ enum Key {
|
|||||||
ENTER = 0x0D,
|
ENTER = 0x0D,
|
||||||
M = 0x4D,
|
M = 0x4D,
|
||||||
T = 0x54,
|
T = 0x54,
|
||||||
X = 0x58
|
X = 0x58,
|
||||||
|
E = 0x45
|
||||||
}
|
}
|
||||||
|
|
||||||
enum VehicleSeat {
|
enum VehicleSeat {
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ import smoothThrottle from './vehiclesync/smoothtrottle';
|
|||||||
smoothThrottle();
|
smoothThrottle();
|
||||||
|
|
||||||
import vehicleIndicators from './vehiclesync/vehicleindicators';
|
import vehicleIndicators from './vehiclesync/vehicleindicators';
|
||||||
vehicleIndicators();
|
vehicleIndicators();
|
||||||
|
|
||||||
import reportList from './Player/reportmenu';
|
import reportList from './Player/reportmenu';
|
||||||
reportList(globalData);
|
reportList(globalData);
|
||||||
@@ -202,6 +202,8 @@ itemShopList(globalData);
|
|||||||
import taximeterInput from './Gui/taximeter';
|
import taximeterInput from './Gui/taximeter';
|
||||||
taximeterInput(globalData);
|
taximeterInput(globalData);
|
||||||
|
|
||||||
|
require('./Gui/policedepartment');
|
||||||
|
|
||||||
interface VehicleData {
|
interface VehicleData {
|
||||||
EngineState: boolean;
|
EngineState: boolean;
|
||||||
Locked: boolean;
|
Locked: boolean;
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ namespace ReallifeGamemode.Database.Entities
|
|||||||
|
|
||||||
public bool DriverLicenseBike { get; set; } = false;
|
public bool DriverLicenseBike { get; set; } = false;
|
||||||
|
|
||||||
|
public bool WeaponLicense { get; set; } = false;
|
||||||
|
|
||||||
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
||||||
|
|
||||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||||
|
|||||||
1428
ReallifeGamemode.Database/Migrations/20200313203304_UserWeaponLicense.Designer.cs
generated
Normal file
1428
ReallifeGamemode.Database/Migrations/20200313203304_UserWeaponLicense.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class UserWeaponLicense : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "WeaponLicense",
|
||||||
|
table: "Users",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "WeaponLicense",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1026,6 +1026,8 @@ namespace ReallifeGamemode.Database.Migrations
|
|||||||
|
|
||||||
b.Property<int>("Wanteds");
|
b.Property<int>("Wanteds");
|
||||||
|
|
||||||
|
b.Property<bool>("WeaponLicense");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("BanId");
|
b.HasIndex("BanId");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using ReallifeGamemode.Server.Core.API;
|
using ReallifeGamemode.Server.Core.API;
|
||||||
using ReallifeGamemode.Server.Types;
|
using ReallifeGamemode.Server.Types;
|
||||||
|
using ReallifeGamemode.Server.Core.Extensions;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Core.Menus
|
namespace ReallifeGamemode.Server.Core.Menus
|
||||||
{
|
{
|
||||||
@@ -15,6 +16,42 @@ namespace ReallifeGamemode.Server.Core.Menus
|
|||||||
// Marker position: 440.869 -981.045 30.689
|
// Marker position: 440.869 -981.045 30.689
|
||||||
|
|
||||||
CreateVisuals();
|
CreateVisuals();
|
||||||
|
|
||||||
|
EventHandler.RegisterClientEvent("PoliceDepartment_MenuSelect", OnMenuSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMenuSelect(IPlayer player, object[] args)
|
||||||
|
{
|
||||||
|
var index = (long)args[0];
|
||||||
|
|
||||||
|
using (var dbContext = GetDbContext())
|
||||||
|
{
|
||||||
|
var user = player.GetUser(dbContext);
|
||||||
|
|
||||||
|
if (index == 0)
|
||||||
|
{
|
||||||
|
if (user.WeaponLicense)
|
||||||
|
{
|
||||||
|
player.SendMessage("Du besitzt schon einen Waffenschein.", ChatPrefix.Info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var account = user.GetBankAccount(dbContext);
|
||||||
|
|
||||||
|
if (account.Balance < 5000)
|
||||||
|
{
|
||||||
|
player.SendMessage("Du hast nicht genug Geld auf der Bank (5.000$)!", ChatPrefix.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
account.Balance -= 5000;
|
||||||
|
|
||||||
|
player.SendMessage("Du hast den Waffenschein erfolgreich erworben.", ChatPrefix.Info);
|
||||||
|
|
||||||
|
user.WeaponLicense = true;
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateVisuals()
|
private void CreateVisuals()
|
||||||
@@ -22,8 +59,8 @@ namespace ReallifeGamemode.Server.Core.Menus
|
|||||||
Position pos = new Position(440.869, -981.045, 30.689);
|
Position pos = new Position(440.869, -981.045, 30.689);
|
||||||
|
|
||||||
Api.TextLabel.CreateTextLabel("Polizeirevier\n\nDrücke ~y~E~s~, um das Menü zu öffnen", pos, 20f, 1.3f, Font.ChaletLondon, Color.White);
|
Api.TextLabel.CreateTextLabel("Polizeirevier\n\nDrücke ~y~E~s~, um das Menü zu öffnen", pos, 20f, 1.3f, Font.ChaletLondon, Color.White);
|
||||||
Api.Marker.CreateMarker(MarkerType.VerticalCylinder, pos.Subtract(new Position(0, 0, 1.5)), new Position(), new Position(), 1f, new Color());
|
Api.Marker.CreateMarker(MarkerType.VerticalCylinder, pos.Subtract(new Position(0, 0, 1.7)), new Position(), new Position(), 1f, Color.White);
|
||||||
IColShape colShape = Api.ColShape.CreateSphere(pos.Subtract(new Position(0, 0, 1.5)), 3f);
|
IColShape colShape = Api.ColShape.CreateSphere(pos, 2f);
|
||||||
|
|
||||||
colShape.OnEntityEnter += OnPlayerEnterPoliceDepartment;
|
colShape.OnEntityEnter += OnPlayerEnterPoliceDepartment;
|
||||||
colShape.OnEntityExit += OnPlayerExitPoliceDepartment;
|
colShape.OnEntityExit += OnPlayerExitPoliceDepartment;
|
||||||
@@ -31,12 +68,12 @@ namespace ReallifeGamemode.Server.Core.Menus
|
|||||||
|
|
||||||
private void OnPlayerEnterPoliceDepartment(IColShape colShape, IPlayer player)
|
private void OnPlayerEnterPoliceDepartment(IColShape colShape, IPlayer player)
|
||||||
{
|
{
|
||||||
|
player.TriggerEvent("PoliceDepartment_EnterColShape");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPlayerExitPoliceDepartment(IColShape colShape, IPlayer player)
|
private void OnPlayerExitPoliceDepartment(IColShape colShape, IPlayer player)
|
||||||
{
|
{
|
||||||
|
player.TriggerEvent("PoliceDepartment_ExitColShape");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<ProjectReference Include="..\ReallifeGamemode.Server.Common\ReallifeGamemode.Server.Common.csproj" />
|
<ProjectReference Include="..\ReallifeGamemode.Server.Common\ReallifeGamemode.Server.Common.csproj" />
|
||||||
<ProjectReference Include="..\ReallifeGamemode.Server.Core.API\ReallifeGamemode.Server.Core.API.csproj" />
|
<ProjectReference Include="..\ReallifeGamemode.Server.Core.API\ReallifeGamemode.Server.Core.API.csproj" />
|
||||||
<ProjectReference Include="..\ReallifeGamemode.Server.Core.Events\ReallifeGamemode.Server.Core.Events.csproj" />
|
<ProjectReference Include="..\ReallifeGamemode.Server.Core.Events\ReallifeGamemode.Server.Core.Events.csproj" />
|
||||||
|
<ProjectReference Include="..\ReallifeGamemode.Server.Core.Extensions\ReallifeGamemode.Server.Core.Extensions.csproj" />
|
||||||
<ProjectReference Include="..\ReallifeGamemode.Server.Log\ReallifeGamemode.Server.Log.csproj" />
|
<ProjectReference Include="..\ReallifeGamemode.Server.Log\ReallifeGamemode.Server.Log.csproj" />
|
||||||
<ProjectReference Include="..\ReallifeGamemode.Server.Types\ReallifeGamemode.Server.Types.csproj" />
|
<ProjectReference Include="..\ReallifeGamemode.Server.Types\ReallifeGamemode.Server.Types.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ReallifeGamemode.Database.Models;
|
||||||
using ReallifeGamemode.Server.Core.API;
|
using ReallifeGamemode.Server.Core.API;
|
||||||
using ReallifeGamemode.Server.Log;
|
using ReallifeGamemode.Server.Log;
|
||||||
|
|
||||||
@@ -9,13 +10,17 @@ namespace ReallifeGamemode.Server.Core
|
|||||||
{
|
{
|
||||||
internal abstract class Script
|
internal abstract class Script
|
||||||
{
|
{
|
||||||
protected IAPI Api { get; } = Main.API;
|
protected IAPI Api => Main.API;
|
||||||
|
|
||||||
protected ILogger Log { get; }
|
protected ILogger Log { get; }
|
||||||
|
|
||||||
|
protected Events.EventHandler EventHandler => Main.EventHandler;
|
||||||
|
|
||||||
public Script()
|
public Script()
|
||||||
{
|
{
|
||||||
Log = LogManager.GetLogger(GetType());
|
Log = LogManager.GetLogger(GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DatabaseContext GetDbContext() => Main.GetDbContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
|
|
||||||
if (type == "License")
|
if (type == "License")
|
||||||
{
|
{
|
||||||
if (!playerUser.DriverLicenseBike && !playerUser.DriverLicenseVehicle && !playerUser.FlyingLicensePlane)
|
if (!playerUser.DriverLicenseBike && !playerUser.DriverLicenseVehicle && !playerUser.FlyingLicensePlane && !playerUser.WeaponLicense)
|
||||||
{
|
{
|
||||||
player.SendNotification("~r~Sie besitzen keine Scheine!");
|
player.SendNotification("~r~Sie besitzen keine Scheine!");
|
||||||
return;
|
return;
|
||||||
@@ -158,6 +158,7 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
licenses.Add(playerUser.DriverLicenseVehicle);
|
licenses.Add(playerUser.DriverLicenseVehicle);
|
||||||
licenses.Add(playerUser.DriverLicenseBike);
|
licenses.Add(playerUser.DriverLicenseBike);
|
||||||
licenses.Add(playerUser.FlyingLicensePlane);
|
licenses.Add(playerUser.FlyingLicensePlane);
|
||||||
|
licenses.Add(playerUser.WeaponLicense);
|
||||||
target.TriggerEvent("ShowLicenses", player.Name, licenses.ToArray());
|
target.TriggerEvent("ShowLicenses", player.Name, licenses.ToArray());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user