Add Dynamic Cloth Changing
This commit is contained in:
@@ -19,6 +19,8 @@ var tops;
|
||||
var legs;
|
||||
var shoes;
|
||||
|
||||
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);
|
||||
@@ -33,7 +35,7 @@ mp.events.add('showDutyClothMenu', (hatsArr, topsArr, legsArr, shoesArr) => {
|
||||
legs = legsArr;
|
||||
shoes = shoesArr;
|
||||
|
||||
dutyMenu = new Menu("Dienstkleidung", "Stelle deine Dienstkleidung zusammen", new Point(50, 50));
|
||||
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)));
|
||||
@@ -41,4 +43,48 @@ mp.events.add('showDutyClothMenu', (hatsArr, topsArr, legsArr, shoesArr) => {
|
||||
dutyMenu.AddItem(new UIMenuListItem("Schuhe", "", new ItemsCollection(shoes)));
|
||||
dutyMenu.AddItem(saveItem);
|
||||
dutyMenu.Visible = true;
|
||||
|
||||
dutyMenu.ListChange.on((item, index) => {
|
||||
switch (item.Text) {
|
||||
case "Hut":
|
||||
if (item.SelectedItem.DisplayText === "Keinen") {
|
||||
mp.events.callRemote("updateDutyProp", 0, -1);
|
||||
} else {
|
||||
mp.events.callRemote("updateDutyProp", 0, parseInt(item.SelectedItem.DisplayText));
|
||||
}
|
||||
break;
|
||||
case "Top":
|
||||
mp.events.callRemote("updateDutyCloth", 11, parseInt(item.SelectedItem.DisplayText));
|
||||
break;
|
||||
case "Hose":
|
||||
mp.events.callRemote("updateDutyCloth", 4, parseInt(item.SelectedItem.DisplayText));
|
||||
break;
|
||||
case "Schuhe":
|
||||
mp.events.callRemote("updateDutyCloth", 6, parseInt(item.SelectedItem.DisplayText));
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//dutyMenu.ListChange.on((item, index) => {
|
||||
// switch (item) {
|
||||
// case "Hut":
|
||||
// mp.events.callRemote("updateDutyProp", 0, parseInt(index));
|
||||
// break;
|
||||
// case "Top":
|
||||
// mp.events.callRemote("updateDutyCloth", 11, parseInt(index));
|
||||
// break;
|
||||
// case "Hose":
|
||||
// mp.events.callRemote("updateDutyCloth", 4, parseInt(index));
|
||||
// break;
|
||||
// case "Schuhe":
|
||||
// mp.events.callRemote("updateDutyCloth", 6, parseInt(index));
|
||||
// break;
|
||||
// }
|
||||
//});
|
||||
|
||||
});
|
||||
|
||||
|
||||
//dutyMenu.ItemSelect.on((item) => {
|
||||
// switch
|
||||
//});
|
||||
@@ -12,7 +12,6 @@ let globalData = {
|
||||
require('./CharCreator/index.js');
|
||||
|
||||
require('./FactionManagement/main.js');
|
||||
require('./FactionManagement/duty.js');
|
||||
|
||||
require('./DoorManager/doormanager.js');
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace reallife_gamemode.Model
|
||||
public DbSet<Server.Entities.CharacterProp> CharacterProps { get; set; }
|
||||
public DbSet<Server.Entities.DutyCloth> DutyClothes { get; set; }
|
||||
public DbSet<Server.Entities.DutyProp> DutyProps { 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.UserVehicle> UserVehicles { get; set; }
|
||||
public DbSet<Server.Entities.UserBankAccount> UserBankAccounts { 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; }
|
||||
}
|
||||
}
|
||||
@@ -96,24 +96,24 @@ namespace reallife_gamemode.Server.Events
|
||||
if (nearest == null) return;
|
||||
if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId)
|
||||
{
|
||||
int[] hats;
|
||||
int[] tops;
|
||||
int[] legs;
|
||||
int[] shoes;
|
||||
string[] hats;
|
||||
string[] tops;
|
||||
string[] legs;
|
||||
string[] shoes;
|
||||
|
||||
if(user.GetCharacter().Gender == false) //Wenn männlich
|
||||
{
|
||||
hats = new int[] { -1, 5, 12, 39, 46, 123, 124, 125};
|
||||
tops = new int[] { -1, 55, 26};
|
||||
legs = new int[] { -1, 24, 28 };
|
||||
shoes = new int[] { -1, 24, 25};
|
||||
hats = new string[] { "Keinen", "5", "12", "39", "46", "123", "124", "125"};
|
||||
tops = new string[] { "55", "26"};
|
||||
legs = new string[] { "24", "28" };
|
||||
shoes = new string[] { "24", "25"};
|
||||
}
|
||||
else
|
||||
{
|
||||
hats = new int[] { -1, 12, 38, 45, 122, 123, 124 };
|
||||
tops = new int[] { -1, 48, 43 };
|
||||
legs = new int[] { -1, 34, 37, 102 };
|
||||
shoes = new int[] { -1, 24, 25 };
|
||||
hats = new string[] { "Keinen", "12", "38", "45", "122", "123", "124" };
|
||||
tops = new string[] { "48", "43" };
|
||||
legs = new string[] { "34", "37", "102" };
|
||||
shoes = new string[] { "24", "25" };
|
||||
}
|
||||
|
||||
player.TriggerEvent("showDutyClothMenu", hats, tops, legs, shoes);
|
||||
|
||||
63
Server/Events/UpdateCharacterComponent.cs
Normal file
63
Server/Events/UpdateCharacterComponent.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
|
||||
namespace reallife_gamemode.Server.Events
|
||||
{
|
||||
public class UpdateCharacterComponent : 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user