Merge duty-system into develop
This commit is contained in:
101
Client/Player/dutycloth.js
Normal file
101
Client/Player/dutycloth.js
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Player DutyClothes dutyclothes.js
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
const NativeUI = require("nativeui");
|
||||||
|
const Menu = NativeUI.Menu;
|
||||||
|
const UIMenuItem = NativeUI.UIMenuItem;
|
||||||
|
const UIMenuListItem = NativeUI.UIMenuListItem;
|
||||||
|
const UIMenuCheckboxItem = NativeUI.UIMenuCheckboxItem;
|
||||||
|
const BadgeStyle = NativeUI.BadgeStyle;
|
||||||
|
const Point = NativeUI.Point;
|
||||||
|
const ItemsCollection = NativeUI.ItemsCollection;
|
||||||
|
const Color = NativeUI.Color;
|
||||||
|
|
||||||
|
var hats;
|
||||||
|
var tops;
|
||||||
|
var legs;
|
||||||
|
var shoes;
|
||||||
|
|
||||||
|
var hat = -1;
|
||||||
|
var top;
|
||||||
|
var leg;
|
||||||
|
var shoe;
|
||||||
|
|
||||||
|
let screenRes = mp.game.graphics.getScreenResolution(0, 0);
|
||||||
|
|
||||||
|
var dutyMenu;
|
||||||
|
let saveItem = new UIMenuItem("Speichern", "Speichert deine Dienstkleidung");
|
||||||
|
saveItem.BackColor = new Color(13, 71, 161);
|
||||||
|
saveItem.HighlightedBackColor = new Color(25, 118, 210);
|
||||||
|
|
||||||
|
let cancelItem = new UIMenuItem("Abbrechen", "");
|
||||||
|
cancelItem.BackColor = new Color(213, 0, 0);
|
||||||
|
cancelItem.HighlightedBackColor = new Color(229, 57, 53);
|
||||||
|
|
||||||
|
|
||||||
|
//Cloth Menu
|
||||||
|
|
||||||
|
mp.events.add('showDutyClothMenu', (hatsArr, topsArr, legsArr, shoesArr) => {
|
||||||
|
|
||||||
|
mp.gui.chat.activate(false);
|
||||||
|
hats = hatsArr;
|
||||||
|
tops = topsArr;
|
||||||
|
legs = legsArr;
|
||||||
|
shoes = shoesArr;
|
||||||
|
|
||||||
|
dutyMenu = new Menu("Dienstkleidung", "Stelle deine Dienstkleidung zusammen", new Point(0, screenRes.y/2));
|
||||||
|
|
||||||
|
dutyMenu.AddItem(new UIMenuListItem("Hut", "", new ItemsCollection(hats)));
|
||||||
|
dutyMenu.AddItem(new UIMenuListItem("Top", "", new ItemsCollection(tops)));
|
||||||
|
dutyMenu.AddItem(new UIMenuListItem("Hose", "", new ItemsCollection(legs)));
|
||||||
|
dutyMenu.AddItem(new UIMenuListItem("Schuhe", "", new ItemsCollection(shoes)));
|
||||||
|
dutyMenu.AddItem(saveItem);
|
||||||
|
dutyMenu.AddItem(cancelItem);
|
||||||
|
dutyMenu.Visible = true;
|
||||||
|
|
||||||
|
dutyMenu.ListChange.on((item, index) => {
|
||||||
|
switch (item.Text) {
|
||||||
|
case "Hut":
|
||||||
|
if (item.SelectedItem.DisplayText === "Keinen") {
|
||||||
|
hat = -1;
|
||||||
|
mp.events.callRemote("updateDutyProp", 0, -1);
|
||||||
|
} else {
|
||||||
|
hat = parseInt(item.SelectedItem.DisplayText);
|
||||||
|
mp.events.callRemote("updateDutyProp", 0, hat);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Top":
|
||||||
|
top = parseInt(item.SelectedItem.DisplayText);
|
||||||
|
mp.events.callRemote("updateDutyCloth", 11, top);
|
||||||
|
break;
|
||||||
|
case "Hose":
|
||||||
|
leg = parseInt(item.SelectedItem.DisplayText);
|
||||||
|
mp.events.callRemote("updateDutyCloth", 4, leg);
|
||||||
|
break;
|
||||||
|
case "Schuhe":
|
||||||
|
shoe = parseInt(item.SelectedItem.DisplayText);
|
||||||
|
mp.events.callRemote("updateDutyCloth", 6, shoe);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dutyMenu.ItemSelect.on((item) => {
|
||||||
|
if (item.Text === "Speichern") {
|
||||||
|
var slotType = [1, 0, 0, 0];
|
||||||
|
var slotId = [0, 11, 4, 6];
|
||||||
|
var clothId = [hat, top, leg, shoe];
|
||||||
|
mp.events.callRemote("saveCharacterCloth", JSON.stringify(slotType), JSON.stringify(slotId), JSON.stringify(clothId));
|
||||||
|
dutyMenu.Visible = false;
|
||||||
|
mp.gui.chat.activate(true);
|
||||||
|
} else if (item.Text === "Abbrechen") {
|
||||||
|
dutyMenu.Visible = false;
|
||||||
|
mp.gui.chat.activate(true);
|
||||||
|
mp.events.callRemote("defaultCharacterCloth");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ mp.keys.bind(0x0D, false, function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//F7
|
//F7 //Unshowalles
|
||||||
mp.keys.bind(0x76, false, function () {
|
mp.keys.bind(0x76, false, function () {
|
||||||
if (showGui === true) {
|
if (showGui === true) {
|
||||||
showGui = false;
|
showGui = false;
|
||||||
@@ -28,13 +28,20 @@ mp.keys.bind(0x76, false, function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//NUM2
|
//NUM2 //Save Blips in Edit Mode
|
||||||
mp.keys.bind(0x62, false, function () {
|
mp.keys.bind(0x62, false, function () {
|
||||||
mp.events.callRemote("keyPress:NUM2");
|
mp.events.callRemote("keyPress:NUM2");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//E
|
||||||
|
mp.keys.bind(0x45, false, function () {
|
||||||
|
if (!chat) {
|
||||||
|
mp.events.callRemote("keyPress:E");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//I
|
|
||||||
|
//I //Spielerliste
|
||||||
mp.keys.bind(0x49, false, function () {
|
mp.keys.bind(0x49, false, function () {
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
mp.events.callRemote("keyPress:I");
|
mp.events.callRemote("keyPress:I");
|
||||||
@@ -42,12 +49,21 @@ mp.keys.bind(0x49, false, function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//L
|
//K //Dienstkleidung
|
||||||
mp.keys.bind(0x4C, false, function () {
|
mp.keys.bind(0x4B, false, function () {
|
||||||
mp.events.callRemote("ChangeDoorState");
|
if (!chat) {
|
||||||
|
mp.events.callRemote("keyPress:K");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//N
|
//L //Türen auf / zuschließen
|
||||||
|
mp.keys.bind(0x4C, false, function () {
|
||||||
|
if (!chat) {
|
||||||
|
mp.events.callRemote("keyPress:L");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//N //Motor Starten
|
||||||
mp.keys.bind(0x4E, false, function () {
|
mp.keys.bind(0x4E, false, function () {
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
mp.events.callRemote("keyPress:N");
|
mp.events.callRemote("keyPress:N");
|
||||||
@@ -61,9 +77,10 @@ mp.keys.bind(0x54, false, function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//X
|
//X //Anschnallen
|
||||||
mp.keys.bind(0x58, false, function () {
|
mp.keys.bind(0x58, false, function () {
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
mp.events.callRemote("keyPress:X");
|
mp.events.callRemote("keyPress:X");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ require('./Gui/playerlist.js');
|
|||||||
|
|
||||||
require('./Login/main.js');
|
require('./Login/main.js');
|
||||||
|
|
||||||
|
require('./Player/dutycloth.js');
|
||||||
require('./Player/keys.js');
|
require('./Player/keys.js');
|
||||||
|
|
||||||
require('./Save/main.js');
|
require('./Save/main.js');
|
||||||
|
|||||||
2
Main.cs
2
Main.cs
@@ -30,14 +30,12 @@ namespace reallife_gamemode
|
|||||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||||
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
||||||
NAPI.Data.SetWorldData("policeDoors", false);
|
|
||||||
|
|
||||||
TuningManager.AddTuningGarage(new Vector3(-341, -134, 38.5));
|
TuningManager.AddTuningGarage(new Vector3(-341, -134, 38.5));
|
||||||
|
|
||||||
using (var context = new DatabaseContext())
|
using (var context = new DatabaseContext())
|
||||||
{
|
{
|
||||||
context.Bans.FirstOrDefault();
|
context.Bans.FirstOrDefault();
|
||||||
|
|
||||||
context.Factions.FirstOrDefault();
|
context.Factions.FirstOrDefault();
|
||||||
context.Users.FirstOrDefault();
|
context.Users.FirstOrDefault();
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Configuration;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - DatabaseContext.cs
|
* @overview Life of German Reallife - DatabaseContext.cs
|
||||||
@@ -37,11 +31,16 @@ namespace reallife_gamemode.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
//User
|
//User
|
||||||
|
public DbSet<Server.Entities.Ban> Bans { get; set; }
|
||||||
|
public DbSet<Server.Entities.Character> Characters { get; set; }
|
||||||
|
public DbSet<Server.Entities.CharacterCloth> CharacterClothes { get; set; }
|
||||||
|
public DbSet<Server.Entities.DutyCloth> DutyClothes { get; set; }
|
||||||
|
public DbSet<Server.Entities.MaleCombination> MaleCombinations { get; set; }
|
||||||
|
public DbSet<Server.Entities.FemaleCombination> FemaleCombinations { get; set; }
|
||||||
public DbSet<Server.Entities.User> Users { get; set; }
|
public DbSet<Server.Entities.User> Users { get; set; }
|
||||||
public DbSet<Server.Entities.UserVehicle> UserVehicles { get; set; }
|
public DbSet<Server.Entities.UserVehicle> UserVehicles { get; set; }
|
||||||
public DbSet<Server.Entities.UserBankAccount> UserBankAccounts { get; set; }
|
public DbSet<Server.Entities.UserBankAccount> UserBankAccounts { get; set; }
|
||||||
public DbSet<Server.Entities.Ban> Bans { get; set; }
|
|
||||||
public DbSet<Server.Entities.Character> Characters { get; set; }
|
|
||||||
|
|
||||||
//Faction
|
//Faction
|
||||||
public DbSet<Server.Entities.Faction> Factions { get; set; }
|
public DbSet<Server.Entities.Faction> Factions { get; set; }
|
||||||
|
|||||||
@@ -239,27 +239,7 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
[Command("duty", "~m~Benutzung: ~s~/duty")]
|
[Command("duty", "~m~Benutzung: ~s~/duty")]
|
||||||
public void CmdFactionDuty(Client player)
|
public void CmdFactionDuty(Client player)
|
||||||
{
|
{
|
||||||
if (player.GetUser()?.FactionId == null)
|
|
||||||
{
|
|
||||||
ChatService.NotAuthorized(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(player.GetData("duty") != true)
|
|
||||||
{
|
|
||||||
player.SetData("duty", true);
|
|
||||||
player.SendNotification("Du bist nun ~g~im Dienst.");
|
|
||||||
if(player.GetUser().FactionId == 2)
|
|
||||||
{
|
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.SetData("duty", false);
|
|
||||||
player.SendNotification("Du bist nun ~r~außer Dienst.");
|
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
28
Server/Entities/CharacterCloth.cs
Normal file
28
Server/Entities/CharacterCloth.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Entities CharacterCloth CharacterCloth.cs
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class CharacterCloth
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("User")]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public User User { get; set; }
|
||||||
|
|
||||||
|
public bool Duty { get; set; }
|
||||||
|
|
||||||
|
public byte SlotType { get; set; }
|
||||||
|
public int SlotId { get; set; }
|
||||||
|
public int ClothId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Server/Entities/DutyCloth.cs
Normal file
31
Server/Entities/DutyCloth.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Entities DutyCloth DutyCloth.cs
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class DutyCloth
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("Faction")]
|
||||||
|
public int FactionId { get; set; }
|
||||||
|
public Faction Faction { get; set; }
|
||||||
|
|
||||||
|
public bool Gender { get; set; }
|
||||||
|
|
||||||
|
public byte SlotType { get; set; }
|
||||||
|
public int SlotId { get; set; }
|
||||||
|
public int ClothId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Server/Entities/FemaleCombination.cs
Normal file
24
Server/Entities/FemaleCombination.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Numerics;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Entities FemaleCombination (FemaleCombination.cs)
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class FemaleCombination
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Top { get; set; }
|
||||||
|
public int Torso { get; set; }
|
||||||
|
public int Undershirt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Server/Entities/MaleCombination.cs
Normal file
24
Server/Entities/MaleCombination.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Numerics;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @overview Life of German Reallife - Entities MaleCombination (MaleCombination.cs)
|
||||||
|
* @author VegaZ
|
||||||
|
* @copyright (c) 2008 - 2018 Life of German
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Entities
|
||||||
|
{
|
||||||
|
public class MaleCombination
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Top { get; set; }
|
||||||
|
public int Torso { get; set; }
|
||||||
|
public int Undershirt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using reallife_gamemode.Model;
|
||||||
|
using reallife_gamemode.Server.Entities;
|
||||||
using reallife_gamemode.Server.Extensions;
|
using reallife_gamemode.Server.Extensions;
|
||||||
|
using reallife_gamemode.Server.Managers;
|
||||||
using reallife_gamemode.Server.Saves;
|
using reallife_gamemode.Server.Saves;
|
||||||
|
using reallife_gamemode.Server.Services;
|
||||||
using reallife_gamemode.Server.Util;
|
using reallife_gamemode.Server.Util;
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Key (Key.cs)
|
* @overview Life of German Reallife - Event Key (Key.cs)
|
||||||
@@ -27,7 +32,70 @@ namespace reallife_gamemode.Server.Events
|
|||||||
player.SendNotification("~y~Blip~s~ erstellt!", false);
|
player.SendNotification("~y~Blip~s~ erstellt!", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[RemoteEvent("keyPress:E")]
|
||||||
|
public void KeyPressE(Client player)
|
||||||
|
{
|
||||||
|
var user = player.GetUser();
|
||||||
|
if (user?.FactionId != null)
|
||||||
|
{
|
||||||
|
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5);
|
||||||
|
if (nearest == null) return;
|
||||||
|
if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId)
|
||||||
|
{
|
||||||
|
var nameTagColor = new Color(0, 0, 0);
|
||||||
|
var factionId = user.FactionId;
|
||||||
|
|
||||||
|
if (player.GetData("duty") == false)
|
||||||
|
{
|
||||||
|
player.SetData("duty", true);
|
||||||
|
player.SendNotification("Du bist nun ~g~im Dienst.");
|
||||||
|
if (player.GetUser().FactionId == 2) //Fire Department
|
||||||
|
{
|
||||||
|
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", true);
|
||||||
|
}
|
||||||
|
switch (factionId)
|
||||||
|
{
|
||||||
|
//LSPD
|
||||||
|
case 1:
|
||||||
|
nameTagColor = new Color(28, 134, 238);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
player.NametagColor = nameTagColor;
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
List<CharacterCloth> clothes = context.CharacterClothes.ToList().FindAll(u => u.UserId == user.Id && u.Duty == true);
|
||||||
|
|
||||||
|
foreach(var cloth in clothes)
|
||||||
|
{
|
||||||
|
if(cloth.SlotType == 0)
|
||||||
|
{
|
||||||
|
player.SetClothes(cloth.SlotId, cloth.ClothId, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(cloth.ClothId != -1)
|
||||||
|
{
|
||||||
|
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.ClearAccessory(cloth.SlotId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetData("duty", false);
|
||||||
|
player.SendNotification("Du bist nun ~r~außer Dienst.");
|
||||||
|
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false);
|
||||||
|
player.NametagColor = new Color(255, 255, 255);
|
||||||
|
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
[RemoteEvent("keyPress:I")]
|
[RemoteEvent("keyPress:I")]
|
||||||
public void KeyPressI(Client player)
|
public void KeyPressI(Client player)
|
||||||
{
|
{
|
||||||
@@ -45,6 +113,63 @@ namespace reallife_gamemode.Server.Events
|
|||||||
}
|
}
|
||||||
player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(ListPlayers));
|
player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(ListPlayers));
|
||||||
}
|
}
|
||||||
|
[RemoteEvent("keyPress:K")]
|
||||||
|
public void KeyPressK(Client player)
|
||||||
|
{
|
||||||
|
var user = player.GetUser();
|
||||||
|
if (user?.FactionId != null)
|
||||||
|
{
|
||||||
|
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5);
|
||||||
|
if (nearest == null) return;
|
||||||
|
if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId)
|
||||||
|
{
|
||||||
|
List<string> hats = new List<string>();
|
||||||
|
List<string> tops = new List<string>();
|
||||||
|
List<string> legs = new List<string>();
|
||||||
|
List<string> shoes = new List<string>();
|
||||||
|
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
List<DutyCloth> clothes = context.DutyClothes.ToList().FindAll(c => c.FactionId == user.FactionId && c.Gender == user.GetCharacter().Gender);
|
||||||
|
foreach(var cloth in clothes)
|
||||||
|
{
|
||||||
|
if(cloth.SlotType == 1)
|
||||||
|
{
|
||||||
|
if (cloth.ClothId != -1)
|
||||||
|
{
|
||||||
|
hats.Add(cloth.ClothId.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hats.Add("Keinen");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (cloth.SlotId)
|
||||||
|
{
|
||||||
|
case 11:
|
||||||
|
tops.Add(cloth.ClothId.ToString());
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
legs.Add(cloth.ClothId.ToString());
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
shoes.Add(cloth.ClothId.ToString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
[RemoteEvent("keyPress:L")]
|
||||||
|
public void KeyPressL(Client player)
|
||||||
|
{
|
||||||
|
DoorManager.ChangeDoorState(player);
|
||||||
|
}
|
||||||
[RemoteEvent("keyPress:N")]
|
[RemoteEvent("keyPress:N")]
|
||||||
public void KeyPressN(Client player)
|
public void KeyPressN(Client player)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ namespace reallife_gamemode.Server.Events
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
CharacterCreator.ApplyCharacter(player);
|
CharacterCreator.ApplyCharacter(player);
|
||||||
|
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||||
}
|
}
|
||||||
|
|||||||
199
Server/Events/UpdateCharacterCloth.cs
Normal file
199
Server/Events/UpdateCharacterCloth.cs
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using GTANetworkAPI;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using reallife_gamemode.Model;
|
||||||
|
using reallife_gamemode.Server.Entities;
|
||||||
|
using reallife_gamemode.Server.Extensions;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Events
|
||||||
|
{
|
||||||
|
public class UpdateCharacterCloth : Script
|
||||||
|
{
|
||||||
|
[RemoteEvent("updateDutyProp")]
|
||||||
|
public void UpdateDutyProp(Client player, int componentId, int componentVariation)
|
||||||
|
{
|
||||||
|
if (componentId != -1)
|
||||||
|
{
|
||||||
|
player.SetAccessories(componentId, componentVariation, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.ClearAccessory(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("updateDutyCloth")]
|
||||||
|
public void UpdateDutyCloth(Client player, int componentId, int componentVariation)
|
||||||
|
{
|
||||||
|
if (componentId == 11)
|
||||||
|
{
|
||||||
|
//TODO Spezielle Duty Kleidung in Datenbank einpflegen (Ergibt bei Cop-Kleidung NULL)
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
if (player.GetUser().GetCharacter().Gender == false)
|
||||||
|
{
|
||||||
|
var combination = context.MaleCombinations.FirstOrDefault(c => c.Top == componentVariation);
|
||||||
|
player.SetClothes(11, componentVariation, 0);
|
||||||
|
if (combination != null)
|
||||||
|
{
|
||||||
|
player.SetClothes(3, combination.Torso, 0);
|
||||||
|
player.SetClothes(8, combination.Undershirt, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var combination = context.FemaleCombinations.FirstOrDefault(c => c.Top == componentVariation);
|
||||||
|
player.SetClothes(11, componentVariation, 0);
|
||||||
|
if (combination != null)
|
||||||
|
{
|
||||||
|
player.SetClothes(3, combination.Torso, 0);
|
||||||
|
player.SetClothes(8, combination.Undershirt, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetClothes(componentId, componentVariation, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("saveCharacterCloth")]
|
||||||
|
public void SaveDutyCloth(Client client, string JSlotType, string JSlotId, string JClothId)
|
||||||
|
{
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||||
|
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||||
|
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||||
|
|
||||||
|
User user = client.GetUser();
|
||||||
|
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||||
|
|
||||||
|
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
||||||
|
if (charClothes == null)
|
||||||
|
{
|
||||||
|
for (var x = 0; x < slotType.Length; x++)
|
||||||
|
{
|
||||||
|
CharacterCloth newCloth = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = true,
|
||||||
|
|
||||||
|
SlotType = (byte)slotType[x],
|
||||||
|
SlotId = slotId[x],
|
||||||
|
ClothId = clothId[x]
|
||||||
|
};
|
||||||
|
context.CharacterClothes.Add(newCloth);
|
||||||
|
}
|
||||||
|
if (user.GetCharacter().Gender == false)
|
||||||
|
{
|
||||||
|
CharacterCloth newTorso = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = true,
|
||||||
|
|
||||||
|
SlotType = 0,
|
||||||
|
SlotId = 3,
|
||||||
|
ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso
|
||||||
|
};
|
||||||
|
CharacterCloth newUndershirt = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = true,
|
||||||
|
|
||||||
|
SlotType = 0,
|
||||||
|
SlotId = 8,
|
||||||
|
ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt
|
||||||
|
};
|
||||||
|
context.CharacterClothes.Add(newTorso);
|
||||||
|
context.CharacterClothes.Add(newUndershirt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CharacterCloth newTorso = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = true,
|
||||||
|
|
||||||
|
SlotType = 0,
|
||||||
|
SlotId = 3,
|
||||||
|
ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso
|
||||||
|
};
|
||||||
|
CharacterCloth newUndershirt = new CharacterCloth
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
|
||||||
|
Duty = true,
|
||||||
|
|
||||||
|
SlotType = 0,
|
||||||
|
SlotId = 8,
|
||||||
|
ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt
|
||||||
|
};
|
||||||
|
context.CharacterClothes.Add(newTorso);
|
||||||
|
context.CharacterClothes.Add(newUndershirt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (var x = 0; x < slotType.Length; x++)
|
||||||
|
{
|
||||||
|
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
||||||
|
loopCloth.ClothId = clothId[x];
|
||||||
|
}
|
||||||
|
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
||||||
|
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
||||||
|
if (user.GetCharacter().Gender == false)
|
||||||
|
{
|
||||||
|
torso.ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso;
|
||||||
|
undershirt.ClothId = context.MaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
torso.ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Torso;
|
||||||
|
undershirt.ClothId = context.FemaleCombinations.FirstOrDefault(c => c.Top == clothId[1]).Undershirt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
LoadCharacterDefaults(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("defaultCharacterCloth")]
|
||||||
|
public static void LoadCharacterDefaults(Client player)
|
||||||
|
{
|
||||||
|
User user = player.GetUser();
|
||||||
|
using (var context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
||||||
|
|
||||||
|
foreach(var cloth in charClothes)
|
||||||
|
{
|
||||||
|
if(cloth.SlotType == 1)
|
||||||
|
{
|
||||||
|
if (cloth.ClothId == -1)
|
||||||
|
{
|
||||||
|
player.ClearAccessory(cloth.SlotId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.SetClothes(cloth.SlotId, cloth.ClothId, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,6 +42,21 @@ namespace reallife_gamemode.Server.Extensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Character GetCharacter(this User user, DatabaseContext context = null)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
using (context = new DatabaseContext())
|
||||||
|
{
|
||||||
|
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gibt zurück, ob ein Client eingeloggt ist
|
/// Gibt zurück, ob ein Client eingeloggt ist
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ namespace reallife_gamemode.Server.Managers
|
|||||||
{
|
{
|
||||||
public class DoorManager : Script
|
public class DoorManager : Script
|
||||||
{
|
{
|
||||||
[RemoteEvent("ChangeDoorState")]
|
public static void ChangeDoorState(Client player)
|
||||||
public void ChangeDoorState(Client player)
|
|
||||||
{
|
{
|
||||||
List<Door> NearDoors = new List<Door>();
|
List<Door> NearDoors = new List<Door>();
|
||||||
var user = player.GetUser();
|
var user = player.GetUser();
|
||||||
|
|||||||
41
Server/Managers/PositionManager.cs
Normal file
41
Server/Managers/PositionManager.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using GTANetworkAPI;
|
||||||
|
using reallife_gamemode.Server.Entities;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Managers
|
||||||
|
{
|
||||||
|
public class PositionManager : Script
|
||||||
|
{
|
||||||
|
public static List<DutyPoint> DutyPoints = new List<DutyPoint>();
|
||||||
|
public static List<ColShape> DutyColShapes = new List<ColShape>();
|
||||||
|
|
||||||
|
[ServerEvent(Event.ResourceStart)]
|
||||||
|
public void OnResourceStart()
|
||||||
|
{
|
||||||
|
DutyPoint dutyPointLSPD = new DutyPoint()
|
||||||
|
{
|
||||||
|
Position = new Vector3(458.24, -990.86, 30.68),
|
||||||
|
FactionId = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
DutyPoints.Add(dutyPointLSPD);
|
||||||
|
|
||||||
|
foreach (DutyPoint d in DutyPoints)
|
||||||
|
{
|
||||||
|
NAPI.Marker.CreateMarker(1, new Vector3(d.Position.X, d.Position.Y, d.Position.Z - 2), new Vector3(d.Position.X, d.Position.Y, d.Position.Z + 1),
|
||||||
|
new Vector3(0,0,0), 3, new Color(255, 255, 255, 50), false, 0);
|
||||||
|
NAPI.TextLabel.CreateTextLabel("Stempeluhr - Dr\u00fccke ~y~E\n~s~Dienstkleidung - Dr\u00fccke ~y~K", d.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DutyPoint
|
||||||
|
{
|
||||||
|
public Vector3 Position { get; set; }
|
||||||
|
public int FactionId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ namespace reallife_gamemode.Server.Managers
|
|||||||
{
|
{
|
||||||
if(c.IsInVehicle)
|
if(c.IsInVehicle)
|
||||||
{
|
{
|
||||||
c.TriggerEvent("showTuningInfo");
|
c.TriggerEvent("showTuningInfo", c.GetData("duty"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
40
Server/Util/Converter.cs
Normal file
40
Server/Util/Converter.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using GTANetworkAPI;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace reallife_gamemode.Server.Util
|
||||||
|
{
|
||||||
|
public class Converter
|
||||||
|
{
|
||||||
|
public static Color HexToColor(string hexColor)
|
||||||
|
{
|
||||||
|
//Remove # if present
|
||||||
|
if (hexColor.IndexOf('#') != -1)
|
||||||
|
hexColor = hexColor.Replace("#", "");
|
||||||
|
|
||||||
|
int red = 0;
|
||||||
|
int green = 0;
|
||||||
|
int blue = 0;
|
||||||
|
|
||||||
|
if (hexColor.Length == 6)
|
||||||
|
{
|
||||||
|
//#RRGGBB
|
||||||
|
red = int.Parse(hexColor.Substring(0, 2), NumberStyles.AllowHexSpecifier);
|
||||||
|
green = int.Parse(hexColor.Substring(2, 2), NumberStyles.AllowHexSpecifier);
|
||||||
|
blue = int.Parse(hexColor.Substring(4, 2), NumberStyles.AllowHexSpecifier);
|
||||||
|
}
|
||||||
|
else if (hexColor.Length == 3)
|
||||||
|
{
|
||||||
|
//#RGB
|
||||||
|
red = int.Parse(hexColor[0].ToString() + hexColor[0].ToString(), NumberStyles.AllowHexSpecifier);
|
||||||
|
green = int.Parse(hexColor[1].ToString() + hexColor[1].ToString(), NumberStyles.AllowHexSpecifier);
|
||||||
|
blue = int.Parse(hexColor[2].ToString() + hexColor[2].ToString(), NumberStyles.AllowHexSpecifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color returnColor = new Color(red, green, blue);
|
||||||
|
return returnColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.2" />
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.2" />
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
|
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<<<<<<< HEAD
|
||||||
<ItemGroup Condition="'$(ConfigurationName)' != 'ServerBuild'">
|
<ItemGroup Condition="'$(ConfigurationName)' != 'ServerBuild'">
|
||||||
<Reference Include="Bootstrapper">
|
<Reference Include="Bootstrapper">
|
||||||
<HintPath>..\..\bridge\runtime\Bootstrapper.dll</HintPath>
|
<HintPath>..\..\bridge\runtime\Bootstrapper.dll</HintPath>
|
||||||
@@ -21,6 +22,12 @@
|
|||||||
<Reference Include="Bootstrapper">
|
<Reference Include="Bootstrapper">
|
||||||
<HintPath>..\Bootstrapper.dll</HintPath>
|
<HintPath>..\Bootstrapper.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
=======
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Bootstrapper">
|
||||||
|
<HintPath>..\..\bridge\runtime\Bootstrapper.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
>>>>>>> feature/duty-system
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' == 'Debug'">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' == 'Debug'">
|
||||||
<Exec Command="del "..\..\client_packages\*" /Q /S
xcopy "$(OutDir)*" "..\..\bridge\resources\reallife-gamemode" /Y /Q
del "..\..\client_packages\*.*" /Q
xcopy "..\..\reallife-gamemode\reallife-gamemode\Client\*" "..\..\client_packages\" /S /Q /Y
" />
|
<Exec Command="del "..\..\client_packages\*" /Q /S
xcopy "$(OutDir)*" "..\..\bridge\resources\reallife-gamemode" /Y /Q
del "..\..\client_packages\*.*" /Q
xcopy "..\..\reallife-gamemode\reallife-gamemode\Client\*" "..\..\client_packages\" /S /Q /Y
" />
|
||||||
|
|||||||
Reference in New Issue
Block a user