bissl formattiert
This commit is contained in:
@@ -14,140 +14,140 @@ using ReallifeGamemode.Server.Extensions;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class ATMManager : Script
|
||||
{
|
||||
public static List<ColShape> ATMColShapes = new List<ColShape>();
|
||||
|
||||
public static void InitATMs()
|
||||
{
|
||||
public static List<ColShape> ATMColShapes = new List<ColShape>();
|
||||
|
||||
public static void InitATMs()
|
||||
var addedATMs = 0;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var currentATM in dbContext.Blips)
|
||||
{
|
||||
var addedATMs = 0;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
if (currentATM.Sprite == 500)
|
||||
{
|
||||
if (dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null)
|
||||
{
|
||||
foreach (var currentATM in dbContext.Blips)
|
||||
{
|
||||
if (currentATM.Sprite == 500)
|
||||
{
|
||||
if (dbContext.ATMs.FirstOrDefault(a => a.Id == currentATM.Id) == null)
|
||||
{
|
||||
var dataSet = new ATM
|
||||
{
|
||||
Id = currentATM.Id,
|
||||
X = currentATM.PositionX,
|
||||
Y = currentATM.PositionY,
|
||||
Z = currentATM.PositionZ
|
||||
};
|
||||
dbContext.Add(dataSet);
|
||||
addedATMs++;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addedATMs > 0)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt");
|
||||
}
|
||||
else
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt");
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
LoadATMs();
|
||||
var dataSet = new ATM
|
||||
{
|
||||
Id = currentATM.Id,
|
||||
X = currentATM.PositionX,
|
||||
Y = currentATM.PositionY,
|
||||
Z = currentATM.PositionZ
|
||||
};
|
||||
dbContext.Add(dataSet);
|
||||
addedATMs++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadATMs()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
else
|
||||
{
|
||||
foreach (var currentATM in dbContext.ATMs)
|
||||
{
|
||||
var currentColShape = NAPI.ColShape.CreateCylinderColShape(new Vector3(currentATM.X, currentATM.Y, currentATM.Z), 2.5f, 3, 0);
|
||||
currentColShape.OnEntityEnterColShape += EnterATMRange;
|
||||
currentColShape.OnEntityExitColShape += ExitATMRange;
|
||||
ATMColShapes.Add(currentColShape);
|
||||
currentColShape.SetData("id", currentATM.Id);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnterATMRange(ColShape colShape, Player client)
|
||||
if (addedATMs > 0)
|
||||
{
|
||||
client.SetData("nearATM", colShape.GetData<int>("id"));
|
||||
NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt");
|
||||
}
|
||||
|
||||
public static void ExitATMRange(ColShape colShape, Player client)
|
||||
else
|
||||
{
|
||||
client.ResetData("nearATM");
|
||||
NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt");
|
||||
}
|
||||
|
||||
public static void ShowAtmUi(Player player, int atmId)
|
||||
{
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")]
|
||||
public void AtmAction(Player client, int site, int inputField1, int inputField2)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = client.GetUser(dbContext);
|
||||
int nearATM = client.GetData<int>("nearATM");
|
||||
//SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen
|
||||
switch (site)
|
||||
{
|
||||
//GELD EINZAHLEN in1
|
||||
case 0:
|
||||
|
||||
if (user.Handmoney < inputField1)
|
||||
{
|
||||
//TODO im CEFBrowser anzeigen
|
||||
//client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance);
|
||||
client.SendNotification("~r~Nicht genügend Geld auf der Hand!");
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateBankMoneyIn = user.BankAccount;
|
||||
var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
user.Handmoney -= inputField1;
|
||||
updateBankMoneyIn.Balance += inputField1;
|
||||
updateATMBalanceIn.Balance += inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD AUSZAHLEN in1
|
||||
case 1:
|
||||
var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
|
||||
if (user.BankAccount.Balance < inputField1)
|
||||
{
|
||||
client.SendNotification("~r~Nicht genügend Geld auf dem Bankkonto!"); //TODO Im Automaten anzeigen lassen
|
||||
}
|
||||
else if (checkATM.Balance < inputField1)
|
||||
{
|
||||
client.SendNotification("~r~Nicht genügend Geld im Automaten vorhanden!"); //TODO Im Automaten anzeigen lassen |||| oder OUT OF ORDER anzeigen wenn leer
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateHandMoneyOut = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
updateHandMoneyOut.Handmoney += inputField1;
|
||||
user.BankAccount.Balance -= inputField1;
|
||||
updateATMBalanceOut.Balance -= inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag
|
||||
case 2:
|
||||
|
||||
break;
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
LoadATMs();
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadATMs()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (var currentATM in dbContext.ATMs)
|
||||
{
|
||||
var currentColShape = NAPI.ColShape.CreateCylinderColShape(new Vector3(currentATM.X, currentATM.Y, currentATM.Z), 2.5f, 3, 0);
|
||||
currentColShape.OnEntityEnterColShape += EnterATMRange;
|
||||
currentColShape.OnEntityExitColShape += ExitATMRange;
|
||||
ATMColShapes.Add(currentColShape);
|
||||
currentColShape.SetData("id", currentATM.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnterATMRange(ColShape colShape, Player client)
|
||||
{
|
||||
client.SetData("nearATM", colShape.GetData<int>("id"));
|
||||
}
|
||||
|
||||
public static void ExitATMRange(ColShape colShape, Player client)
|
||||
{
|
||||
client.ResetData("nearATM");
|
||||
}
|
||||
|
||||
public static void ShowAtmUi(Player player, int atmId)
|
||||
{
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")]
|
||||
public void AtmAction(Player client, int site, int inputField1, int inputField2)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = client.GetUser(dbContext);
|
||||
int nearATM = client.GetData<int>("nearATM");
|
||||
//SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen
|
||||
switch (site)
|
||||
{
|
||||
//GELD EINZAHLEN in1
|
||||
case 0:
|
||||
|
||||
if (user.Handmoney < inputField1)
|
||||
{
|
||||
//TODO im CEFBrowser anzeigen
|
||||
//client.TriggerEvent("SERVER:WORLD_INTERACTION:ATM_ERROR", 0, checkATM.Balance);
|
||||
client.SendNotification("~r~Nicht genügend Geld auf der Hand!");
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateBankMoneyIn = user.BankAccount;
|
||||
var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
user.Handmoney -= inputField1;
|
||||
updateBankMoneyIn.Balance += inputField1;
|
||||
updateATMBalanceIn.Balance += inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD AUSZAHLEN in1
|
||||
case 1:
|
||||
var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
|
||||
if (user.BankAccount.Balance < inputField1)
|
||||
{
|
||||
client.SendNotification("~r~Nicht genügend Geld auf dem Bankkonto!"); //TODO Im Automaten anzeigen lassen
|
||||
}
|
||||
else if (checkATM.Balance < inputField1)
|
||||
{
|
||||
client.SendNotification("~r~Nicht genügend Geld im Automaten vorhanden!"); //TODO Im Automaten anzeigen lassen |||| oder OUT OF ORDER anzeigen wenn leer
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateHandMoneyOut = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
updateHandMoneyOut.Handmoney += inputField1;
|
||||
user.BankAccount.Balance -= inputField1;
|
||||
updateATMBalanceOut.Balance -= inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag
|
||||
case 2:
|
||||
|
||||
break;
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,98 +15,98 @@ using ReallifeGamemode.Server.Util;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class BankManager
|
||||
{
|
||||
public static TransactionResult SetMoney(Player admin, IBankAccountOwner owner, int amount, string reason = "Von Admin gesetzt")
|
||||
{
|
||||
public static TransactionResult SetMoney(Player admin, IBankAccountOwner owner, int amount, string reason = "Von Admin gesetzt")
|
||||
using (var transferMoney = new DatabaseContext())
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
IBankAccount account = owner.GetBankAccount(transferMoney);
|
||||
|
||||
if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||
|
||||
var transactionLog = new BankAccountTransactionHistory
|
||||
{
|
||||
using (var transferMoney = new DatabaseContext())
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
Sender = "ADMIN: " + admin.Name,
|
||||
SenderBalance = 0,
|
||||
Receiver = owner.Name,
|
||||
ReceiverBalance = amount,
|
||||
NewReceiverBalance = amount,
|
||||
NewSenderBalance = 0,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = reason
|
||||
};
|
||||
|
||||
IBankAccount account = owner.GetBankAccount(transferMoney);
|
||||
// add log
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
|
||||
if (account == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||
account.Balance = amount;
|
||||
|
||||
var transactionLog = new BankAccountTransactionHistory
|
||||
{
|
||||
Sender = "ADMIN: " + admin.Name,
|
||||
SenderBalance = 0,
|
||||
Receiver = owner.Name,
|
||||
ReceiverBalance = amount,
|
||||
NewReceiverBalance = amount,
|
||||
NewSenderBalance = 0,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = reason
|
||||
};
|
||||
transferMoney.SaveChanges();
|
||||
|
||||
// add log
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
|
||||
account.Balance = amount;
|
||||
|
||||
transferMoney.SaveChanges();
|
||||
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
public static TransactionResult TransferMoney<TSender, TReceiver>(
|
||||
BankAccountHolder<TSender> sender,
|
||||
BankAccountHolder<TReceiver> receiver,
|
||||
int amount,
|
||||
string origin,
|
||||
DatabaseContext dbContext) where TSender : class, IBankAccount, new() where TReceiver : class, IBankAccount, new()
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
IBankAccount senderAccount;
|
||||
IBankAccount receiverAccount;
|
||||
|
||||
if (sender is BankAccountHolder<BusinessBankAccount> businessSender)
|
||||
{
|
||||
senderAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessSender.BankAccountId).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
senderAccount = sender.BankAccount;
|
||||
}
|
||||
|
||||
if (receiver is BankAccountHolder<BusinessBankAccount> businessReceiver)
|
||||
{
|
||||
receiverAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessReceiver.BankAccountId).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
receiverAccount = receiver.BankAccount;
|
||||
}
|
||||
|
||||
if (senderAccount == null) return TransactionResult.SENDER_NO_BANKACCOUNT;
|
||||
if (receiverAccount == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||
|
||||
if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY;
|
||||
|
||||
var transactionLog = new BankAccountTransactionHistory
|
||||
{
|
||||
Sender = sender.BankAccountName,
|
||||
SenderBalance = senderAccount.Balance,
|
||||
Receiver = receiver.BankAccountName,
|
||||
ReceiverBalance = receiverAccount.Balance,
|
||||
NewReceiverBalance = receiverAccount.Balance + amount,
|
||||
NewSenderBalance = senderAccount.Balance - amount,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
// add log
|
||||
dbContext.BankAccountTransactionLogs.Add(transactionLog);
|
||||
|
||||
senderAccount.Balance -= amount;
|
||||
receiverAccount.Balance += amount;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
public static TransactionResult TransferMoney<TSender, TReceiver>(
|
||||
BankAccountHolder<TSender> sender,
|
||||
BankAccountHolder<TReceiver> receiver,
|
||||
int amount,
|
||||
string origin,
|
||||
DatabaseContext dbContext) where TSender : class, IBankAccount, new() where TReceiver : class, IBankAccount, new()
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
IBankAccount senderAccount;
|
||||
IBankAccount receiverAccount;
|
||||
|
||||
if (sender is BankAccountHolder<BusinessBankAccount> businessSender)
|
||||
{
|
||||
senderAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessSender.BankAccountId).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
senderAccount = sender.BankAccount;
|
||||
}
|
||||
|
||||
if (receiver is BankAccountHolder<BusinessBankAccount> businessReceiver)
|
||||
{
|
||||
receiverAccount = dbContext.BusinessBankAccounts.Where(b => b.Id == businessReceiver.BankAccountId).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
receiverAccount = receiver.BankAccount;
|
||||
}
|
||||
|
||||
if (senderAccount == null) return TransactionResult.SENDER_NO_BANKACCOUNT;
|
||||
if (receiverAccount == null) return TransactionResult.RECEIVER_NO_BANKACCOUNT;
|
||||
|
||||
if (senderAccount.Balance < amount) return TransactionResult.SENDER_NOT_ENOUGH_MONEY;
|
||||
|
||||
var transactionLog = new BankAccountTransactionHistory
|
||||
{
|
||||
Sender = sender.BankAccountName,
|
||||
SenderBalance = senderAccount.Balance,
|
||||
Receiver = receiver.BankAccountName,
|
||||
ReceiverBalance = receiverAccount.Balance,
|
||||
NewReceiverBalance = receiverAccount.Balance + amount,
|
||||
NewSenderBalance = senderAccount.Balance - amount,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
// add log
|
||||
dbContext.BankAccountTransactionLogs.Add(transactionLog);
|
||||
|
||||
senderAccount.Balance -= amount;
|
||||
receiverAccount.Balance += amount;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,326 +7,326 @@ using ReallifeGamemode.Server.Extensions;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class CharacterCreator : Script
|
||||
{
|
||||
[RemoteEvent("creator_GenderChange")]
|
||||
public void changeGender(Player player, int gender)
|
||||
{
|
||||
[RemoteEvent("creator_GenderChange")]
|
||||
public void changeGender(Player player, int gender)
|
||||
if (gender == 0) player.SetSkin(PedHash.FreemodeMale01);
|
||||
else player.SetSkin(PedHash.FreemodeFemale01);
|
||||
}
|
||||
|
||||
[RemoteEvent("creatorSave")]
|
||||
public void CreatorSave(Player player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData)
|
||||
{
|
||||
var jParentData = JObject.Parse(parentData);
|
||||
var jFeatureData = JArray.Parse(featureData);
|
||||
var jAppearanceData = JArray.Parse(appearanceData);
|
||||
var jHairAndColorData = JArray.Parse(hairAndColorData);
|
||||
|
||||
byte father = jParentData.Value<byte>("Father");
|
||||
byte mother = jParentData.Value<byte>("Mother");
|
||||
float similarity = jParentData.Value<float>("Similarity");
|
||||
float skinSimilarity = jParentData.Value<float>("SkinSimilarity");
|
||||
|
||||
float noseWidth = jFeatureData.Value<float>(0);
|
||||
float noseBottomHeight = jFeatureData.Value<float>(1);
|
||||
float noseTipLength = jFeatureData.Value<float>(2);
|
||||
float noseBridgeDepth = jFeatureData.Value<float>(3);
|
||||
float noseTipHeight = jFeatureData.Value<float>(4);
|
||||
float noseBroken = jFeatureData.Value<float>(5);
|
||||
float browHeight = jFeatureData.Value<float>(6);
|
||||
float browDepth = jFeatureData.Value<float>(7);
|
||||
float cheekboneHeight = jFeatureData.Value<float>(8);
|
||||
float cheekboneWidth = jFeatureData.Value<float>(9);
|
||||
float cheekDepth = jFeatureData.Value<float>(10);
|
||||
float eyeSize = jFeatureData.Value<float>(11);
|
||||
float lipThickness = jFeatureData.Value<float>(12);
|
||||
float jawWidth = jFeatureData.Value<float>(13);
|
||||
float jawShape = jFeatureData.Value<float>(14);
|
||||
float chinHeight = jFeatureData.Value<float>(15);
|
||||
float chinDepth = jFeatureData.Value<float>(16);
|
||||
float chinWidth = jFeatureData.Value<float>(17);
|
||||
float chinIndent = jFeatureData.Value<float>(18);
|
||||
float neckWidth = jFeatureData.Value<float>(19);
|
||||
|
||||
byte blemishes = jAppearanceData[0].Value<byte>("Value");
|
||||
float blemishesOpacity = jAppearanceData[0].Value<byte>("Opacity");
|
||||
byte facialHair = jAppearanceData[1].Value<byte>("Value");
|
||||
float facialHairOpacity = jAppearanceData[1].Value<byte>("Opacity");
|
||||
byte eyebrows = jAppearanceData[2].Value<byte>("Value");
|
||||
float eyebrowsOpacity = jAppearanceData[2].Value<byte>("Opacity");
|
||||
byte ageing = jAppearanceData[3].Value<byte>("Value");
|
||||
float ageingOpacity = jAppearanceData[3].Value<byte>("Opacity");
|
||||
byte makeup = jAppearanceData[4].Value<byte>("Value");
|
||||
float makeupOpacity = jAppearanceData[4].Value<byte>("Opacity");
|
||||
byte blush = jAppearanceData[5].Value<byte>("Value");
|
||||
float blushOpacity = jAppearanceData[5].Value<byte>("Opacity");
|
||||
byte complexion = jAppearanceData[6].Value<byte>("Value");
|
||||
float complexionOpacity = jAppearanceData[6].Value<byte>("Opacity");
|
||||
byte sunDamage = jAppearanceData[7].Value<byte>("Value");
|
||||
float sunDamageOpacity = jAppearanceData[7].Value<byte>("Opacity");
|
||||
byte lipstick = jAppearanceData[8].Value<byte>("Value");
|
||||
float lipstickOpacity = jAppearanceData[8].Value<byte>("Opacity");
|
||||
byte freckles = jAppearanceData[9].Value<byte>("Value");
|
||||
float frecklesOpacity = jAppearanceData[9].Value<byte>("Opacity");
|
||||
byte chestHair = jAppearanceData[10].Value<byte>("Value");
|
||||
float chestHairOpacity = jAppearanceData[10].Value<byte>("Opacity");
|
||||
|
||||
byte hair = jHairAndColorData.Value<byte>(0);
|
||||
byte hairColor = jHairAndColorData.Value<byte>(1);
|
||||
byte hairHighlightColor = jHairAndColorData.Value<byte>(2);
|
||||
byte eyebrowColor = jHairAndColorData.Value<byte>(3);
|
||||
byte beardColor = jHairAndColorData.Value<byte>(4);
|
||||
byte eyeColor = jHairAndColorData.Value<byte>(5);
|
||||
byte blushColor = jHairAndColorData.Value<byte>(6);
|
||||
byte lipstickColor = jHairAndColorData.Value<byte>(7);
|
||||
byte chestHairColor = jHairAndColorData.Value<byte>(8);
|
||||
|
||||
using (var saveCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = new Database.Entities.Character
|
||||
{
|
||||
if (gender == 0) player.SetSkin(PedHash.FreemodeMale01);
|
||||
else player.SetSkin(PedHash.FreemodeFemale01);
|
||||
UserId = player.GetUser().Id,
|
||||
Gender = gender,
|
||||
Father = father,
|
||||
Mother = mother,
|
||||
Similarity = similarity,
|
||||
SkinSimilarity = skinSimilarity,
|
||||
|
||||
NoseWidth = noseWidth,
|
||||
NoseBottomHeight = noseBottomHeight,
|
||||
NoseTipLength = noseTipLength,
|
||||
NoseBridgeDepth = noseBridgeDepth,
|
||||
NoseTipHeight = noseTipHeight,
|
||||
NoseBroken = noseBroken,
|
||||
BrowHeight = browHeight,
|
||||
BrowDepth = browDepth,
|
||||
CheekboneHeight = cheekboneHeight,
|
||||
CheekboneWidth = cheekboneWidth,
|
||||
CheekDepth = cheekDepth,
|
||||
EyeSize = eyeSize,
|
||||
LipThickness = lipThickness,
|
||||
JawWidth = jawWidth,
|
||||
JawShape = jawShape,
|
||||
ChinHeight = chinHeight,
|
||||
ChinDepth = chinDepth,
|
||||
ChinWidth = chinWidth,
|
||||
ChinIndent = chinIndent,
|
||||
NeckWidth = neckWidth,
|
||||
|
||||
Blemishes = blemishes,
|
||||
BlemishesOpacity = blemishesOpacity,
|
||||
FacialHair = facialHair,
|
||||
FacialHairOpacity = facialHairOpacity,
|
||||
Eyebrows = eyebrows,
|
||||
EyebrowsOpacity = eyebrowsOpacity,
|
||||
Ageing = ageing,
|
||||
AgeingOpacity = ageingOpacity,
|
||||
Makeup = makeup,
|
||||
MakeupOpacity = makeupOpacity,
|
||||
Blush = blush,
|
||||
BlushOpacity = blushOpacity,
|
||||
Complexion = complexion,
|
||||
ComplexionOpacity = complexionOpacity,
|
||||
SunDamage = sunDamage,
|
||||
SunDamageOpacity = sunDamageOpacity,
|
||||
Lipstick = lipstick,
|
||||
LipstickOpacity = lipstickOpacity,
|
||||
Freckles = freckles,
|
||||
FrecklesOpacity = frecklesOpacity,
|
||||
ChestHair = chestHair,
|
||||
ChestHairOpacity = chestHairOpacity,
|
||||
|
||||
Hair = hair,
|
||||
HairColor = hairColor,
|
||||
HairHighlightColor = hairHighlightColor,
|
||||
EyebrowColor = eyebrowColor,
|
||||
BeardColor = beardColor,
|
||||
EyeColor = eyeColor,
|
||||
BlushColor = blushColor,
|
||||
LipstickColor = lipstickColor,
|
||||
ChestHairColor = chestHairColor
|
||||
};
|
||||
|
||||
saveCharacter.Characters.Add(character);
|
||||
saveCharacter.SaveChanges();
|
||||
|
||||
var userId = player.GetUser().Id;
|
||||
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
|
||||
|
||||
user.CharacterId = character.Id;
|
||||
saveCharacter.SaveChanges();
|
||||
}
|
||||
//HeadOverlay makeupHo = new HeadOverlay()
|
||||
//{
|
||||
// Index = 0,
|
||||
// Opacity = 0.0f,
|
||||
// Color = 0,
|
||||
// SecondaryColor = 0
|
||||
//};
|
||||
//HeadOverlay blushHo = new HeadOverlay()
|
||||
//{
|
||||
// Index = 0,
|
||||
// Opacity = 0.0f,
|
||||
// Color = 0,
|
||||
// SecondaryColor = 0
|
||||
//};
|
||||
//player.SetHeadOverlay(4, makeupHo);
|
||||
//player.SetHeadOverlay(5, blushHo);
|
||||
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
player.Dimension = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wendet den Character eines Spielers auf diesen an
|
||||
/// </summary>
|
||||
/// <param name="player">Der Player, dessen Aussehen man setzen will</param>
|
||||
public static void ApplyCharacter(Player player)
|
||||
{
|
||||
var user = player.GetUser();
|
||||
using (var loadCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = loadCharacter.Characters.SingleOrDefault(c => c.Id == user.CharacterId);
|
||||
|
||||
if (character == null) return;
|
||||
|
||||
//Männlich / Weiblich
|
||||
if (character.Gender == false)
|
||||
{
|
||||
player.SetSkin(PedHash.FreemodeMale01);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetSkin(PedHash.FreemodeFemale01);
|
||||
}
|
||||
|
||||
[RemoteEvent("creatorSave")]
|
||||
public void CreatorSave(Player player, bool gender, string parentData, string featureData, string appearanceData, string hairAndColorData)
|
||||
{
|
||||
var jParentData = JObject.Parse(parentData);
|
||||
var jFeatureData = JArray.Parse(featureData);
|
||||
var jAppearanceData = JArray.Parse(appearanceData);
|
||||
var jHairAndColorData = JArray.Parse(hairAndColorData);
|
||||
|
||||
byte father = jParentData.Value<byte>("Father");
|
||||
byte mother = jParentData.Value<byte>("Mother");
|
||||
float similarity = jParentData.Value<float>("Similarity");
|
||||
float skinSimilarity = jParentData.Value<float>("SkinSimilarity");
|
||||
|
||||
float noseWidth = jFeatureData.Value<float>(0);
|
||||
float noseBottomHeight = jFeatureData.Value<float>(1);
|
||||
float noseTipLength = jFeatureData.Value<float>(2);
|
||||
float noseBridgeDepth = jFeatureData.Value<float>(3);
|
||||
float noseTipHeight = jFeatureData.Value<float>(4);
|
||||
float noseBroken = jFeatureData.Value<float>(5);
|
||||
float browHeight = jFeatureData.Value<float>(6);
|
||||
float browDepth = jFeatureData.Value<float>(7);
|
||||
float cheekboneHeight = jFeatureData.Value<float>(8);
|
||||
float cheekboneWidth = jFeatureData.Value<float>(9);
|
||||
float cheekDepth = jFeatureData.Value<float>(10);
|
||||
float eyeSize = jFeatureData.Value<float>(11);
|
||||
float lipThickness = jFeatureData.Value<float>(12);
|
||||
float jawWidth = jFeatureData.Value<float>(13);
|
||||
float jawShape = jFeatureData.Value<float>(14);
|
||||
float chinHeight = jFeatureData.Value<float>(15);
|
||||
float chinDepth = jFeatureData.Value<float>(16);
|
||||
float chinWidth = jFeatureData.Value<float>(17);
|
||||
float chinIndent = jFeatureData.Value<float>(18);
|
||||
float neckWidth = jFeatureData.Value<float>(19);
|
||||
|
||||
byte blemishes = jAppearanceData[0].Value<byte>("Value");
|
||||
float blemishesOpacity = jAppearanceData[0].Value<byte>("Opacity");
|
||||
byte facialHair = jAppearanceData[1].Value<byte>("Value");
|
||||
float facialHairOpacity = jAppearanceData[1].Value<byte>("Opacity");
|
||||
byte eyebrows = jAppearanceData[2].Value<byte>("Value");
|
||||
float eyebrowsOpacity = jAppearanceData[2].Value<byte>("Opacity");
|
||||
byte ageing = jAppearanceData[3].Value<byte>("Value");
|
||||
float ageingOpacity = jAppearanceData[3].Value<byte>("Opacity");
|
||||
byte makeup = jAppearanceData[4].Value<byte>("Value");
|
||||
float makeupOpacity = jAppearanceData[4].Value<byte>("Opacity");
|
||||
byte blush = jAppearanceData[5].Value<byte>("Value");
|
||||
float blushOpacity = jAppearanceData[5].Value<byte>("Opacity");
|
||||
byte complexion = jAppearanceData[6].Value<byte>("Value");
|
||||
float complexionOpacity = jAppearanceData[6].Value<byte>("Opacity");
|
||||
byte sunDamage = jAppearanceData[7].Value<byte>("Value");
|
||||
float sunDamageOpacity = jAppearanceData[7].Value<byte>("Opacity");
|
||||
byte lipstick = jAppearanceData[8].Value<byte>("Value");
|
||||
float lipstickOpacity = jAppearanceData[8].Value<byte>("Opacity");
|
||||
byte freckles = jAppearanceData[9].Value<byte>("Value");
|
||||
float frecklesOpacity = jAppearanceData[9].Value<byte>("Opacity");
|
||||
byte chestHair = jAppearanceData[10].Value<byte>("Value");
|
||||
float chestHairOpacity = jAppearanceData[10].Value<byte>("Opacity");
|
||||
|
||||
byte hair = jHairAndColorData.Value<byte>(0);
|
||||
byte hairColor = jHairAndColorData.Value<byte>(1);
|
||||
byte hairHighlightColor = jHairAndColorData.Value<byte>(2);
|
||||
byte eyebrowColor = jHairAndColorData.Value<byte>(3);
|
||||
byte beardColor = jHairAndColorData.Value<byte>(4);
|
||||
byte eyeColor = jHairAndColorData.Value<byte>(5);
|
||||
byte blushColor = jHairAndColorData.Value<byte>(6);
|
||||
byte lipstickColor = jHairAndColorData.Value<byte>(7);
|
||||
byte chestHairColor = jHairAndColorData.Value<byte>(8);
|
||||
|
||||
using (var saveCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = new Database.Entities.Character
|
||||
{
|
||||
UserId = player.GetUser().Id,
|
||||
Gender = gender,
|
||||
Father = father,
|
||||
Mother = mother,
|
||||
Similarity = similarity,
|
||||
SkinSimilarity = skinSimilarity,
|
||||
|
||||
NoseWidth = noseWidth,
|
||||
NoseBottomHeight = noseBottomHeight,
|
||||
NoseTipLength = noseTipLength,
|
||||
NoseBridgeDepth = noseBridgeDepth,
|
||||
NoseTipHeight = noseTipHeight,
|
||||
NoseBroken = noseBroken,
|
||||
BrowHeight = browHeight,
|
||||
BrowDepth = browDepth,
|
||||
CheekboneHeight = cheekboneHeight,
|
||||
CheekboneWidth = cheekboneWidth,
|
||||
CheekDepth = cheekDepth,
|
||||
EyeSize = eyeSize,
|
||||
LipThickness = lipThickness,
|
||||
JawWidth = jawWidth,
|
||||
JawShape = jawShape,
|
||||
ChinHeight = chinHeight,
|
||||
ChinDepth = chinDepth,
|
||||
ChinWidth = chinWidth,
|
||||
ChinIndent = chinIndent,
|
||||
NeckWidth = neckWidth,
|
||||
|
||||
Blemishes = blemishes,
|
||||
BlemishesOpacity = blemishesOpacity,
|
||||
FacialHair = facialHair,
|
||||
FacialHairOpacity = facialHairOpacity,
|
||||
Eyebrows = eyebrows,
|
||||
EyebrowsOpacity = eyebrowsOpacity,
|
||||
Ageing = ageing,
|
||||
AgeingOpacity = ageingOpacity,
|
||||
Makeup = makeup,
|
||||
MakeupOpacity = makeupOpacity,
|
||||
Blush = blush,
|
||||
BlushOpacity = blushOpacity,
|
||||
Complexion = complexion,
|
||||
ComplexionOpacity = complexionOpacity,
|
||||
SunDamage = sunDamage,
|
||||
SunDamageOpacity = sunDamageOpacity,
|
||||
Lipstick = lipstick,
|
||||
LipstickOpacity = lipstickOpacity,
|
||||
Freckles = freckles,
|
||||
FrecklesOpacity = frecklesOpacity,
|
||||
ChestHair = chestHair,
|
||||
ChestHairOpacity = chestHairOpacity,
|
||||
|
||||
Hair = hair,
|
||||
HairColor = hairColor,
|
||||
HairHighlightColor = hairHighlightColor,
|
||||
EyebrowColor = eyebrowColor,
|
||||
BeardColor = beardColor,
|
||||
EyeColor = eyeColor,
|
||||
BlushColor = blushColor,
|
||||
LipstickColor = lipstickColor,
|
||||
ChestHairColor = chestHairColor
|
||||
};
|
||||
|
||||
saveCharacter.Characters.Add(character);
|
||||
saveCharacter.SaveChanges();
|
||||
|
||||
var userId = player.GetUser().Id;
|
||||
var user = saveCharacter.Users.SingleOrDefault(u => u.Id == userId);
|
||||
|
||||
user.CharacterId = character.Id;
|
||||
saveCharacter.SaveChanges();
|
||||
}
|
||||
//HeadOverlay makeupHo = new HeadOverlay()
|
||||
//{
|
||||
// Index = 0,
|
||||
// Opacity = 0.0f,
|
||||
// Color = 0,
|
||||
// SecondaryColor = 0
|
||||
//};
|
||||
//HeadOverlay blushHo = new HeadOverlay()
|
||||
//{
|
||||
// Index = 0,
|
||||
// Opacity = 0.0f,
|
||||
// Color = 0,
|
||||
// SecondaryColor = 0
|
||||
//};
|
||||
//player.SetHeadOverlay(4, makeupHo);
|
||||
//player.SetHeadOverlay(5, blushHo);
|
||||
NAPI.Player.SpawnPlayer(player, Main.DEFAULT_SPAWN_POSITION, Main.DEFAULT_SPAWN_HEADING);
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
player.Dimension = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wendet den Character eines Spielers auf diesen an
|
||||
/// </summary>
|
||||
/// <param name="player">Der Player, dessen Aussehen man setzen will</param>
|
||||
public static void ApplyCharacter(Player player)
|
||||
{
|
||||
var user = player.GetUser();
|
||||
using (var loadCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = loadCharacter.Characters.SingleOrDefault(c => c.Id == user.CharacterId);
|
||||
|
||||
if (character == null) return;
|
||||
|
||||
//Männlich / Weiblich
|
||||
if (character.Gender == false)
|
||||
{
|
||||
player.SetSkin(PedHash.FreemodeMale01);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetSkin(PedHash.FreemodeFemale01);
|
||||
}
|
||||
|
||||
//Gesichtszüge
|
||||
float[] faceFeatures = new float[] { character.NoseWidth, character.NoseBottomHeight, character.NoseTipLength, character.NoseBridgeDepth, character.NoseTipHeight,
|
||||
//Gesichtszüge
|
||||
float[] faceFeatures = new float[] { character.NoseWidth, character.NoseBottomHeight, character.NoseTipLength, character.NoseBridgeDepth, character.NoseTipHeight,
|
||||
character.NoseBroken, character.BrowHeight, character.BrowDepth, character.CheekboneHeight, character.CheekboneWidth,
|
||||
character.CheekboneWidth, character.CheekDepth, character.EyeSize, character.LipThickness, character.JawWidth,
|
||||
character.JawShape, character.ChinHeight, character.ChinDepth, character.ChinWidth, character.ChinIndent, character.NeckWidth };
|
||||
|
||||
for (var i = 0; i < faceFeatures.Length; i++)
|
||||
{
|
||||
player.SetFaceFeature(i, faceFeatures[i]);
|
||||
}
|
||||
|
||||
//Gesichtsmerkmale
|
||||
HeadOverlay blemishes = new HeadOverlay()
|
||||
{
|
||||
Index = character.Blemishes,
|
||||
Opacity = character.BlemishesOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay facialHair = new HeadOverlay()
|
||||
{
|
||||
Index = character.FacialHair,
|
||||
Opacity = character.FacialHairOpacity,
|
||||
Color = character.BeardColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay eyebrows = new HeadOverlay()
|
||||
{
|
||||
Index = character.Eyebrows,
|
||||
Opacity = character.EyebrowsOpacity,
|
||||
Color = character.EyebrowColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay ageing = new HeadOverlay()
|
||||
{
|
||||
Index = character.Ageing,
|
||||
Opacity = character.AgeingOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay makeup = new HeadOverlay()
|
||||
{
|
||||
Index = character.Makeup,
|
||||
Opacity = character.MakeupOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay blush = new HeadOverlay()
|
||||
{
|
||||
Index = character.Blush,
|
||||
Opacity = character.BlushOpacity,
|
||||
Color = character.BlushColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay complexion = new HeadOverlay()
|
||||
{
|
||||
Index = character.Complexion,
|
||||
Opacity = character.ComplexionOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay sunDamage = new HeadOverlay()
|
||||
{
|
||||
Index = character.SunDamage,
|
||||
Opacity = character.SunDamageOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay lipstick = new HeadOverlay()
|
||||
{
|
||||
Index = character.Lipstick,
|
||||
Opacity = character.LipstickOpacity,
|
||||
Color = character.LipstickColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay freckles = new HeadOverlay()
|
||||
{
|
||||
Index = character.Freckles,
|
||||
Opacity = character.FrecklesOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay chestHair = new HeadOverlay()
|
||||
{
|
||||
Index = character.ChestHair,
|
||||
Opacity = character.ChestHairOpacity,
|
||||
Color = character.ChestHairColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
|
||||
player.SetHeadOverlay(0, blemishes);
|
||||
player.SetHeadOverlay(1, facialHair);
|
||||
player.SetHeadOverlay(2, eyebrows);
|
||||
player.SetHeadOverlay(3, ageing);
|
||||
player.SetHeadOverlay(4, makeup);
|
||||
player.SetHeadOverlay(5, blush);
|
||||
player.SetHeadOverlay(6, complexion);
|
||||
player.SetHeadOverlay(7, sunDamage);
|
||||
player.SetHeadOverlay(8, lipstick);
|
||||
player.SetHeadOverlay(9, freckles);
|
||||
player.SetHeadOverlay(10, chestHair);
|
||||
player.SetHeadOverlay(11, blemishes);
|
||||
player.SetHeadOverlay(12, blemishes);
|
||||
|
||||
//Gesicht (Vererbung durch Mutter / Vater)
|
||||
HeadBlend headBlend = new HeadBlend()
|
||||
{
|
||||
ShapeFirst = character.Mother,
|
||||
ShapeSecond = character.Father,
|
||||
ShapeThird = 0,
|
||||
SkinFirst = character.Mother,
|
||||
SkinSecond = character.Father,
|
||||
SkinThird = 0,
|
||||
ShapeMix = character.Similarity,
|
||||
SkinMix = character.SkinSimilarity,
|
||||
ThirdMix = 0.0f
|
||||
};
|
||||
NAPI.Player.SetPlayerHeadBlend(player, headBlend);
|
||||
|
||||
//Haare und Haarfarbe
|
||||
player.SetClothes(2, character.Hair, 0);
|
||||
NAPI.Player.SetPlayerHairColor(player, character.HairColor, character.HairHighlightColor);
|
||||
|
||||
//Augenfarbe
|
||||
NAPI.Player.SetPlayerEyeColor(player, character.EyeColor);
|
||||
}
|
||||
for (var i = 0; i < faceFeatures.Length; i++)
|
||||
{
|
||||
player.SetFaceFeature(i, faceFeatures[i]);
|
||||
}
|
||||
|
||||
//Gesichtsmerkmale
|
||||
HeadOverlay blemishes = new HeadOverlay()
|
||||
{
|
||||
Index = character.Blemishes,
|
||||
Opacity = character.BlemishesOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay facialHair = new HeadOverlay()
|
||||
{
|
||||
Index = character.FacialHair,
|
||||
Opacity = character.FacialHairOpacity,
|
||||
Color = character.BeardColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay eyebrows = new HeadOverlay()
|
||||
{
|
||||
Index = character.Eyebrows,
|
||||
Opacity = character.EyebrowsOpacity,
|
||||
Color = character.EyebrowColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay ageing = new HeadOverlay()
|
||||
{
|
||||
Index = character.Ageing,
|
||||
Opacity = character.AgeingOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay makeup = new HeadOverlay()
|
||||
{
|
||||
Index = character.Makeup,
|
||||
Opacity = character.MakeupOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay blush = new HeadOverlay()
|
||||
{
|
||||
Index = character.Blush,
|
||||
Opacity = character.BlushOpacity,
|
||||
Color = character.BlushColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay complexion = new HeadOverlay()
|
||||
{
|
||||
Index = character.Complexion,
|
||||
Opacity = character.ComplexionOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay sunDamage = new HeadOverlay()
|
||||
{
|
||||
Index = character.SunDamage,
|
||||
Opacity = character.SunDamageOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay lipstick = new HeadOverlay()
|
||||
{
|
||||
Index = character.Lipstick,
|
||||
Opacity = character.LipstickOpacity,
|
||||
Color = character.LipstickColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay freckles = new HeadOverlay()
|
||||
{
|
||||
Index = character.Freckles,
|
||||
Opacity = character.FrecklesOpacity,
|
||||
Color = 255,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
HeadOverlay chestHair = new HeadOverlay()
|
||||
{
|
||||
Index = character.ChestHair,
|
||||
Opacity = character.ChestHairOpacity,
|
||||
Color = character.ChestHairColor,
|
||||
SecondaryColor = 255
|
||||
};
|
||||
|
||||
player.SetHeadOverlay(0, blemishes);
|
||||
player.SetHeadOverlay(1, facialHair);
|
||||
player.SetHeadOverlay(2, eyebrows);
|
||||
player.SetHeadOverlay(3, ageing);
|
||||
player.SetHeadOverlay(4, makeup);
|
||||
player.SetHeadOverlay(5, blush);
|
||||
player.SetHeadOverlay(6, complexion);
|
||||
player.SetHeadOverlay(7, sunDamage);
|
||||
player.SetHeadOverlay(8, lipstick);
|
||||
player.SetHeadOverlay(9, freckles);
|
||||
player.SetHeadOverlay(10, chestHair);
|
||||
player.SetHeadOverlay(11, blemishes);
|
||||
player.SetHeadOverlay(12, blemishes);
|
||||
|
||||
//Gesicht (Vererbung durch Mutter / Vater)
|
||||
HeadBlend headBlend = new HeadBlend()
|
||||
{
|
||||
ShapeFirst = character.Mother,
|
||||
ShapeSecond = character.Father,
|
||||
ShapeThird = 0,
|
||||
SkinFirst = character.Mother,
|
||||
SkinSecond = character.Father,
|
||||
SkinThird = 0,
|
||||
ShapeMix = character.Similarity,
|
||||
SkinMix = character.SkinSimilarity,
|
||||
ThirdMix = 0.0f
|
||||
};
|
||||
NAPI.Player.SetPlayerHeadBlend(player, headBlend);
|
||||
|
||||
//Haare und Haarfarbe
|
||||
player.SetClothes(2, character.Hair, 0);
|
||||
NAPI.Player.SetPlayerHairColor(player, character.HairColor, character.HairHighlightColor);
|
||||
|
||||
//Augenfarbe
|
||||
NAPI.Player.SetPlayerEyeColor(player, character.EyeColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,71 +15,71 @@ using ReallifeGamemode.Server.Types;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class DoorManager : Script
|
||||
{
|
||||
private static Dictionary<int, NetHandle> _doorColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static void LoadDoors()
|
||||
{
|
||||
private static Dictionary<int, NetHandle> _doorColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static void LoadDoors()
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (Door door in dbContext.Doors)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (Door door in dbContext.Doors)
|
||||
{
|
||||
_doorColShapes[door.Id] = NAPI.ColShape.CreateSphereColShape(door.Position, 30f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReloadDoors()
|
||||
{
|
||||
foreach (var doorPair in _doorColShapes)
|
||||
{
|
||||
doorPair.Value.Entity<ColShape>().Delete();
|
||||
}
|
||||
_doorColShapes.Clear();
|
||||
LoadDoors();
|
||||
}
|
||||
|
||||
public static void ChangeDoorState(Player player)
|
||||
{
|
||||
var user = player.GetUser();
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
IQueryable<Door> NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius);
|
||||
foreach (Door d in NearDoors)
|
||||
{
|
||||
if (!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null))
|
||||
{
|
||||
string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!";
|
||||
player.SendNotification(lockState, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
d.Locked = !d.Locked;
|
||||
|
||||
string notStr = d.Name + " " + (d.Locked == false ? "~g~auf" : "~r~ab") + "geschlossen";
|
||||
|
||||
player.SendNotification(notStr, true);
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, (d.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerEnterColshape)]
|
||||
public void DoorManagerPlayerEnterColShapeEvent(ColShape colShape, Player player)
|
||||
{
|
||||
if (_doorColShapes.ContainsValue(colShape.Handle))
|
||||
{
|
||||
int doorId = _doorColShapes.Where(d => d.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Door door = dbContext.Doors.Where(d => d.Id == doorId).First();
|
||||
player.TriggerEvent("changeDoorState", door.Model, door.X, door.Y, door.Z, (door.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
_doorColShapes[door.Id] = NAPI.ColShape.CreateSphereColShape(door.Position, 30f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReloadDoors()
|
||||
{
|
||||
foreach (var doorPair in _doorColShapes)
|
||||
{
|
||||
doorPair.Value.Entity<ColShape>().Delete();
|
||||
}
|
||||
_doorColShapes.Clear();
|
||||
LoadDoors();
|
||||
}
|
||||
|
||||
public static void ChangeDoorState(Player player)
|
||||
{
|
||||
var user = player.GetUser();
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
IQueryable<Door> NearDoors = dbContext.Doors.Where(d => d.Position.DistanceTo(player.Position) <= d.Radius);
|
||||
foreach (Door d in NearDoors)
|
||||
{
|
||||
if (!user.IsAdmin(AdminLevel.ADMIN) && (d.FactionId != user.FactionId || d.FactionId == null))
|
||||
{
|
||||
string lockState = "~r~Du hast kein Recht diese T\u00fcr " + (d.Locked == true ? "auf" : "ab") + "zuschlie\u00dfen!";
|
||||
player.SendNotification(lockState, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
d.Locked = !d.Locked;
|
||||
|
||||
string notStr = d.Name + " " + (d.Locked == false ? "~g~auf" : "~r~ab") + "geschlossen";
|
||||
|
||||
player.SendNotification(notStr, true);
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, (d.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerEnterColshape)]
|
||||
public void DoorManagerPlayerEnterColShapeEvent(ColShape colShape, Player player)
|
||||
{
|
||||
if (_doorColShapes.ContainsValue(colShape.Handle))
|
||||
{
|
||||
int doorId = _doorColShapes.Where(d => d.Value.Value == colShape.Handle.Value).FirstOrDefault().Key;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
Door door = dbContext.Doors.Where(d => d.Id == doorId).First();
|
||||
player.TriggerEvent("changeDoorState", door.Model, door.X, door.Y, door.Z, (door.Locked ? 1 : 0), 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,320 +15,320 @@ using ReallifeGamemode.Services;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class JobManager : Script
|
||||
{
|
||||
private static List<JobBase> _jobs = new List<JobBase>();
|
||||
|
||||
public static void LoadJobs()
|
||||
{
|
||||
private static List<JobBase> _jobs = new List<JobBase>();
|
||||
IEnumerable<Type> jobTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(JobBase)) && !t.IsAbstract);
|
||||
|
||||
public static void LoadJobs()
|
||||
foreach (var type in jobTypes)
|
||||
{
|
||||
var instance = Activator.CreateInstance(type) as JobBase;
|
||||
if (GetJob(instance.Id) != null)
|
||||
{
|
||||
IEnumerable<Type> jobTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(JobBase)) && !t.IsAbstract);
|
||||
|
||||
foreach (var type in jobTypes)
|
||||
{
|
||||
var instance = Activator.CreateInstance(type) as JobBase;
|
||||
if (GetJob(instance.Id) != null)
|
||||
{
|
||||
throw new InvalidOperationException($"Double Job ID found: {instance.Id} | {instance.Name}");
|
||||
}
|
||||
_jobs.Add(instance);
|
||||
NAPI.Util.ConsoleOutput($"Loading job {instance.Name}");
|
||||
}
|
||||
NAPI.Util.ConsoleOutput($"Loaded {_jobs.Count} jobs");
|
||||
}
|
||||
|
||||
public static JobBase GetJob(int id) => _jobs.Where(j => j.Id == id).FirstOrDefault();
|
||||
|
||||
public static T GetJob<T>() where T : JobBase
|
||||
{
|
||||
return _jobs.Where(j => j.GetType() == typeof(T)).FirstOrDefault() as T;
|
||||
}
|
||||
|
||||
public static List<JobBase> GetJobs() => _jobs.OrderBy(j => j.Id).ToList();
|
||||
|
||||
[RemoteEvent("CLIENT:JobCenter_CancelJob")]
|
||||
public void CancelJobEvent(Player player)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = player.GetUser(dbContext);
|
||||
|
||||
if (u == null) return;
|
||||
|
||||
if (u.JobId == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du hast momentan keinen Job, den du kündigen könntest.");
|
||||
return;
|
||||
}
|
||||
|
||||
u.JobId = null;
|
||||
|
||||
ChatService.SendMessage(player, "~y~[JOBCENTER]~s~ Du hast deinen Job erfolgreich gekündigt.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:JobCenter_AcceptJob")]
|
||||
public void AcceptJobEvent(Player player, int jobId)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = player.GetUser(dbContext);
|
||||
|
||||
if (u == null) return;
|
||||
|
||||
if (u.JobId != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du musst deinen alten Job kündigen, bevor du einen neuen ausüben kannst");
|
||||
return;
|
||||
}
|
||||
|
||||
JobBase job = JobManager.GetJob(jobId);
|
||||
|
||||
if (job == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Bei der Job-Annahme ist ein Fehler aufgetretet: Dieser Job wurde nicht gefunden");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatService.SendMessage(player, $"~y~[JOBCENTER]~s~ Du hast erfolgreich deinen neuen Job: ~o~{job.Name}~s~ angenommen.");
|
||||
|
||||
u.JobId = jobId;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:JobManager_ShowJobMenu")]
|
||||
public void ShowJobMenuEvent(Player player)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
|
||||
if (u.JobId == null) return;
|
||||
|
||||
JobBase job = GetJob(u.JobId.Value);
|
||||
|
||||
dynamic data = null;
|
||||
|
||||
if (job.Id == 1 && job.GetUsersInJob().Contains(player))
|
||||
{
|
||||
var taxiCalls = JobManager.GetJob<TaxiDriverJob>().TaxiContracts;
|
||||
if (!taxiCalls.Any(t => t.Driver?.Handle == player.Handle)) // Spieler in keiner aktiven Fahrt
|
||||
{
|
||||
data = new
|
||||
{
|
||||
job.Id,
|
||||
Status = 0,
|
||||
JobData = new
|
||||
{
|
||||
TaxiCalls = taxiCalls
|
||||
.Where(t => t.Driver == null)
|
||||
.Select(t => new
|
||||
{
|
||||
t.Name,
|
||||
Distance = Math.Round(t.Position.DistanceTo(player.Position), 0)
|
||||
})
|
||||
.OrderBy(t => t.Distance)
|
||||
}
|
||||
};
|
||||
}
|
||||
else // Spieler in aktiver Fahrt
|
||||
{
|
||||
data = new
|
||||
{
|
||||
job.Id,
|
||||
Status = 1,
|
||||
JobData = new
|
||||
{
|
||||
taxiCalls.Where(t => t.Driver.Handle == player.Handle).First().Name
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
JobPoint nearJobPoint = PositionManager.jobPoints.Find(p => p.Position.DistanceTo(player.Position) <= 2);
|
||||
if (nearJobPoint == null && u.JobId == 2) return;
|
||||
|
||||
var json = JsonConvert.SerializeObject(data);
|
||||
|
||||
player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name, json);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Job_StartJob")]
|
||||
public void StartJobEvent(Player player)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
|
||||
if (u.JobId == null) return;
|
||||
|
||||
JobBase job = GetJob(u.JobId.Value);
|
||||
|
||||
if (job.GetUsersInJob().Contains(player))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du bist schon in deinem Job aktiv");
|
||||
return;
|
||||
}
|
||||
|
||||
if (job.NeedVehicleToStart && !job.GetJobVehicles().Any(v => v.GetVehicle().Handle.Value == player.Vehicle?.Handle.Value))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Zum Start dieses Jobs musst du in einem Jobfahrzeug sein");
|
||||
return;
|
||||
}
|
||||
|
||||
job.StartJob(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Job_StopJob")]
|
||||
public void StopJob(Player player)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
|
||||
if (u.JobId == null) return;
|
||||
|
||||
JobBase job = GetJob(u.JobId.Value);
|
||||
|
||||
if (!job.GetUsersInJob().Contains(player))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du führst deinen Job momentan nicht aus");
|
||||
return;
|
||||
}
|
||||
|
||||
if (job.NeedVehicleToStart && player.Vehicle != null)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(player.Vehicle, false);
|
||||
}
|
||||
|
||||
job.StopJob(player);
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerExitVehicle)]
|
||||
public void JobManagerPlayerExitVehicle(Player player, Vehicle veh)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
|
||||
if (u.JobId == null) return;
|
||||
|
||||
JobBase job = GetJob(u.JobId.Value);
|
||||
|
||||
if (job.GetUsersInJob().Contains(player) && job.NeedVehicleToStart)
|
||||
{
|
||||
job.StopJob(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerEnterVehicle)]
|
||||
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh, sbyte seat)
|
||||
{
|
||||
if (seat == 0) return;
|
||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt in Taxi ein
|
||||
{
|
||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||
|
||||
Player driver = veh.GetDriver();
|
||||
if (!driver.HasData("DriverPrice")) return;
|
||||
int taxiPrice = driver.GetData<int>("DriverPrice");
|
||||
float km = 0;
|
||||
if (!driver.HasData("FareKm")) { driver.SetData<float>("FareKm", km); }
|
||||
km = driver.GetData<float>("FareKm");
|
||||
if (driver.HasData("Passager")) return;
|
||||
driver.SetData<int>("Passager", player.GetUser().Id);
|
||||
driver.SetData<bool>("hasPassager", true);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User contractUser = player.GetUser(dbContext);
|
||||
contractUser.Handmoney -= (int)Math.Round(km * taxiPrice);
|
||||
dbContext.SaveChanges();
|
||||
contractUser.Player.TriggerEvent("SERVER:SET_HANDMONEY", contractUser.Handmoney);
|
||||
}
|
||||
player.TriggerEvent("CLIENT:startCustomerFare", taxiPrice, km);
|
||||
|
||||
var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name);
|
||||
if (taxiContracts.Count() == 0) return;
|
||||
|
||||
var contract = taxiContracts.First();
|
||||
taxiJob.TaxiContracts.Remove(contract);
|
||||
|
||||
if (driver != null && contract.Driver != null && contract.Driver.Handle != veh.GetDriver().Handle)
|
||||
{
|
||||
ChatService.SendMessage(contract.Driver, $"!{{02FCFF}}{player.Name} ist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
||||
ChatService.SendMessage(player, $"!{{02FCFF}}Du bist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
private void JobManagerEnterVehicleAttempt(Player player, Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerEnterVehicle(player, vehicle, seat); }
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
private void JobManagerOnPlayerDeath(Player player, Player killer, uint reason)
|
||||
{
|
||||
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerDeath(player); }
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
private void JobManagerOnPlayerDisconnect(Player player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerDc(player); }
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerExitVehicle)]
|
||||
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh)
|
||||
{
|
||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt vom Taxi aus
|
||||
{
|
||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||
if (veh.Occupants.Count == 0) return;
|
||||
Player driver = veh.GetDriver();
|
||||
if (driver == null) return;
|
||||
if (player.GetUser().Id != driver.GetData<int>("Passager")) { player.TriggerEvent("CLIENT:cancelFare"); return; }
|
||||
player.TriggerEvent("CLIENT:cancelFareCustomer");
|
||||
driver.TriggerEvent("CLIENT:resetFareClock");
|
||||
driver.ResetData("Passager");
|
||||
driver.ResetData("hasPassager");
|
||||
driver.SetData<float>("FareKm", 0);
|
||||
foreach (Player occupant in veh.Occupants)
|
||||
{
|
||||
if (occupant == driver) continue;
|
||||
occupant.WarpOutOfVehicle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:JobManager_TaxiJob_AcceptCall")]
|
||||
public void TaxiJobAcceptCall(Player player, string name)
|
||||
{
|
||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||
|
||||
if (!taxiJob.TaxiContracts.Any(t => t.Name == name))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler hat kein Taxi gerufen oder der Auftrag ist nicht mehr aktuell");
|
||||
return;
|
||||
}
|
||||
|
||||
var job = taxiJob.TaxiContracts.Where(t => t.Name == name).First();
|
||||
|
||||
var target = PlayerService.GetPlayerByNameOrId(name);
|
||||
if (target == null)
|
||||
{
|
||||
taxiJob.TaxiContracts.Remove(job);
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht mehr online");
|
||||
return;
|
||||
}
|
||||
|
||||
job.Driver = player;
|
||||
|
||||
player.TriggerEvent("SERVER:Util_setWaypoint", target.Position.X, target.Position.Y);
|
||||
player.SetData<bool>("hasPassager", true);
|
||||
|
||||
ChatService.SendMessage(target, $"!{{02FCFF}}Dein Auftrag wurde von {player.Name} angenommen. Warte an deiner aktuellen Position.");
|
||||
ChatService.SendMessage(target, $"!{{02FCFF}}Für die Anfahrt fallen zusätzlich Kosten auf.");
|
||||
ChatService.SendMessage(player, $"!{{02FCFF}}Du hast den Auftrag von {name} angenommen. Hole ihn nun ab.");
|
||||
throw new InvalidOperationException($"Double Job ID found: {instance.Id} | {instance.Name}");
|
||||
}
|
||||
_jobs.Add(instance);
|
||||
NAPI.Util.ConsoleOutput($"Loading job {instance.Name}");
|
||||
}
|
||||
NAPI.Util.ConsoleOutput($"Loaded {_jobs.Count} jobs");
|
||||
}
|
||||
|
||||
public static JobBase GetJob(int id) => _jobs.Where(j => j.Id == id).FirstOrDefault();
|
||||
|
||||
public static T GetJob<T>() where T : JobBase
|
||||
{
|
||||
return _jobs.Where(j => j.GetType() == typeof(T)).FirstOrDefault() as T;
|
||||
}
|
||||
|
||||
public static List<JobBase> GetJobs() => _jobs.OrderBy(j => j.Id).ToList();
|
||||
|
||||
[RemoteEvent("CLIENT:JobCenter_CancelJob")]
|
||||
public void CancelJobEvent(Player player)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = player.GetUser(dbContext);
|
||||
|
||||
if (u == null) return;
|
||||
|
||||
if (u.JobId == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du hast momentan keinen Job, den du kündigen könntest.");
|
||||
return;
|
||||
}
|
||||
|
||||
u.JobId = null;
|
||||
|
||||
ChatService.SendMessage(player, "~y~[JOBCENTER]~s~ Du hast deinen Job erfolgreich gekündigt.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:JobCenter_AcceptJob")]
|
||||
public void AcceptJobEvent(Player player, int jobId)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = player.GetUser(dbContext);
|
||||
|
||||
if (u == null) return;
|
||||
|
||||
if (u.JobId != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du musst deinen alten Job kündigen, bevor du einen neuen ausüben kannst");
|
||||
return;
|
||||
}
|
||||
|
||||
JobBase job = JobManager.GetJob(jobId);
|
||||
|
||||
if (job == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Bei der Job-Annahme ist ein Fehler aufgetretet: Dieser Job wurde nicht gefunden");
|
||||
return;
|
||||
}
|
||||
|
||||
ChatService.SendMessage(player, $"~y~[JOBCENTER]~s~ Du hast erfolgreich deinen neuen Job: ~o~{job.Name}~s~ angenommen.");
|
||||
|
||||
u.JobId = jobId;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:JobManager_ShowJobMenu")]
|
||||
public void ShowJobMenuEvent(Player player)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
|
||||
if (u.JobId == null) return;
|
||||
|
||||
JobBase job = GetJob(u.JobId.Value);
|
||||
|
||||
dynamic data = null;
|
||||
|
||||
if (job.Id == 1 && job.GetUsersInJob().Contains(player))
|
||||
{
|
||||
var taxiCalls = JobManager.GetJob<TaxiDriverJob>().TaxiContracts;
|
||||
if (!taxiCalls.Any(t => t.Driver?.Handle == player.Handle)) // Spieler in keiner aktiven Fahrt
|
||||
{
|
||||
data = new
|
||||
{
|
||||
job.Id,
|
||||
Status = 0,
|
||||
JobData = new
|
||||
{
|
||||
TaxiCalls = taxiCalls
|
||||
.Where(t => t.Driver == null)
|
||||
.Select(t => new
|
||||
{
|
||||
t.Name,
|
||||
Distance = Math.Round(t.Position.DistanceTo(player.Position), 0)
|
||||
})
|
||||
.OrderBy(t => t.Distance)
|
||||
}
|
||||
};
|
||||
}
|
||||
else // Spieler in aktiver Fahrt
|
||||
{
|
||||
data = new
|
||||
{
|
||||
job.Id,
|
||||
Status = 1,
|
||||
JobData = new
|
||||
{
|
||||
taxiCalls.Where(t => t.Driver.Handle == player.Handle).First().Name
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
JobPoint nearJobPoint = PositionManager.jobPoints.Find(p => p.Position.DistanceTo(player.Position) <= 2);
|
||||
if (nearJobPoint == null && u.JobId == 2) return;
|
||||
|
||||
var json = JsonConvert.SerializeObject(data);
|
||||
|
||||
player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name, json);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Job_StartJob")]
|
||||
public void StartJobEvent(Player player)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
|
||||
if (u.JobId == null) return;
|
||||
|
||||
JobBase job = GetJob(u.JobId.Value);
|
||||
|
||||
if (job.GetUsersInJob().Contains(player))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du bist schon in deinem Job aktiv");
|
||||
return;
|
||||
}
|
||||
|
||||
if (job.NeedVehicleToStart && !job.GetJobVehicles().Any(v => v.GetVehicle().Handle.Value == player.Vehicle?.Handle.Value))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Zum Start dieses Jobs musst du in einem Jobfahrzeug sein");
|
||||
return;
|
||||
}
|
||||
|
||||
job.StartJob(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:Job_StopJob")]
|
||||
public void StopJob(Player player)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
|
||||
if (u.JobId == null) return;
|
||||
|
||||
JobBase job = GetJob(u.JobId.Value);
|
||||
|
||||
if (!job.GetUsersInJob().Contains(player))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du führst deinen Job momentan nicht aus");
|
||||
return;
|
||||
}
|
||||
|
||||
if (job.NeedVehicleToStart && player.Vehicle != null)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(player.Vehicle, false);
|
||||
}
|
||||
|
||||
job.StopJob(player);
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerExitVehicle)]
|
||||
public void JobManagerPlayerExitVehicle(Player player, Vehicle veh)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
|
||||
if (u.JobId == null) return;
|
||||
|
||||
JobBase job = GetJob(u.JobId.Value);
|
||||
|
||||
if (job.GetUsersInJob().Contains(player) && job.NeedVehicleToStart)
|
||||
{
|
||||
job.StopJob(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerEnterVehicle)]
|
||||
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh, sbyte seat)
|
||||
{
|
||||
if (seat == 0) return;
|
||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt in Taxi ein
|
||||
{
|
||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||
|
||||
Player driver = veh.GetDriver();
|
||||
if (!driver.HasData("DriverPrice")) return;
|
||||
int taxiPrice = driver.GetData<int>("DriverPrice");
|
||||
float km = 0;
|
||||
if (!driver.HasData("FareKm")) { driver.SetData<float>("FareKm", km); }
|
||||
km = driver.GetData<float>("FareKm");
|
||||
if (driver.HasData("Passager")) return;
|
||||
driver.SetData<int>("Passager", player.GetUser().Id);
|
||||
driver.SetData<bool>("hasPassager", true);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User contractUser = player.GetUser(dbContext);
|
||||
contractUser.Handmoney -= (int)Math.Round(km * taxiPrice);
|
||||
dbContext.SaveChanges();
|
||||
contractUser.Player.TriggerEvent("SERVER:SET_HANDMONEY", contractUser.Handmoney);
|
||||
}
|
||||
player.TriggerEvent("CLIENT:startCustomerFare", taxiPrice, km);
|
||||
|
||||
var taxiContracts = taxiJob.TaxiContracts.Where(t => t.Name == player.Name);
|
||||
if (taxiContracts.Count() == 0) return;
|
||||
|
||||
var contract = taxiContracts.First();
|
||||
taxiJob.TaxiContracts.Remove(contract);
|
||||
|
||||
if (driver != null && contract.Driver != null && contract.Driver.Handle != veh.GetDriver().Handle)
|
||||
{
|
||||
ChatService.SendMessage(contract.Driver, $"!{{02FCFF}}{player.Name} ist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
||||
ChatService.SendMessage(player, $"!{{02FCFF}}Du bist in ein Taxi eingestiegen, der Auftrag wurde beendet.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
private void JobManagerEnterVehicleAttempt(Player player, Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerEnterVehicle(player, vehicle, seat); }
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
private void JobManagerOnPlayerDeath(Player player, Player killer, uint reason)
|
||||
{
|
||||
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerDeath(player); }
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
private void JobManagerOnPlayerDisconnect(Player player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (JobManager.GetJob<RefuseCollectorJob>().GetUsersInJob().Contains(player)) { JobManager.GetJob<RefuseCollectorJob>().MuellmannOnPlayerDc(player); }
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerExitVehicle)]
|
||||
public void JobManagerPlayerEnterVehicle(Player player, Vehicle veh)
|
||||
{
|
||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
if (sVeh is JobVehicle jV && jV.JobId == 1) // Spieler steigt vom Taxi aus
|
||||
{
|
||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||
if (veh.Occupants.Count == 0) return;
|
||||
Player driver = veh.GetDriver();
|
||||
if (driver == null) return;
|
||||
if (player.GetUser().Id != driver.GetData<int>("Passager")) { player.TriggerEvent("CLIENT:cancelFare"); return; }
|
||||
player.TriggerEvent("CLIENT:cancelFareCustomer");
|
||||
driver.TriggerEvent("CLIENT:resetFareClock");
|
||||
driver.ResetData("Passager");
|
||||
driver.ResetData("hasPassager");
|
||||
driver.SetData<float>("FareKm", 0);
|
||||
foreach (Player occupant in veh.Occupants)
|
||||
{
|
||||
if (occupant == driver) continue;
|
||||
occupant.WarpOutOfVehicle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:JobManager_TaxiJob_AcceptCall")]
|
||||
public void TaxiJobAcceptCall(Player player, string name)
|
||||
{
|
||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||
|
||||
if (!taxiJob.TaxiContracts.Any(t => t.Name == name))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler hat kein Taxi gerufen oder der Auftrag ist nicht mehr aktuell");
|
||||
return;
|
||||
}
|
||||
|
||||
var job = taxiJob.TaxiContracts.Where(t => t.Name == name).First();
|
||||
|
||||
var target = PlayerService.GetPlayerByNameOrId(name);
|
||||
if (target == null)
|
||||
{
|
||||
taxiJob.TaxiContracts.Remove(job);
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht mehr online");
|
||||
return;
|
||||
}
|
||||
|
||||
job.Driver = player;
|
||||
|
||||
player.TriggerEvent("SERVER:Util_setWaypoint", target.Position.X, target.Position.Y);
|
||||
player.SetData<bool>("hasPassager", true);
|
||||
|
||||
ChatService.SendMessage(target, $"!{{02FCFF}}Dein Auftrag wurde von {player.Name} angenommen. Warte an deiner aktuellen Position.");
|
||||
ChatService.SendMessage(target, $"!{{02FCFF}}Für die Anfahrt fallen zusätzlich Kosten auf.");
|
||||
ChatService.SendMessage(player, $"!{{02FCFF}}Du hast den Auftrag von {name} angenommen. Hole ihn nun ab.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,29 +13,29 @@ using ReallifeGamemode.Server.Extensions;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class LoadManager : Script
|
||||
{
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (SavedBlip b in dbContext.Blips)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (SavedBlip b in dbContext.Blips)
|
||||
{
|
||||
if (b.Active == true)
|
||||
{
|
||||
NAPI.Blip.CreateBlip((uint)b.Sprite, new Vector3(b.PositionX, b.PositionY, b.PositionZ), b.Scale,
|
||||
b.Color, b.Name, b.Alpha, b.DrawDistance, b.ShortRange, (short)b.Rotation, b.Dimension);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ServerVehicle veh in dbContext.ServerVehicles)
|
||||
{
|
||||
if (!veh.Active) continue;
|
||||
|
||||
Vehicle current = veh.Spawn();
|
||||
TuningManager.ApplyTuningToServerVehicle(veh);
|
||||
}
|
||||
}
|
||||
if (b.Active == true)
|
||||
{
|
||||
NAPI.Blip.CreateBlip((uint)b.Sprite, new Vector3(b.PositionX, b.PositionY, b.PositionZ), b.Scale,
|
||||
b.Color, b.Name, b.Alpha, b.DrawDistance, b.ShortRange, (short)b.Rotation, b.Dimension);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ServerVehicle veh in dbContext.ServerVehicles)
|
||||
{
|
||||
if (!veh.Active) continue;
|
||||
|
||||
Vehicle current = veh.Spawn();
|
||||
TuningManager.ApplyTuningToServerVehicle(veh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class PedManager : Script
|
||||
{
|
||||
private List<PedData> pedDatas = new List<PedData>();
|
||||
private List<PedData> pedDatas = new List<PedData>();
|
||||
public static List<SavedPed> serverPeds = new List<SavedPed>();
|
||||
private static Dictionary<Player, List<PedData>> dataDict = new Dictionary<Player, List<PedData>>();
|
||||
private void GetPedsFromDatabase()
|
||||
@@ -42,7 +42,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
if (!s.Active) continue;
|
||||
Vector3 vector3 = new Vector3(s.PositionX, s.PositionY, s.PositionZ);
|
||||
pedDatas.Add(new PedData(player, (DataType)s.Type, vector3, s.Heading, s.HashModel));
|
||||
|
||||
|
||||
vector3s.Add(vector3);
|
||||
headings.Add(s.Heading);
|
||||
hashes.Add(s.HashModel);
|
||||
|
||||
@@ -10,195 +10,195 @@ using ReallifeGamemode.Server.Extensions;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class SaveManager : Script
|
||||
{
|
||||
[RemoteEvent("OnSaveBlipData")]
|
||||
public static void OnSaveBlipData(Player player, string blipSprite, string blipName, string blipScale, string blipColor,
|
||||
string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension)
|
||||
{
|
||||
[RemoteEvent("OnSaveBlipData")]
|
||||
public static void OnSaveBlipData(Player player, string blipSprite, string blipName, string blipScale, string blipColor,
|
||||
string blipAlpha, string blipDrawDistance, string blipShortRange, string blipRotation, string blipDimension)
|
||||
float x = player.Position.X;
|
||||
float y = player.Position.Y;
|
||||
float z = player.Position.Z;
|
||||
short sprite = short.Parse(blipSprite);
|
||||
string name = blipName;
|
||||
float scale = float.Parse(blipScale);
|
||||
byte color = Convert.ToByte(blipColor);
|
||||
byte alpha = Convert.ToByte(blipAlpha);
|
||||
float drawDistance = float.Parse(blipDrawDistance);
|
||||
bool shortRange = bool.Parse(blipShortRange);
|
||||
float rotation = float.Parse(blipRotation);
|
||||
byte dimension = Convert.ToByte(blipDimension);
|
||||
|
||||
NAPI.Blip.CreateBlip(uint.Parse(blipSprite), new Vector3(x, y, z), scale, color, name, alpha, drawDistance, shortRange, short.Parse(blipRotation), dimension);
|
||||
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new SavedBlip
|
||||
{
|
||||
float x = player.Position.X;
|
||||
float y = player.Position.Y;
|
||||
float z = player.Position.Z;
|
||||
short sprite = short.Parse(blipSprite);
|
||||
string name = blipName;
|
||||
float scale = float.Parse(blipScale);
|
||||
byte color = Convert.ToByte(blipColor);
|
||||
byte alpha = Convert.ToByte(blipAlpha);
|
||||
float drawDistance = float.Parse(blipDrawDistance);
|
||||
bool shortRange = bool.Parse(blipShortRange);
|
||||
float rotation = float.Parse(blipRotation);
|
||||
byte dimension = Convert.ToByte(blipDimension);
|
||||
Sprite = sprite,
|
||||
PositionX = x,
|
||||
PositionY = y,
|
||||
PositionZ = z,
|
||||
Name = blipName,
|
||||
Scale = scale,
|
||||
Color = color,
|
||||
Alpha = alpha,
|
||||
DrawDistance = drawDistance,
|
||||
ShortRange = shortRange,
|
||||
Rotation = rotation,
|
||||
Dimension = dimension,
|
||||
Active = true
|
||||
};
|
||||
saveData.Blips.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
NAPI.Blip.CreateBlip(uint.Parse(blipSprite), new Vector3(x, y, z), scale, color, name, alpha, drawDistance, shortRange, short.Parse(blipRotation), dimension);
|
||||
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new SavedBlip
|
||||
{
|
||||
Sprite = sprite,
|
||||
PositionX = x,
|
||||
PositionY = y,
|
||||
PositionZ = z,
|
||||
Name = blipName,
|
||||
Scale = scale,
|
||||
Color = color,
|
||||
Alpha = alpha,
|
||||
DrawDistance = drawDistance,
|
||||
ShortRange = shortRange,
|
||||
Rotation = rotation,
|
||||
Dimension = dimension,
|
||||
Active = true
|
||||
};
|
||||
saveData.Blips.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static Vehicle SaveVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked)
|
||||
public static Vehicle SaveVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked)
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new SavedVehicle
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new SavedVehicle
|
||||
{
|
||||
Model = vehicleModel,
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Locked = vehicleLocked,
|
||||
Active = true
|
||||
};
|
||||
saveData.Vehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
Model = vehicleModel,
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Locked = vehicleLocked,
|
||||
Active = true
|
||||
};
|
||||
saveData.Vehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
|
||||
public static Vehicle SaveJobVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int jobId)
|
||||
public static Vehicle SaveJobVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int jobId)
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new JobVehicle
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new JobVehicle
|
||||
{
|
||||
Model = vehicleModel,
|
||||
JobId = jobId,
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Locked = vehicleLocked,
|
||||
Active = true
|
||||
};
|
||||
saveData.JobVehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
Model = vehicleModel,
|
||||
JobId = jobId,
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Locked = vehicleLocked,
|
||||
Active = true
|
||||
};
|
||||
saveData.JobVehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
|
||||
public static Vehicle SaveSchoolVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int schoolId)
|
||||
public static Vehicle SaveSchoolVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int schoolId)
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new SchoolVehicle
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new SchoolVehicle
|
||||
{
|
||||
Model = vehicleModel,
|
||||
SchoolId = schoolId,
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Locked = vehicleLocked,
|
||||
Active = true
|
||||
};
|
||||
saveData.SchoolVehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
Model = vehicleModel,
|
||||
SchoolId = schoolId,
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Locked = vehicleLocked,
|
||||
Active = true
|
||||
};
|
||||
saveData.SchoolVehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
|
||||
public static Vehicle SaveFactionVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int[] factionId, int livery)
|
||||
public static Vehicle SaveFactionVehicleData(Vehicle veh, VehicleHash vehicleModel, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, bool vehicleLocked, bool vehicleEngine, int[] factionId, int livery)
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new FactionVehicle
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new FactionVehicle
|
||||
{
|
||||
Model = vehicleModel,
|
||||
Owners = JsonConvert.SerializeObject(factionId),
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Locked = vehicleLocked,
|
||||
Active = true,
|
||||
Livery = livery
|
||||
};
|
||||
saveData.FactionVehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
Model = vehicleModel,
|
||||
Owners = JsonConvert.SerializeObject(factionId),
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Locked = vehicleLocked,
|
||||
Active = true,
|
||||
Livery = livery
|
||||
};
|
||||
saveData.FactionVehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
|
||||
public static Vehicle SaveShopVehicleData(Vehicle veh, VehicleHash vehicleModel, string vehicleModelName, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, BusinessBase business, int price)
|
||||
public static Vehicle SaveShopVehicleData(Vehicle veh, VehicleHash vehicleModel, string vehicleModelName, Vector3 vehiclePosition, float vehicleHeading,
|
||||
string vehicleNumberPlate, int vehiclePrimaryColor, int vehicleSecondaryColor, BusinessBase business, int price)
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new ShopVehicle
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new ShopVehicle
|
||||
{
|
||||
Model = vehicleModel,
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Active = true,
|
||||
BusinessId = business.Id,
|
||||
Price = price
|
||||
};
|
||||
saveData.ShopVehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
Model = vehicleModel,
|
||||
PositionX = vehiclePosition.X,
|
||||
PositionY = vehiclePosition.Y,
|
||||
PositionZ = vehiclePosition.Z,
|
||||
Heading = vehicleHeading,
|
||||
NumberPlate = vehicleNumberPlate,
|
||||
PrimaryColor = vehiclePrimaryColor,
|
||||
SecondaryColor = vehicleSecondaryColor,
|
||||
Active = true,
|
||||
BusinessId = business.Id,
|
||||
Price = price
|
||||
};
|
||||
saveData.ShopVehicles.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
return dataSet.Spawn(veh);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveGotoPoint(Player player, string description)
|
||||
public static void SaveGotoPoint(Player player, string description)
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new GotoPoint
|
||||
{
|
||||
using (var saveData = new DatabaseContext())
|
||||
{
|
||||
var dataSet = new GotoPoint
|
||||
{
|
||||
Description = description,
|
||||
X = player.Position.X,
|
||||
Y = player.Position.Y,
|
||||
Z = player.Position.Z,
|
||||
Active = true
|
||||
};
|
||||
saveData.GotoPoints.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
}
|
||||
}
|
||||
Description = description,
|
||||
X = player.Position.X,
|
||||
Y = player.Position.Y,
|
||||
Z = player.Position.Z,
|
||||
Active = true
|
||||
};
|
||||
saveData.GotoPoints.Add(dataSet);
|
||||
saveData.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveAllOnSave()
|
||||
{
|
||||
@@ -219,8 +219,8 @@ namespace ReallifeGamemode.Server.Managers
|
||||
user.PositionZ = pos.Z;
|
||||
}
|
||||
|
||||
saveAll.SaveChanges();
|
||||
}
|
||||
}
|
||||
saveAll.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,57 +9,57 @@ using ReallifeGamemode.Server.Shop.SevenEleven;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class ShopManager
|
||||
{
|
||||
public static List<ClotheShop> clotheStores = new List<ClotheShop>();
|
||||
public static List<ItemShop> itemShops = new List<ItemShop>();
|
||||
|
||||
public static void LoadClotheShops()
|
||||
{
|
||||
public static List<ClotheShop> clotheStores = new List<ClotheShop>();
|
||||
public static List<ItemShop> itemShops = new List<ItemShop>();
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
List<SavedBlip> discount = dbContext.Blips.ToList().FindAll(s => s.Name == "Binco" || s.Name == "Discount Store");
|
||||
List<SavedBlip> midclass = dbContext.Blips.ToList().FindAll(s => s.Name == "Suburban");
|
||||
List<SavedBlip> luxury = dbContext.Blips.ToList().FindAll(s => s.Name == "Ponsonbys");
|
||||
|
||||
public static void LoadClotheShops()
|
||||
foreach (var store in discount)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
List<SavedBlip> discount = dbContext.Blips.ToList().FindAll(s => s.Name == "Binco" || s.Name == "Discount Store");
|
||||
List<SavedBlip> midclass = dbContext.Blips.ToList().FindAll(s => s.Name == "Suburban");
|
||||
List<SavedBlip> luxury = dbContext.Blips.ToList().FindAll(s => s.Name == "Ponsonbys");
|
||||
|
||||
foreach (var store in discount)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ClotheShop newShop = new ClotheShop(1, pos);
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
foreach (var store in midclass)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ClotheShop newShop = new ClotheShop(2, pos);
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
foreach (var store in luxury)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ClotheShop newShop = new ClotheShop(3, pos);
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
}
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ClotheShop newShop = new ClotheShop(1, pos);
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
|
||||
public static void LoadItemShops()
|
||||
foreach (var store in midclass)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
int id = 0;
|
||||
List<SavedBlip> shops = dbContext.Blips.ToList().FindAll(s => s.Name == "24/7");
|
||||
foreach (var store in shops)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ItemShop newShop = new ItemShop(pos, id);
|
||||
itemShops.Add(newShop);
|
||||
id++;
|
||||
}
|
||||
NAPI.Util.ConsoleOutput($"Loaded {itemShops.Count}x 24/7");
|
||||
}
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ClotheShop newShop = new ClotheShop(2, pos);
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
foreach (var store in luxury)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ClotheShop newShop = new ClotheShop(3, pos);
|
||||
clotheStores.Add(newShop);
|
||||
NAPI.Util.ConsoleOutput($"Loading ClotheShop {store.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadItemShops()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
int id = 0;
|
||||
List<SavedBlip> shops = dbContext.Blips.ToList().FindAll(s => s.Name == "24/7");
|
||||
foreach (var store in shops)
|
||||
{
|
||||
Vector3 pos = new Vector3(store.PositionX, store.PositionY, store.PositionZ);
|
||||
ItemShop newShop = new ItemShop(pos, id);
|
||||
itemShops.Add(newShop);
|
||||
id++;
|
||||
}
|
||||
NAPI.Util.ConsoleOutput($"Loaded {itemShops.Count}x 24/7");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,29 +5,29 @@ using GTANetworkAPI;
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class TimeManager
|
||||
{
|
||||
private static Timer realTimeTimer;
|
||||
|
||||
public static void StartTimeManager()
|
||||
{
|
||||
private static Timer realTimeTimer;
|
||||
if (realTimeTimer == null)
|
||||
{
|
||||
realTimeTimer = new Timer(1000);
|
||||
realTimeTimer.Elapsed += SetTime;
|
||||
}
|
||||
|
||||
public static void StartTimeManager()
|
||||
{
|
||||
if (realTimeTimer == null)
|
||||
{
|
||||
realTimeTimer = new Timer(1000);
|
||||
realTimeTimer.Elapsed += SetTime;
|
||||
}
|
||||
|
||||
realTimeTimer.Start();
|
||||
}
|
||||
|
||||
public static void PauseTimeManager()
|
||||
{
|
||||
realTimeTimer.Stop();
|
||||
}
|
||||
|
||||
private static void SetTime(object sender, ElapsedEventArgs args)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
NAPI.World.SetTime(now.Hour, now.Minute, now.Second);
|
||||
}
|
||||
realTimeTimer.Start();
|
||||
}
|
||||
|
||||
public static void PauseTimeManager()
|
||||
{
|
||||
realTimeTimer.Stop();
|
||||
}
|
||||
|
||||
private static void SetTime(object sender, ElapsedEventArgs args)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
NAPI.World.SetTime(now.Hour, now.Minute, now.Second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user