weaponschein fertig
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Core.Extensions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Core.Menus
|
||||
{
|
||||
@@ -15,6 +16,42 @@ namespace ReallifeGamemode.Server.Core.Menus
|
||||
// Marker position: 440.869 -981.045 30.689
|
||||
|
||||
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()
|
||||
@@ -22,8 +59,8 @@ namespace ReallifeGamemode.Server.Core.Menus
|
||||
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.Marker.CreateMarker(MarkerType.VerticalCylinder, pos.Subtract(new Position(0, 0, 1.5)), new Position(), new Position(), 1f, new Color());
|
||||
IColShape colShape = Api.ColShape.CreateSphere(pos.Subtract(new Position(0, 0, 1.5)), 3f);
|
||||
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, 2f);
|
||||
|
||||
colShape.OnEntityEnter += OnPlayerEnterPoliceDepartment;
|
||||
colShape.OnEntityExit += OnPlayerExitPoliceDepartment;
|
||||
@@ -31,12 +68,12 @@ namespace ReallifeGamemode.Server.Core.Menus
|
||||
|
||||
private void OnPlayerEnterPoliceDepartment(IColShape colShape, IPlayer player)
|
||||
{
|
||||
|
||||
player.TriggerEvent("PoliceDepartment_EnterColShape");
|
||||
}
|
||||
|
||||
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.Core.API\ReallifeGamemode.Server.Core.API.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.Types\ReallifeGamemode.Server.Types.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Log;
|
||||
|
||||
@@ -9,13 +10,17 @@ namespace ReallifeGamemode.Server.Core
|
||||
{
|
||||
internal abstract class Script
|
||||
{
|
||||
protected IAPI Api { get; } = Main.API;
|
||||
protected IAPI Api => Main.API;
|
||||
|
||||
protected ILogger Log { get; }
|
||||
|
||||
protected Events.EventHandler EventHandler => Main.EventHandler;
|
||||
|
||||
public Script()
|
||||
{
|
||||
Log = LogManager.GetLogger(GetType());
|
||||
}
|
||||
|
||||
protected DatabaseContext GetDbContext() => Main.GetDbContext();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user