formatted code
This commit is contained in:
@@ -14,9 +14,9 @@ import moneyFormat from '../moneyformat';
|
|||||||
|
|
||||||
export default function carDealer() {
|
export default function carDealer() {
|
||||||
|
|
||||||
var shopMenu;
|
var shopMenu: NativeUI.Menu;
|
||||||
|
|
||||||
mp.events.add('ShopVehicle_OpenMenu', (businessName, price) => {
|
mp.events.add('ShopVehicle_OpenMenu', (businessName, price, availableOptions: string[]) => {
|
||||||
var veh = mp.players.local.vehicle;
|
var veh = mp.players.local.vehicle;
|
||||||
if (!veh) return;
|
if (!veh) return;
|
||||||
mp.gui.chat.show(false);
|
mp.gui.chat.show(false);
|
||||||
@@ -34,6 +34,10 @@ export default function carDealer() {
|
|||||||
priceItem.SetRightLabel("~g~$~s~ " + moneyFormat(price));
|
priceItem.SetRightLabel("~g~$~s~ " + moneyFormat(price));
|
||||||
shopMenu.AddItem(priceItem);
|
shopMenu.AddItem(priceItem);
|
||||||
|
|
||||||
|
var targetsCollection = new ItemsCollection(availableOptions);
|
||||||
|
var targetItem = new UIMenuListItem("Besitzer", "W<>hle den Besitzer aus", targetsCollection);
|
||||||
|
shopMenu.AddItem(targetItem);
|
||||||
|
|
||||||
var saveItem = new UIMenuItem("Kaufen");
|
var saveItem = new UIMenuItem("Kaufen");
|
||||||
saveItem.BackColor = new Color(0, 100, 0);
|
saveItem.BackColor = new Color(0, 100, 0);
|
||||||
saveItem.HighlightedBackColor = new Color(0, 150, 0);
|
saveItem.HighlightedBackColor = new Color(0, 150, 0);
|
||||||
@@ -48,7 +52,7 @@ export default function carDealer() {
|
|||||||
if (item === cancelItem) {
|
if (item === cancelItem) {
|
||||||
shopMenu.Close();
|
shopMenu.Close();
|
||||||
} else if (item === saveItem) {
|
} else if (item === saveItem) {
|
||||||
mp.events.callRemote("VehShop_BuyVehicle");
|
mp.events.callRemote("VehShop_BuyVehicle", targetItem.SelectedItem.Id);
|
||||||
shopMenu.Close();
|
shopMenu.Close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ namespace ReallifeGamemode.Server.Entities
|
|||||||
[Key]
|
[Key]
|
||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int Balance {
|
public int Balance
|
||||||
|
{
|
||||||
get => _balance;
|
get => _balance;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
using System;
|
using ReallifeGamemode.Server.Models;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Entities
|
namespace ReallifeGamemode.Server.Entities
|
||||||
@@ -8,6 +11,17 @@ namespace ReallifeGamemode.Server.Entities
|
|||||||
{
|
{
|
||||||
public Group Group { get; set; }
|
public Group Group { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("Group")]
|
||||||
|
public int? GroupId { get; set; }
|
||||||
|
|
||||||
|
public Group GetGroup()
|
||||||
|
{
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
return dbContext.Groups.Where(g => g.Id == GroupId).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return "Gruppen Fahrzeug | Gruppe: " + Group.Name;
|
return "Gruppen Fahrzeug | Gruppe: " + Group.Name;
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ namespace ReallifeGamemode.Server.Entities
|
|||||||
veh.Position.Add(new Vector3(0, 0, 1.3)), 10.0f, 1f, 1, new Color(255, 255, 255));
|
veh.Position.Add(new Vector3(0, 0, 1.3)), 10.0f, 1f, 1, new Color(255, 255, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this is GroupVehicle gV)
|
||||||
|
{
|
||||||
|
numberplate = $"{gV.GroupId}" + numberplate;
|
||||||
|
}
|
||||||
|
|
||||||
veh.NumberPlate = numberplate;
|
veh.NumberPlate = numberplate;
|
||||||
|
|
||||||
return veh;
|
return veh;
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ namespace ReallifeGamemode.Server.Entities
|
|||||||
|
|
||||||
public Group Group { get; set; }
|
public Group Group { get; set; }
|
||||||
|
|
||||||
|
public GroupRank GroupRank { get; set; }
|
||||||
|
|
||||||
public FactionRank GetFactionRank()
|
public FactionRank GetFactionRank()
|
||||||
{
|
{
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ namespace ReallifeGamemode.Server.Entities
|
|||||||
public string Bic { get; set; }
|
public string Bic { get; set; }
|
||||||
[StringLength(32)]
|
[StringLength(32)]
|
||||||
public string Iban { get; set; }
|
public string Iban { get; set; }
|
||||||
public int Balance {
|
public int Balance
|
||||||
|
{
|
||||||
get => _balance;
|
get => _balance;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -91,9 +91,20 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
|
|
||||||
using (var userDeath = new DatabaseContext())
|
using (var userDeath = new DatabaseContext())
|
||||||
{
|
{
|
||||||
var dead = new Entities.Logs.Death { VictimId = player.GetUser().Id, KillerId = killerId, KillerPositionX = killerPosX, KillerPositionY = killerPosY,
|
var dead = new Entities.Logs.Death
|
||||||
KillerPositionZ = killerPosZ, KillerHeading = killerHeading, VictimPositionX = player.Position.X, VictimPositionY = player.Position.Y,
|
{
|
||||||
VictimPositionZ = player.Position.Z, VictimHeading = player.Heading, CauseOfDeath = reason.ToString()};
|
VictimId = player.GetUser().Id,
|
||||||
|
KillerId = killerId,
|
||||||
|
KillerPositionX = killerPosX,
|
||||||
|
KillerPositionY = killerPosY,
|
||||||
|
KillerPositionZ = killerPosZ,
|
||||||
|
KillerHeading = killerHeading,
|
||||||
|
VictimPositionX = player.Position.X,
|
||||||
|
VictimPositionY = player.Position.Y,
|
||||||
|
VictimPositionZ = player.Position.Z,
|
||||||
|
VictimHeading = player.Heading,
|
||||||
|
CauseOfDeath = reason.ToString()
|
||||||
|
};
|
||||||
userDeath.DeathLogs.Add(dead);
|
userDeath.DeathLogs.Add(dead);
|
||||||
userDeath.SaveChanges();
|
userDeath.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
.Users
|
.Users
|
||||||
.Include(u => u.Faction)
|
.Include(u => u.Faction)
|
||||||
.Include(u => u.FactionRank)
|
.Include(u => u.FactionRank)
|
||||||
.FirstOrDefault(u => u.Name == client.Name);
|
.Where(u => u.Name == client.Name)
|
||||||
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -42,7 +43,8 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
.Users
|
.Users
|
||||||
.Include(u => u.Faction)
|
.Include(u => u.Faction)
|
||||||
.Include(u => u.FactionRank)
|
.Include(u => u.FactionRank)
|
||||||
.FirstOrDefault(u => u.Name == client.Name);
|
.Where(u => u.Name == client.Name)
|
||||||
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using ReallifeGamemode.Server.Business;
|
using ReallifeGamemode.Server.Business;
|
||||||
using ReallifeGamemode.Server.Entities;
|
using ReallifeGamemode.Server.Entities;
|
||||||
using ReallifeGamemode.Server.Extensions;
|
using ReallifeGamemode.Server.Extensions;
|
||||||
@@ -70,7 +71,8 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
player.SendNotification("~r~Du hast nicht genug Geld");
|
player.SendNotification("~r~Du hast nicht genug Geld");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else */if(result == TransactionResult.SUCCESS)
|
else */
|
||||||
|
if (result == TransactionResult.SUCCESS)
|
||||||
{
|
{
|
||||||
player.TriggerEvent("business_updateMoney", playerBusiness.GetBankAccount().Balance.ToMoneyString());
|
player.TriggerEvent("business_updateMoney", playerBusiness.GetBankAccount().Balance.ToMoneyString());
|
||||||
player.SendNotification("~g~Du hast erfolgreich ~s~" + amount.ToMoneyString() + " ~g~ überwiesen");
|
player.SendNotification("~g~Du hast erfolgreich ~s~" + amount.ToMoneyString() + " ~g~ überwiesen");
|
||||||
@@ -116,12 +118,22 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
if (sVeh == null) return;
|
if (sVeh == null) return;
|
||||||
if (!(sVeh is ShopVehicle)) return;
|
if (!(sVeh is ShopVehicle)) return;
|
||||||
ShopVehicle shopVehicle = (ShopVehicle)sVeh;
|
ShopVehicle shopVehicle = (ShopVehicle)sVeh;
|
||||||
player.TriggerEvent("ShopVehicle_OpenMenu", GetBusiness(shopVehicle.BusinessId).Name, shopVehicle.Price);
|
|
||||||
|
List<string> availableTargets = new List<string>()
|
||||||
|
{
|
||||||
|
"Spieler (dich selbst)"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (player.GetUser().FactionLeader && !player.GetUser().Faction.StateOwned) availableTargets.Add("Fraktion");
|
||||||
|
if (player.GetUser().GroupRank == GroupRank.OWNER) availableTargets.Add("Gruppe");
|
||||||
|
|
||||||
|
player.TriggerEvent("ShopVehicle_OpenMenu", GetBusiness(shopVehicle.BusinessId).Name, shopVehicle.Price, availableTargets.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
[RemoteEvent("VehShop_BuyVehicle")]
|
[RemoteEvent("VehShop_BuyVehicle")]
|
||||||
public void CarDealerBusiness_BuyVehicle(Client player)
|
public void CarDealerBusiness_BuyVehicle(Client player, string target)
|
||||||
{
|
{
|
||||||
|
player.SendChatMessage(target);
|
||||||
ServerVehicle sVeh = player.Vehicle?.GetServerVehicle();
|
ServerVehicle sVeh = player.Vehicle?.GetServerVehicle();
|
||||||
if (sVeh == null) return;
|
if (sVeh == null) return;
|
||||||
if (!(sVeh is ShopVehicle)) return;
|
if (!(sVeh is ShopVehicle)) return;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using ReallifeGamemode.Server.Models;
|
|||||||
namespace ReallifeGamemode.Migrations
|
namespace ReallifeGamemode.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(DatabaseContext))]
|
[DbContext(typeof(DatabaseContext))]
|
||||||
[Migration("20190505145708_Groups")]
|
[Migration("20190505154643_Groups")]
|
||||||
partial class Groups
|
partial class Groups
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -776,6 +776,8 @@ namespace ReallifeGamemode.Migrations
|
|||||||
|
|
||||||
b.Property<int?>("GroupId");
|
b.Property<int?>("GroupId");
|
||||||
|
|
||||||
|
b.Property<int>("GroupRank");
|
||||||
|
|
||||||
b.Property<int>("Handmoney");
|
b.Property<int>("Handmoney");
|
||||||
|
|
||||||
b.Property<int>("LogUserId");
|
b.Property<int>("LogUserId");
|
||||||
@@ -12,6 +12,12 @@ namespace ReallifeGamemode.Migrations
|
|||||||
table: "Users",
|
table: "Users",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "GroupRank",
|
||||||
|
table: "Users",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
migrationBuilder.AddColumn<int>(
|
||||||
name: "GroupId",
|
name: "GroupId",
|
||||||
table: "ServerVehicles",
|
table: "ServerVehicles",
|
||||||
@@ -110,6 +116,10 @@ namespace ReallifeGamemode.Migrations
|
|||||||
name: "GroupId",
|
name: "GroupId",
|
||||||
table: "Users");
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "GroupRank",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "GroupId",
|
name: "GroupId",
|
||||||
table: "ServerVehicles");
|
table: "ServerVehicles");
|
||||||
@@ -774,6 +774,8 @@ namespace ReallifeGamemode.Migrations
|
|||||||
|
|
||||||
b.Property<int?>("GroupId");
|
b.Property<int?>("GroupId");
|
||||||
|
|
||||||
|
b.Property<int>("GroupRank");
|
||||||
|
|
||||||
b.Property<int>("Handmoney");
|
b.Property<int>("Handmoney");
|
||||||
|
|
||||||
b.Property<int>("LogUserId");
|
b.Property<int>("LogUserId");
|
||||||
|
|||||||
14
ReallifeGamemode.Server/Util/GroupRanks.cs
Normal file
14
ReallifeGamemode.Server/Util/GroupRanks.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Util
|
||||||
|
{
|
||||||
|
public enum GroupRank
|
||||||
|
{
|
||||||
|
NONE,
|
||||||
|
MEMBER,
|
||||||
|
MANAGER,
|
||||||
|
OWNER
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user