added editorconfig and formatted code
This commit is contained in:
124
ReallifeGamemode.Server/.editorconfig
Normal file
124
ReallifeGamemode.Server/.editorconfig
Normal file
@@ -0,0 +1,124 @@
|
||||
# Informationen zu EDITORCONFIG-Dateien finden Sie unter https://aka.ms/editorconfigdocs
|
||||
###############################
|
||||
# Core EditorConfig Options #
|
||||
###############################
|
||||
root = true
|
||||
# All files
|
||||
[*]
|
||||
indent_style = space
|
||||
# Code files
|
||||
[*.{cs,csx,vb,vbx}]
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
charset = utf-8-bom
|
||||
###############################
|
||||
# .NET Coding Conventions #
|
||||
###############################
|
||||
[*.{cs,vb}]
|
||||
# Organize usings
|
||||
dotnet_sort_system_directives_first = true
|
||||
# this. preferences
|
||||
dotnet_style_qualification_for_field = true:warn
|
||||
dotnet_style_qualification_for_property = true:warn
|
||||
dotnet_style_qualification_for_method = true:warn
|
||||
dotnet_style_qualification_for_event = true:warn
|
||||
# Language keywords vs BCL types preferences
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
|
||||
dotnet_style_predefined_type_for_member_access = true:silent
|
||||
# Parentheses preferences
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
|
||||
# Modifier preferences
|
||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
|
||||
dotnet_style_readonly_field = true:suggestion
|
||||
# Expression-level preferences
|
||||
dotnet_style_object_initializer = true:suggestion
|
||||
dotnet_style_collection_initializer = true:suggestion
|
||||
dotnet_style_explicit_tuple_names = true:suggestion
|
||||
dotnet_style_null_propagation = true:suggestion
|
||||
dotnet_style_coalesce_expression = true:suggestion
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
|
||||
dotnet_prefer_inferred_tuple_names = true:suggestion
|
||||
dotnet_prefer_inferred_anonymous_type_member_names = true:suggestion
|
||||
dotnet_style_prefer_auto_properties = true:silent
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
|
||||
dotnet_style_prefer_conditional_expression_over_return = true:silent
|
||||
###############################
|
||||
# Naming Conventions #
|
||||
###############################
|
||||
# Style Definitions
|
||||
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
|
||||
# Use PascalCase for constant fields
|
||||
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
|
||||
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
|
||||
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
|
||||
dotnet_naming_symbols.constant_fields.applicable_kinds = field
|
||||
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.constant_fields.required_modifiers = const
|
||||
###############################
|
||||
# C# Coding Conventions #
|
||||
###############################
|
||||
[*.cs]
|
||||
# var preferences
|
||||
csharp_style_var_for_built_in_types = true:silent
|
||||
csharp_style_var_when_type_is_apparent = true:silent
|
||||
csharp_style_var_elsewhere = true:silent
|
||||
# Expression-bodied members
|
||||
csharp_style_expression_bodied_methods = false:silent
|
||||
csharp_style_expression_bodied_constructors = false:silent
|
||||
csharp_style_expression_bodied_operators = false:silent
|
||||
csharp_style_expression_bodied_properties = true:silent
|
||||
csharp_style_expression_bodied_indexers = true:silent
|
||||
csharp_style_expression_bodied_accessors = true:silent
|
||||
# Pattern matching preferences
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
|
||||
# Null-checking preferences
|
||||
csharp_style_throw_expression = true:suggestion
|
||||
csharp_style_conditional_delegate_call = true:suggestion
|
||||
# Modifier preferences
|
||||
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
|
||||
# Expression-level preferences
|
||||
csharp_prefer_braces = true:silent
|
||||
csharp_style_deconstructed_variable_declaration = true:suggestion
|
||||
csharp_prefer_simple_default_expression = true:suggestion
|
||||
csharp_style_pattern_local_over_anonymous_function = true:suggestion
|
||||
csharp_style_inlined_variable_declaration = true:suggestion
|
||||
###############################
|
||||
# C# Formatting Rules #
|
||||
###############################
|
||||
# New line preferences
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
# Indentation preferences
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_switch_labels = true
|
||||
csharp_indent_labels = flush_left
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
# Wrapping preferences
|
||||
csharp_preserve_single_line_statements = true
|
||||
csharp_preserve_single_line_blocks = true
|
||||
###############################
|
||||
# VB Coding Conventions #
|
||||
###############################
|
||||
[*.vb]
|
||||
# Modifier preferences
|
||||
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion
|
||||
@@ -7,92 +7,92 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public abstract class BusinessBase : IBankAccountOwner
|
||||
public abstract class BusinessBase : IBankAccountOwner
|
||||
{
|
||||
private TextLabel _informationLabel;
|
||||
private ColShape _colShape;
|
||||
|
||||
public abstract int Id { get; }
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract Vector3 Position { get; }
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
private TextLabel _informationLabel;
|
||||
private ColShape _colShape;
|
||||
|
||||
public abstract int Id { get; }
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract Vector3 Position { get; }
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
_informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
||||
NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255));
|
||||
|
||||
_colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f);
|
||||
_colShape.OnEntityEnterColShape += EntityEnterBusinessColShape;
|
||||
_colShape.OnEntityExitColShape += EntityExitBusinessColShape;
|
||||
|
||||
if (GetBankAccount() == null)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
dbContext.BusinessBankAccounts.Add(new BusinessBankAccount()
|
||||
{
|
||||
BusinessId = Id,
|
||||
Balance = 0
|
||||
});
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EntityExitBusinessColShape(ColShape colShape, Client client)
|
||||
{
|
||||
client.TriggerEvent("business_removeHelp", true);
|
||||
}
|
||||
|
||||
private void EntityEnterBusinessColShape(ColShape colShape, Client client)
|
||||
{
|
||||
if (GetOwner() != null && GetOwner().Id == client.GetUser()?.Id && !client.IsInVehicle)
|
||||
{
|
||||
client.TriggerEvent("business_showHelp", Name, (GetBankAccount()?.Balance ?? 0).ToMoneyString());
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(int? money = null)
|
||||
{
|
||||
if (money == null) money = GetBankAccount()?.Balance ?? 0;
|
||||
User owner = GetOwner();
|
||||
string infoText = Name + "\n" + "Besitzer: " + (owner == null ? "Niemand" : owner.Name) + "\nKasse: ~g~" + money.ToMoneyString();
|
||||
_informationLabel.Text = infoText;
|
||||
}
|
||||
|
||||
public User GetOwner(DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Load();
|
||||
}
|
||||
else
|
||||
{
|
||||
return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
_informationLabel = NAPI.TextLabel.CreateTextLabel(Name, Position.Add(new Vector3(0, 0, 0.5)), 20.0f, 1.3f, 0, new Color(255, 255, 255));
|
||||
NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, Position.Subtract(new Vector3(0, 0, 1.5)), new Vector3(), new Vector3(), 1f, new Color(255, 255, 255));
|
||||
|
||||
_colShape = NAPI.ColShape.CreateSphereColShape(Position.Subtract(new Vector3(0, 0, 1.5)), 3f);
|
||||
_colShape.OnEntityEnterColShape += EntityEnterBusinessColShape;
|
||||
_colShape.OnEntityExitColShape += EntityExitBusinessColShape;
|
||||
|
||||
if (GetBankAccount() == null)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput("Creating Bank Account for Business: " + Name);
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
dbContext.BusinessBankAccounts.Add(new BusinessBankAccount()
|
||||
{
|
||||
BusinessId = Id,
|
||||
Balance = 0
|
||||
});
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EntityExitBusinessColShape(ColShape colShape, Client client)
|
||||
{
|
||||
client.TriggerEvent("business_removeHelp", true);
|
||||
}
|
||||
|
||||
private void EntityEnterBusinessColShape(ColShape colShape, Client client)
|
||||
{
|
||||
if (GetOwner() != null && GetOwner().Id == client.GetUser()?.Id && !client.IsInVehicle)
|
||||
{
|
||||
client.TriggerEvent("business_showHelp", Name, (GetBankAccount()?.Balance ?? 0).ToMoneyString());
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(int? money = null)
|
||||
{
|
||||
if (money == null) money = GetBankAccount()?.Balance ?? 0;
|
||||
User owner = GetOwner();
|
||||
string infoText = Name + "\n" + "Besitzer: " + (owner == null ? "Niemand" : owner.Name) + "\nKasse: ~g~" + money.ToMoneyString();
|
||||
_informationLabel.Text = infoText;
|
||||
}
|
||||
|
||||
public User GetOwner(DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Load();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public abstract class CarDealerBusinessBase : BusinessBase
|
||||
{
|
||||
public abstract Vector3 CarSpawnPositon { get; }
|
||||
public abstract float CarSpawnHeading { get; }
|
||||
}
|
||||
public abstract class CarDealerBusinessBase : BusinessBase
|
||||
{
|
||||
public abstract Vector3 CarSpawnPositon { get; }
|
||||
public abstract float CarSpawnHeading { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,17 +5,17 @@ using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public class ShopBusiness : BusinessBase
|
||||
public class ShopBusiness : BusinessBase
|
||||
{
|
||||
public override int Id => 2;
|
||||
|
||||
public override string Name => "24/7 Business";
|
||||
|
||||
public override Vector3 Position => new Vector3(-443, 1134, 326);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public override int Id => 2;
|
||||
|
||||
public override string Name => "24/7 Business";
|
||||
|
||||
public override Vector3 Position => new Vector3(-443, 1134, 326);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,17 +5,17 @@ using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public class TelefonBusiness : BusinessBase
|
||||
public class TelefonBusiness : BusinessBase
|
||||
{
|
||||
public override int Id => 1;
|
||||
|
||||
public override string Name => "Telefon Business";
|
||||
|
||||
public override Vector3 Position => new Vector3(-423, 1130, 326);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public override int Id => 1;
|
||||
|
||||
public override string Name => "Telefon Business";
|
||||
|
||||
public override Vector3 Position => new Vector3(-423, 1130, 326);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,21 @@ using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Business
|
||||
{
|
||||
public class VapidCarDealerBusiness : CarDealerBusinessBase
|
||||
public class VapidCarDealerBusiness : CarDealerBusinessBase
|
||||
{
|
||||
public override int Id => 3;
|
||||
|
||||
public override string Name => "Vapid Autohaus";
|
||||
|
||||
public override Vector3 Position => new Vector3(-177, -1156, 23);
|
||||
|
||||
public override Vector3 CarSpawnPositon => new Vector3(-222, -1162, 22.5);
|
||||
|
||||
public override float CarSpawnHeading => 356.6f;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
public override int Id => 3;
|
||||
|
||||
public override string Name => "Vapid Autohaus";
|
||||
|
||||
public override Vector3 Position => new Vector3(-177, -1156, 23);
|
||||
|
||||
public override Vector3 CarSpawnPositon => new Vector3(-222, -1162, 22.5);
|
||||
|
||||
public override float CarSpawnHeading => 356.6f;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Classes
|
||||
{
|
||||
public class TempBlip
|
||||
{
|
||||
public byte Color { get; set; }
|
||||
public string Name { get; set; }
|
||||
public byte Transparency { get; set; }
|
||||
public bool ShortRange { get; set; }
|
||||
public uint Sprite { get; set; }
|
||||
public float Scale { get; set; }
|
||||
}
|
||||
public class TempBlip
|
||||
{
|
||||
public byte Color { get; set; }
|
||||
public string Name { get; set; }
|
||||
public byte Transparency { get; set; }
|
||||
public bool ShortRange { get; set; }
|
||||
public uint Sprite { get; set; }
|
||||
public float Scale { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,236 +15,236 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
class FactionCommands : Script
|
||||
class FactionCommands : Script
|
||||
{
|
||||
#region Chat Commands
|
||||
|
||||
[Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionF(Client player, string message)
|
||||
{
|
||||
#region Chat Commands
|
||||
Faction f = player.GetUser()?.Faction;
|
||||
if (f == null || f.StateOwned)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
[Command("f", "~m~Benutzung: ~s~/f [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionF(Client player, string message)
|
||||
{
|
||||
Faction f = player.GetUser()?.Faction;
|
||||
if (f == null || f.StateOwned)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMessage = "!{02FCFF}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + " )) **";
|
||||
ChatService.BroadcastFaction(broadcastMessage, f);
|
||||
}
|
||||
|
||||
[Command("r", "~m~Benutzung: ~s~/r [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionR(Client player, string message)
|
||||
{
|
||||
Entities.Faction f = player.GetUser()?.Faction;
|
||||
if (f == null || !f.StateOwned)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMessage = "!{33AA33}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **";
|
||||
ChatService.BroadcastFaction(broadcastMessage, f);
|
||||
}
|
||||
|
||||
[Command("d", "~m~Benutzung: ~s~/d [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionD(Client player, string message)
|
||||
{
|
||||
Faction f = player.GetUser()?.Faction;
|
||||
if (f == null || !f.StateOwned)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMessage = "!{CC3333}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **";
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.StateOwned));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Leader Commands
|
||||
[Command("giverank", "~m~Benutzung: ~s~/giverank [Name] [Rang]", GreedyArg = true)]
|
||||
public void CmdFactionGiverank(Client player, string name, string rank)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(name);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.GetUser()?.FactionId != player.GetUser()?.FactionId)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht in deiner Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
FactionRank fr = dbContext.FactionRanks.FirstOrDefault(r => r.RankName == rank && r.FactionId == player.GetUser(dbContext).FactionId);
|
||||
if (fr == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Rang existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
target.GetUser(dbContext).FactionRankId = fr.Id;
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " den Rang '" + fr.RankName + "' gegeben.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du hast von " + player.Name + " den Rang '" + fr.RankName + "' erhalten.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionLc(Client player, string message)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMsg = "~y~[" + player.GetUser().Faction.Name + "] " + player.Name + ": " + message;
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
if (p.GetUser()?.FactionLeader ?? false) ChatService.SendMessage(p, broadcastMsg);
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
#region Sanitäter Commands
|
||||
|
||||
[Command("revive", "~m~Benutzung: ~s~/revive")]
|
||||
public void CmdFactionMedicRevive(Client player)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionId != 2)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst in einem Auto nicht wiederbeleben");
|
||||
return;
|
||||
}
|
||||
|
||||
var nearPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(2, player);
|
||||
var deadPlayer = nearPlayers.Where(i => i.GetData("isDead") == true).FirstOrDefault();
|
||||
if (player == deadPlayer)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst dich nicht selbst wiederbeleben");
|
||||
return;
|
||||
}
|
||||
player.PlayAnimation("amb@medic@standing@kneel@enter", "enter", 0);
|
||||
|
||||
deadPlayer.TriggerEvent("onPlayerRevived");
|
||||
deadPlayer.SendNotification("Du wurdest von ~r~" + player.Name + "~s~ wiederbelebt.");
|
||||
deadPlayer.SetData("isDead", false);
|
||||
NAPI.Player.SpawnPlayer(deadPlayer, deadPlayer.Position);
|
||||
deadPlayer.Health = 50;
|
||||
|
||||
MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == deadPlayer.Name);
|
||||
Medic.RemoveTaskFromList(task);
|
||||
}
|
||||
|
||||
[Command("heal", "~m~Benutzung: ~s~/heal [Spieler]")] //TODO Eventuell noch mit Geldbetrag wie bei SA:MP
|
||||
public void CmdFactionMedicHealive(Client player, string receiver)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionId != 2)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst in einem Auto nicht heilen");
|
||||
return;
|
||||
}
|
||||
Client target = ClientService.GetClientByNameOrId(receiver);
|
||||
target.Health = 100;
|
||||
target.SendNotification("Du wurdest von ~g~" + player.Name + " ~s~geheilt.", false);
|
||||
player.SendNotification("Du hast~g~" + target.Name + " ~s~geheilt.", false);
|
||||
}
|
||||
#endregion
|
||||
#region Staatsfraktionen (LSPD / FBI) Commands
|
||||
[Command("wanted", "~m~Benutzung: ~s~/wa(nted) [Name / ID] [Anzahl] [Grund]", Alias = "wa", GreedyArg = true)]
|
||||
public void CmdFactionWanted(Client player, string nameOrId, int amount, string reason)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if (user == null || (user.FactionId != 1 && user.FactionId != 2))
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if(amount <= 0)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Es muss eine positive Wantedanzahl vergeben werden");
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
User targetUser = target.GetUser();
|
||||
targetUser.GiveWanteds(player, amount, reason);
|
||||
}
|
||||
|
||||
[Command("clear", "~m~Benutzung: ~s~/clear [Name / ID] [Grund]")]
|
||||
public void CmdFactionClear(Client player, string nameOrId, string reason)
|
||||
{
|
||||
|
||||
User user = player.GetUser();
|
||||
if (user == null || (user.FactionId != 1 && user.FactionId != 2))
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User targetUser = target.GetUser(dbContext);
|
||||
if(targetUser.Wanteds == 0)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Der Spieler hat keine Wanteds");
|
||||
return;
|
||||
}
|
||||
|
||||
targetUser.Wanteds = 0;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Global Fraktions Commands
|
||||
#endregion
|
||||
string broadcastMessage = "!{02FCFF}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + " )) **";
|
||||
ChatService.BroadcastFaction(broadcastMessage, f);
|
||||
}
|
||||
|
||||
[Command("r", "~m~Benutzung: ~s~/r [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionR(Client player, string message)
|
||||
{
|
||||
Entities.Faction f = player.GetUser()?.Faction;
|
||||
if (f == null || !f.StateOwned)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMessage = "!{33AA33}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **";
|
||||
ChatService.BroadcastFaction(broadcastMessage, f);
|
||||
}
|
||||
|
||||
[Command("d", "~m~Benutzung: ~s~/d [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionD(Client player, string message)
|
||||
{
|
||||
Faction f = player.GetUser()?.Faction;
|
||||
if (f == null || !f.StateOwned)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMessage = "!{CC3333}** " + player.GetUser().GetFactionRank().RankName + " " + player.Name + ": " + message + ", over **";
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
ChatService.BroadcastFaction(broadcastMessage, context.Factions.ToList().FindAll(c => c.StateOwned));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Leader Commands
|
||||
[Command("giverank", "~m~Benutzung: ~s~/giverank [Name] [Rang]", GreedyArg = true)]
|
||||
public void CmdFactionGiverank(Client player, string name, string rank)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(name);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.GetUser()?.FactionId != player.GetUser()?.FactionId)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht in deiner Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
FactionRank fr = dbContext.FactionRanks.FirstOrDefault(r => r.RankName == rank && r.FactionId == player.GetUser(dbContext).FactionId);
|
||||
if (fr == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Rang existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
target.GetUser(dbContext).FactionRankId = fr.Id;
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " den Rang '" + fr.RankName + "' gegeben.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du hast von " + player.Name + " den Rang '" + fr.RankName + "' erhalten.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[Command("lc", "~m~Benutzung: ~s~/lc [Nachricht]", GreedyArg = true)]
|
||||
public void CmdFactionLc(Client player, string message)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
|
||||
string broadcastMsg = "~y~[" + player.GetUser().Faction.Name + "] " + player.Name + ": " + message;
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
if (p.GetUser()?.FactionLeader ?? false) ChatService.SendMessage(p, broadcastMsg);
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
#region Sanitäter Commands
|
||||
|
||||
[Command("revive", "~m~Benutzung: ~s~/revive")]
|
||||
public void CmdFactionMedicRevive(Client player)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionId != 2)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst in einem Auto nicht wiederbeleben");
|
||||
return;
|
||||
}
|
||||
|
||||
var nearPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(2, player);
|
||||
var deadPlayer = nearPlayers.Where(i => i.GetData("isDead") == true).FirstOrDefault();
|
||||
if (player == deadPlayer)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst dich nicht selbst wiederbeleben");
|
||||
return;
|
||||
}
|
||||
player.PlayAnimation("amb@medic@standing@kneel@enter", "enter", 0);
|
||||
|
||||
deadPlayer.TriggerEvent("onPlayerRevived");
|
||||
deadPlayer.SendNotification("Du wurdest von ~r~" + player.Name + "~s~ wiederbelebt.");
|
||||
deadPlayer.SetData("isDead", false);
|
||||
NAPI.Player.SpawnPlayer(deadPlayer, deadPlayer.Position);
|
||||
deadPlayer.Health = 50;
|
||||
|
||||
MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == deadPlayer.Name);
|
||||
Medic.RemoveTaskFromList(task);
|
||||
}
|
||||
|
||||
[Command("heal", "~m~Benutzung: ~s~/heal [Spieler]")] //TODO Eventuell noch mit Geldbetrag wie bei SA:MP
|
||||
public void CmdFactionMedicHealive(Client player, string receiver)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionId != 2)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
if (player.IsInVehicle)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst in einem Auto nicht heilen");
|
||||
return;
|
||||
}
|
||||
Client target = ClientService.GetClientByNameOrId(receiver);
|
||||
target.Health = 100;
|
||||
target.SendNotification("Du wurdest von ~g~" + player.Name + " ~s~geheilt.", false);
|
||||
player.SendNotification("Du hast~g~" + target.Name + " ~s~geheilt.", false);
|
||||
}
|
||||
#endregion
|
||||
#region Staatsfraktionen (LSPD / FBI) Commands
|
||||
[Command("wanted", "~m~Benutzung: ~s~/wa(nted) [Name / ID] [Anzahl] [Grund]", Alias = "wa", GreedyArg = true)]
|
||||
public void CmdFactionWanted(Client player, string nameOrId, int amount, string reason)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if (user == null || (user.FactionId != 1 && user.FactionId != 2))
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (amount <= 0)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Es muss eine positive Wantedanzahl vergeben werden");
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
User targetUser = target.GetUser();
|
||||
targetUser.GiveWanteds(player, amount, reason);
|
||||
}
|
||||
|
||||
[Command("clear", "~m~Benutzung: ~s~/clear [Name / ID] [Grund]")]
|
||||
public void CmdFactionClear(Client player, string nameOrId, string reason)
|
||||
{
|
||||
|
||||
User user = player.GetUser();
|
||||
if (user == null || (user.FactionId != 1 && user.FactionId != 2))
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User targetUser = target.GetUser(dbContext);
|
||||
if (targetUser.Wanteds == 0)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Der Spieler hat keine Wanteds");
|
||||
return;
|
||||
}
|
||||
|
||||
targetUser.Wanteds = 0;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Global Fraktions Commands
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,24 +8,24 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
class GroupCommands : Script
|
||||
class GroupCommands : Script
|
||||
{
|
||||
#region Chat Commands
|
||||
[Command("g", "~m~Benutzung: ~s~/g [Nachricht]", GreedyArg = true)]
|
||||
public void CmdGroupG(Client player, string message)
|
||||
{
|
||||
#region Chat Commands
|
||||
[Command("g", "~m~Benutzung: ~s~/g [Nachricht]", GreedyArg = true)]
|
||||
public void CmdGroupG(Client player, string message)
|
||||
{
|
||||
Entities.Group group = player.GetUser().Group;
|
||||
if (group == null)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
Entities.Group group = player.GetUser().Group;
|
||||
if (group == null)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
message = $"{player.Name}: {message}";
|
||||
message = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
message = $"{player.Name}: {message}";
|
||||
|
||||
ChatService.BroadcastGroup(message, group);
|
||||
}
|
||||
#endregion
|
||||
ChatService.BroadcastGroup(message, group);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,45 +9,45 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
class UserCommands : Script
|
||||
class UserCommands : Script
|
||||
{
|
||||
|
||||
[Command("car", "~m~Benutzung: ~s~/car")]
|
||||
public void CmdUserCar(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (!player.IsInVehicle) return;
|
||||
|
||||
Vehicle pVeh = player.Vehicle;
|
||||
|
||||
if (pVeh.GetServerVehicle() is ServerVehicle veh)
|
||||
{
|
||||
if (player.GetUser().IsAdmin(AdminLevel.SUPPORTER))
|
||||
{
|
||||
ChatService.SendMessage(player, "~m~" + ((VehicleHash)pVeh.Model) + " | " + veh.ToString() + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ChatService.SendMessage(player, "~m~" + ((VehicleHash)pVeh.Model) + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
}
|
||||
|
||||
[Command("paycheck", "~m~Benutzung: ~s~/paycheck")]
|
||||
public void CmdUserPaycheck(Client client)
|
||||
{
|
||||
|
||||
[Command("car", "~m~Benutzung: ~s~/car")]
|
||||
public void CmdUserCar(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (!player.IsInVehicle) return;
|
||||
|
||||
Vehicle pVeh = player.Vehicle;
|
||||
|
||||
if (pVeh.GetServerVehicle() is ServerVehicle veh)
|
||||
{
|
||||
if (player.GetUser().IsAdmin(AdminLevel.SUPPORTER))
|
||||
{
|
||||
ChatService.SendMessage(player, "~m~" + ((VehicleHash)pVeh.Model) + " | " + veh.ToString() + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ChatService.SendMessage(player, "~m~" + ((VehicleHash)pVeh.Model) + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
}
|
||||
|
||||
[Command("paycheck", "~m~Benutzung: ~s~/paycheck")]
|
||||
public void CmdUserPaycheck(Client client)
|
||||
{
|
||||
|
||||
User user = client.GetUser();
|
||||
if (Economy.Paychecks.ContainsKey(user.Id))
|
||||
{
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK] -------------------------------------------------------");
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Lohn : ~g~+$" + Economy.Paychecks[user.Id].Wage);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Finanzhilfe : ~g~+$" + (int)Economy.Paychecks[user.Id].FinancialHelp);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Fahrzeugsteuer : ~r~-$" + Economy.Paychecks[user.Id].VehicleTaxation);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Grundsteuer (Haus) : ~r~-$" + Economy.Paychecks[user.Id].PropertyTaxation);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Einkommen Steuer : ~r~" + (int)(Economy.Paychecks[user.Id].FinancialInterest * 100) + " %");
|
||||
ChatService.SendMessage(client, "");
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Ausgaben : ~r~-$" + (Economy.Paychecks[user.Id].Wage - Economy.Paychecks[user.Id].Amount));
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK] -------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
User user = client.GetUser();
|
||||
if (Economy.Paychecks.ContainsKey(user.Id))
|
||||
{
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK] -------------------------------------------------------");
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Lohn : ~g~+$" + Economy.Paychecks[user.Id].Wage);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Finanzhilfe : ~g~+$" + (int)Economy.Paychecks[user.Id].FinancialHelp);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Fahrzeugsteuer : ~r~-$" + Economy.Paychecks[user.Id].VehicleTaxation);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Grundsteuer (Haus) : ~r~-$" + Economy.Paychecks[user.Id].PropertyTaxation);
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Einkommen Steuer : ~r~" + (int)(Economy.Paychecks[user.Id].FinancialInterest * 100) + " %");
|
||||
ChatService.SendMessage(client, "");
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK]~s~ Ausgaben : ~r~-$" + (Economy.Paychecks[user.Id].Wage - Economy.Paychecks[user.Id].Amount));
|
||||
ChatService.SendMessage(client, "~g~[PAYCHECK] -------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,27 +16,27 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class ATM : IBankAccountOwner, IBankAccount
|
||||
public class ATM : IBankAccountOwner, IBankAccount
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public int Balance { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Z { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(X, Y, Z);
|
||||
|
||||
public bool Faulty { get; set; } = false;
|
||||
public bool Active { get; set; } = true;
|
||||
|
||||
public string Name => throw new NotImplementedException();
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public int Balance { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Z { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(X, Y, Z);
|
||||
|
||||
public bool Faulty { get; set; } = false;
|
||||
public bool Active { get; set; } = true;
|
||||
|
||||
public string Name => throw new NotImplementedException();
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
databaseContext = databaseContext ?? new DatabaseContext();
|
||||
return databaseContext.ATMs.Where(a => a.Id == this.Id).First();
|
||||
}
|
||||
databaseContext = databaseContext ?? new DatabaseContext();
|
||||
return databaseContext.ATMs.Where(a => a.Id == this.Id).First();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,20 +13,20 @@ using ReallifeGamemode.Server.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class Ban
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class Ban
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public string Reason { get; set; }
|
||||
public string BannedBy { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public string BannedBy { get; set; }
|
||||
|
||||
public int Applied { get; set; }
|
||||
public int UntilDateTime { get; set; }
|
||||
}
|
||||
public int Applied { get; set; }
|
||||
public int UntilDateTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,34 +6,34 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class BusRoute
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class BusRoute
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public List<BusRoutePoint> RoutePoints { get; set; }
|
||||
}
|
||||
public List<BusRoutePoint> RoutePoints { get; set; }
|
||||
}
|
||||
|
||||
public class BusRoutePoint
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class BusRoutePoint
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public float X { get; set; }
|
||||
public float X { get; set; }
|
||||
|
||||
public float Y { get; set; }
|
||||
public float Y { get; set; }
|
||||
|
||||
public float Z { get; set; }
|
||||
public float Z { get; set; }
|
||||
|
||||
[ForeignKey("BusRouteId")]
|
||||
public int? BusRouteId { get; set; }
|
||||
[ForeignKey("BusRouteId")]
|
||||
public int? BusRouteId { get; set; }
|
||||
|
||||
public BusRoute BusRoute { get; set; }
|
||||
}
|
||||
public BusRoute BusRoute { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,24 +9,24 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class BusinessBankAccount : IBankAccount
|
||||
public class BusinessBankAccount : IBankAccount
|
||||
{
|
||||
[NotMapped]
|
||||
private int _balance;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public int Balance
|
||||
{
|
||||
[NotMapped]
|
||||
private int _balance;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public int Balance
|
||||
{
|
||||
get => _balance;
|
||||
set
|
||||
{
|
||||
_balance = value;
|
||||
BusinessManager.GetBusiness(BusinessId).Update(value);
|
||||
}
|
||||
}
|
||||
|
||||
public int BusinessId { get; set; }
|
||||
get => _balance;
|
||||
set
|
||||
{
|
||||
_balance = value;
|
||||
BusinessManager.GetBusiness(BusinessId).Update(value);
|
||||
}
|
||||
}
|
||||
|
||||
public int BusinessId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,74 +9,74 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class Character
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class Character
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public bool Gender { get; set; }
|
||||
public byte Father { get; set; }
|
||||
public byte Mother { get; set; }
|
||||
public float Similarity { get; set; }
|
||||
public float SkinSimilarity { get; set; }
|
||||
public bool Gender { get; set; }
|
||||
public byte Father { get; set; }
|
||||
public byte Mother { get; set; }
|
||||
public float Similarity { get; set; }
|
||||
public float SkinSimilarity { get; set; }
|
||||
|
||||
public float NoseWidth { get; set; }
|
||||
public float NoseBottomHeight { get; set; }
|
||||
public float NoseTipLength { get; set; }
|
||||
public float NoseBridgeDepth { get; set; }
|
||||
public float NoseTipHeight { get; set; }
|
||||
public float NoseBroken { get; set; }
|
||||
public float BrowHeight { get; set; }
|
||||
public float BrowDepth { get; set; }
|
||||
public float CheekboneHeight { get; set; }
|
||||
public float CheekboneWidth { get; set; }
|
||||
public float CheekDepth { get; set; }
|
||||
public float EyeSize { get; set; }
|
||||
public float LipThickness { get; set; }
|
||||
public float JawWidth { get; set; }
|
||||
public float JawShape { get; set; }
|
||||
public float ChinHeight { get; set; }
|
||||
public float ChinDepth { get; set; }
|
||||
public float ChinWidth { get; set; }
|
||||
public float ChinIndent { get; set; }
|
||||
public float NeckWidth { get; set; }
|
||||
public float NoseWidth { get; set; }
|
||||
public float NoseBottomHeight { get; set; }
|
||||
public float NoseTipLength { get; set; }
|
||||
public float NoseBridgeDepth { get; set; }
|
||||
public float NoseTipHeight { get; set; }
|
||||
public float NoseBroken { get; set; }
|
||||
public float BrowHeight { get; set; }
|
||||
public float BrowDepth { get; set; }
|
||||
public float CheekboneHeight { get; set; }
|
||||
public float CheekboneWidth { get; set; }
|
||||
public float CheekDepth { get; set; }
|
||||
public float EyeSize { get; set; }
|
||||
public float LipThickness { get; set; }
|
||||
public float JawWidth { get; set; }
|
||||
public float JawShape { get; set; }
|
||||
public float ChinHeight { get; set; }
|
||||
public float ChinDepth { get; set; }
|
||||
public float ChinWidth { get; set; }
|
||||
public float ChinIndent { get; set; }
|
||||
public float NeckWidth { get; set; }
|
||||
|
||||
public byte Blemishes { get; set; }
|
||||
public float BlemishesOpacity { get; set; }
|
||||
public byte FacialHair { get; set; }
|
||||
public float FacialHairOpacity { get; set; }
|
||||
public byte Eyebrows { get; set; }
|
||||
public float EyebrowsOpacity { get; set; }
|
||||
public byte Ageing { get; set; }
|
||||
public float AgeingOpacity { get; set; }
|
||||
public byte Makeup { get; set; }
|
||||
public float MakeupOpacity { get; set; }
|
||||
public byte Blush { get; set; }
|
||||
public float BlushOpacity { get; set; }
|
||||
public byte Complexion { get; set; }
|
||||
public float ComplexionOpacity { get; set; }
|
||||
public byte SunDamage { get; set; }
|
||||
public float SunDamageOpacity { get; set; }
|
||||
public byte Lipstick { get; set; }
|
||||
public float LipstickOpacity { get; set; }
|
||||
public byte Freckles { get; set; }
|
||||
public float FrecklesOpacity { get; set; }
|
||||
public byte ChestHair { get; set; }
|
||||
public float ChestHairOpacity { get; set; }
|
||||
public byte Blemishes { get; set; }
|
||||
public float BlemishesOpacity { get; set; }
|
||||
public byte FacialHair { get; set; }
|
||||
public float FacialHairOpacity { get; set; }
|
||||
public byte Eyebrows { get; set; }
|
||||
public float EyebrowsOpacity { get; set; }
|
||||
public byte Ageing { get; set; }
|
||||
public float AgeingOpacity { get; set; }
|
||||
public byte Makeup { get; set; }
|
||||
public float MakeupOpacity { get; set; }
|
||||
public byte Blush { get; set; }
|
||||
public float BlushOpacity { get; set; }
|
||||
public byte Complexion { get; set; }
|
||||
public float ComplexionOpacity { get; set; }
|
||||
public byte SunDamage { get; set; }
|
||||
public float SunDamageOpacity { get; set; }
|
||||
public byte Lipstick { get; set; }
|
||||
public float LipstickOpacity { get; set; }
|
||||
public byte Freckles { get; set; }
|
||||
public float FrecklesOpacity { get; set; }
|
||||
public byte ChestHair { get; set; }
|
||||
public float ChestHairOpacity { get; set; }
|
||||
|
||||
public byte Hair { get; set; }
|
||||
public byte HairColor { get; set; }
|
||||
public byte HairHighlightColor { get; set; }
|
||||
public byte EyebrowColor { get; set; }
|
||||
public byte BeardColor { get; set; }
|
||||
public byte EyeColor { get; set; }
|
||||
public byte BlushColor { get; set; }
|
||||
public byte LipstickColor { get; set; }
|
||||
public byte ChestHairColor { get; set; }
|
||||
}
|
||||
public byte Hair { get; set; }
|
||||
public byte HairColor { get; set; }
|
||||
public byte HairHighlightColor { get; set; }
|
||||
public byte EyebrowColor { get; set; }
|
||||
public byte BeardColor { get; set; }
|
||||
public byte EyeColor { get; set; }
|
||||
public byte BlushColor { get; set; }
|
||||
public byte LipstickColor { get; set; }
|
||||
public byte ChestHairColor { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,21 +9,21 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class CharacterCloth
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class CharacterCloth
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public bool Duty { get; set; }
|
||||
public bool Duty { get; set; }
|
||||
|
||||
public byte SlotType { get; set; }
|
||||
public int SlotId { get; set; }
|
||||
public int ClothId { get; set; }
|
||||
public int Texture { get; set; }
|
||||
}
|
||||
public byte SlotType { get; set; }
|
||||
public int SlotId { get; set; }
|
||||
public int ClothId { get; set; }
|
||||
public int Texture { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class ClothCombination
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public bool Gender { get; set; }
|
||||
public int Top { get; set; }
|
||||
public int Torso { get; set; }
|
||||
public int Undershirt { get; set; }
|
||||
}
|
||||
public class ClothCombination
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public bool Gender { get; set; }
|
||||
public int Top { get; set; }
|
||||
public int Torso { get; set; }
|
||||
public int Undershirt { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,24 +13,24 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class Door
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Category { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public int Model { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Z { get; set; }
|
||||
public float Radius { get; set; }
|
||||
public class Door
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Category { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public int Model { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Z { get; set; }
|
||||
public float Radius { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(X, Y, Z);
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(X, Y, Z);
|
||||
|
||||
[ForeignKey("FactionId")]
|
||||
public int? FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
}
|
||||
[ForeignKey("FactionId")]
|
||||
public int? FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,20 +12,20 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class DutyCloth
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class DutyCloth
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("Faction")]
|
||||
public int FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
[ForeignKey("Faction")]
|
||||
public int FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public bool Gender { get; set; }
|
||||
public bool Gender { get; set; }
|
||||
|
||||
public byte SlotType { get; set; }
|
||||
public int SlotId { get; set; }
|
||||
public int ClothId { get; set; }
|
||||
}
|
||||
public byte SlotType { get; set; }
|
||||
public int SlotId { get; set; }
|
||||
public int ClothId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,28 +12,28 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class Faction : IBankAccountOwner
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Name { get; set; }
|
||||
public bool StateOwned { get; set; }
|
||||
public class Faction : IBankAccountOwner
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Name { get; set; }
|
||||
public bool StateOwned { get; set; }
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
return databaseContext.FactionBankAccounts.FirstOrDefault(u => u.FactionId == this.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return databaseContext.FactionBankAccounts.FirstOrDefault(u => u.FactionId == this.Id);
|
||||
}
|
||||
return databaseContext.FactionBankAccounts.FirstOrDefault(u => u.FactionId == this.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return databaseContext.FactionBankAccounts.FirstOrDefault(u => u.FactionId == this.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,19 +13,19 @@ using System.Text;
|
||||
*/
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class FactionBankAccount : IBankAccount
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("Faction")]
|
||||
public int FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
[StringLength(12)]
|
||||
public string Bic { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Iban { get; set; }
|
||||
public int Balance { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
public class FactionBankAccount : IBankAccount
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("Faction")]
|
||||
public int FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
[StringLength(12)]
|
||||
public string Bic { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Iban { get; set; }
|
||||
public int Balance { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,23 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class FactionRank
|
||||
public class FactionRank
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string RankName { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
|
||||
public int FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public Faction GetFaction()
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string RankName { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
|
||||
public int FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public Faction GetFaction()
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
|
||||
}
|
||||
}
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,24 +10,24 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
[Table("FactionVehicles")]
|
||||
public class FactionVehicle : ServerVehicle
|
||||
[Table("FactionVehicles")]
|
||||
public class FactionVehicle : ServerVehicle
|
||||
{
|
||||
[ForeignKey("Faction")]
|
||||
public int? FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public Faction GetFaction()
|
||||
{
|
||||
[ForeignKey("Faction")]
|
||||
public int? FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public Faction GetFaction()
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Fraktions Fahrzeug | Fraktion: " + GetFaction().Name;
|
||||
}
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Fraktions Fahrzeug | Fraktion: " + GetFaction().Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,16 @@ using ReallifeGamemode.Server.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class GotoPoint
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Description { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Z { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
public class GotoPoint
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Description { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Z { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,42 +10,42 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class Group : IBankAccountOwner
|
||||
public class Group : IBankAccountOwner
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
GroupBankAccount bankAccount = null;
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
GroupBankAccount bankAccount = null;
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
bankAccount = databaseContext.GroupBankAccounts.Include(g => g.Group).Where(g => g.Group == this).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bankAccount = databaseContext.GroupBankAccounts.Include(g => g.Group).Where(g => g.Group == this).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (bankAccount == null)
|
||||
{
|
||||
bankAccount = new GroupBankAccount
|
||||
{
|
||||
Group = this,
|
||||
Balance = 0
|
||||
};
|
||||
|
||||
databaseContext.GroupBankAccounts.Add(bankAccount);
|
||||
databaseContext.SaveChanges();
|
||||
}
|
||||
|
||||
return bankAccount;
|
||||
bankAccount = databaseContext.GroupBankAccounts.Include(g => g.Group).Where(g => g.Group == this).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bankAccount = databaseContext.GroupBankAccounts.Include(g => g.Group).Where(g => g.Group == this).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (bankAccount == null)
|
||||
{
|
||||
bankAccount = new GroupBankAccount
|
||||
{
|
||||
Group = this,
|
||||
Balance = 0
|
||||
};
|
||||
|
||||
databaseContext.GroupBankAccounts.Add(bankAccount);
|
||||
databaseContext.SaveChanges();
|
||||
}
|
||||
|
||||
return bankAccount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class GroupBankAccount : IBankAccount
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class GroupBankAccount : IBankAccount
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public Group Group { get; set; }
|
||||
public Group Group { get; set; }
|
||||
|
||||
public int Balance { get; set; }
|
||||
}
|
||||
public int Balance { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,17 +8,17 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class GroupVehicle : ServerVehicle
|
||||
public class GroupVehicle : ServerVehicle
|
||||
{
|
||||
public Group Group { get; set; }
|
||||
|
||||
[ForeignKey("Group")]
|
||||
public int? GroupId { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
public Group Group { get; set; }
|
||||
|
||||
[ForeignKey("Group")]
|
||||
public int? GroupId { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
using(var dbContext = new DatabaseContext())
|
||||
return "Gruppen Fahrzeug | Gruppe: " + dbContext.GroupVehicles.Include(g => g.Group).First(g => g.Id == this.Id).Group.Name;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
return "Gruppen Fahrzeug | Gruppe: " + dbContext.GroupVehicles.Include(g => g.Group).First(g => g.Id == this.Id).Group.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,28 +9,28 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class House
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class House
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Type { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
||||
public int Price { get; set; }
|
||||
public int Price { get; set; }
|
||||
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Z { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Z { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(X, Y, Z);
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(X, Y, Z);
|
||||
|
||||
[ForeignKey("Owner")]
|
||||
public int? OwnerId { get; set; }
|
||||
public User Owner { get; set; }
|
||||
[ForeignKey("Owner")]
|
||||
public int? OwnerId { get; set; }
|
||||
public User Owner { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Client User => Owner?.Client;
|
||||
}
|
||||
[NotMapped]
|
||||
public Client User => Owner?.Client;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,68 +8,68 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class Interior
|
||||
public class Interior
|
||||
{
|
||||
[NotMapped]
|
||||
private Vector3 _enterPosition;
|
||||
[NotMapped]
|
||||
private Vector3 _exitPosition;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("EnterPosition")]
|
||||
public string EnterPositionStr
|
||||
{
|
||||
[NotMapped]
|
||||
private Vector3 _enterPosition;
|
||||
[NotMapped]
|
||||
private Vector3 _exitPosition;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("EnterPosition")]
|
||||
public string EnterPositionStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return JsonConvert.SerializeObject(this._enterPosition);
|
||||
}
|
||||
set
|
||||
{
|
||||
this._enterPosition = JsonConvert.DeserializeObject<Vector3>(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Column("ExitPosition")]
|
||||
public string ExitPositionStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return JsonConvert.SerializeObject(this._exitPosition);
|
||||
}
|
||||
set
|
||||
{
|
||||
this._exitPosition = JsonConvert.DeserializeObject<Vector3>(value);
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 EnterPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._enterPosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._enterPosition = value;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 ExitPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._exitPosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._exitPosition = value;
|
||||
}
|
||||
}
|
||||
get
|
||||
{
|
||||
return JsonConvert.SerializeObject(this._enterPosition);
|
||||
}
|
||||
set
|
||||
{
|
||||
this._enterPosition = JsonConvert.DeserializeObject<Vector3>(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Column("ExitPosition")]
|
||||
public string ExitPositionStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return JsonConvert.SerializeObject(this._exitPosition);
|
||||
}
|
||||
set
|
||||
{
|
||||
this._exitPosition = JsonConvert.DeserializeObject<Vector3>(value);
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 EnterPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._enterPosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._enterPosition = value;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 ExitPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._exitPosition;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._exitPosition = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class JobVehicle : ServerVehicle
|
||||
public class JobVehicle : ServerVehicle
|
||||
{
|
||||
public int JobId { get; set; }
|
||||
|
||||
public JobBase GetJob() => JobManager.GetJob(JobId);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
public int JobId { get; set; }
|
||||
|
||||
public JobBase GetJob() => JobManager.GetJob(JobId);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
return "Job Fahrzeug | Job: " + this.GetJob().Name;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
return "Job Fahrzeug | Job: " + this.GetJob().Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,25 +12,25 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities.Logs
|
||||
{
|
||||
public class BankAccountTransactionHistory
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class BankAccountTransactionHistory
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[StringLength(32)]
|
||||
public string Sender { get; set; }
|
||||
public int SenderBalance { get; set; }
|
||||
public int MoneySent { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Receiver { get; set; }
|
||||
public int ReceiverBalance { get; set; }
|
||||
public int NewSenderBalance { get; set; }
|
||||
public int NewReceiverBalance { get; set; }
|
||||
public int Fee { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Origin { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
[StringLength(32)]
|
||||
public string Sender { get; set; }
|
||||
public int SenderBalance { get; set; }
|
||||
public int MoneySent { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Receiver { get; set; }
|
||||
public int ReceiverBalance { get; set; }
|
||||
public int NewSenderBalance { get; set; }
|
||||
public int NewReceiverBalance { get; set; }
|
||||
public int Fee { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Origin { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,33 +13,33 @@ using ReallifeGamemode.Server.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities.Logs
|
||||
{
|
||||
public class Death
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class Death
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("Victim")]
|
||||
public int VictimId { get; set; }
|
||||
public User Victim { get; set; }
|
||||
[ForeignKey("Victim")]
|
||||
public int VictimId { get; set; }
|
||||
public User Victim { get; set; }
|
||||
|
||||
[ForeignKey("Killer")]
|
||||
public int? KillerId { get; set; }
|
||||
public User Killer { get; set; }
|
||||
[ForeignKey("Killer")]
|
||||
public int? KillerId { get; set; }
|
||||
public User Killer { get; set; }
|
||||
|
||||
public float VictimPositionX { get; set; }
|
||||
public float VictimPositionY { get; set; }
|
||||
public float VictimPositionZ { get; set; }
|
||||
public float VictimHeading { get; set; }
|
||||
public float VictimPositionX { get; set; }
|
||||
public float VictimPositionY { get; set; }
|
||||
public float VictimPositionZ { get; set; }
|
||||
public float VictimHeading { get; set; }
|
||||
|
||||
public float KillerPositionX { get; set; }
|
||||
public float KillerPositionY { get; set; }
|
||||
public float KillerPositionZ { get; set; }
|
||||
public float KillerHeading { get; set; }
|
||||
public float KillerPositionX { get; set; }
|
||||
public float KillerPositionY { get; set; }
|
||||
public float KillerPositionZ { get; set; }
|
||||
public float KillerHeading { get; set; }
|
||||
|
||||
[StringLength(64)]
|
||||
public string CauseOfDeath { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
[StringLength(64)]
|
||||
public string CauseOfDeath { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,19 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class News
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class News
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("User")]
|
||||
public int? UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
[ForeignKey("User")]
|
||||
public int? UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public string Caption { get; set; }
|
||||
public string Content { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public int Timestamp { get; set; }
|
||||
}
|
||||
public string Caption { get; set; }
|
||||
public string Content { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public int Timestamp { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,27 +12,27 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities.Saves
|
||||
{
|
||||
public class SavedBlip
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public short Sprite { get; set; }
|
||||
[Required]
|
||||
public float PositionX { get; set; }
|
||||
[Required]
|
||||
public float PositionY { get; set; }
|
||||
[Required]
|
||||
public float PositionZ { get; set; }
|
||||
public string Name { get; set; }
|
||||
public float Scale { get; set; }
|
||||
public byte Color { get; set; }
|
||||
public byte Alpha { get; set; }
|
||||
public float DrawDistance { get; set; }
|
||||
public bool ShortRange { get; set; }
|
||||
public float Rotation { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
public class SavedBlip
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public short Sprite { get; set; }
|
||||
[Required]
|
||||
public float PositionX { get; set; }
|
||||
[Required]
|
||||
public float PositionY { get; set; }
|
||||
[Required]
|
||||
public float PositionZ { get; set; }
|
||||
public string Name { get; set; }
|
||||
public float Scale { get; set; }
|
||||
public byte Color { get; set; }
|
||||
public byte Alpha { get; set; }
|
||||
public float DrawDistance { get; set; }
|
||||
public bool ShortRange { get; set; }
|
||||
public float Rotation { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,28 +12,28 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities.Saves
|
||||
{
|
||||
public class SavedMarker
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public byte Type { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Scale { get; set; }
|
||||
public float DirectionX { get; set; }
|
||||
public float DirectionY { get; set; }
|
||||
public float DirectionZ { get; set; }
|
||||
public float RotationX { get; set; }
|
||||
public float RotationY { get; set; }
|
||||
public float RotationZ { get; set; }
|
||||
public byte ColorR { get; set; }
|
||||
public byte ColorG { get; set; }
|
||||
public byte ColorB { get; set; }
|
||||
public byte ColorA { get; set; }
|
||||
public bool Visible { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
public class SavedMarker
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public byte Type { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Scale { get; set; }
|
||||
public float DirectionX { get; set; }
|
||||
public float DirectionY { get; set; }
|
||||
public float DirectionZ { get; set; }
|
||||
public float RotationX { get; set; }
|
||||
public float RotationY { get; set; }
|
||||
public float RotationZ { get; set; }
|
||||
public byte ColorR { get; set; }
|
||||
public byte ColorG { get; set; }
|
||||
public byte ColorB { get; set; }
|
||||
public byte ColorA { get; set; }
|
||||
public bool Visible { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,17 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities.Saves
|
||||
{
|
||||
public class SavedPed
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public string HashModel { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
public class SavedPed
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public string HashModel { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,21 +12,21 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities.Saves
|
||||
{
|
||||
public class SavedPickup
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[StringLength(128)]
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float RotationX { get; set; }
|
||||
public float RotationY { get; set; }
|
||||
public float RotationZ { get; set; }
|
||||
public bool Vehicle { get; set; }
|
||||
public int RespawnTime { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
public class SavedPickup
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[StringLength(128)]
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float RotationX { get; set; }
|
||||
public float RotationY { get; set; }
|
||||
public float RotationZ { get; set; }
|
||||
public bool Vehicle { get; set; }
|
||||
public int RespawnTime { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,27 +12,27 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities.Saves
|
||||
{
|
||||
public class SavedTextLabel
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Text { get; set; }
|
||||
[Required]
|
||||
public float PositionX { get; set; }
|
||||
[Required]
|
||||
public float PositionY { get; set; }
|
||||
[Required]
|
||||
public float PositionZ { get; set; }
|
||||
public bool LOS { get; set; }
|
||||
public byte Font { get; set; }
|
||||
public float DrawDistance { get; set; }
|
||||
public byte ColorR { get; set; }
|
||||
public byte ColorG { get; set; }
|
||||
public byte ColorB { get; set; }
|
||||
public byte ColorA { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
public class SavedTextLabel
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string Text { get; set; }
|
||||
[Required]
|
||||
public float PositionX { get; set; }
|
||||
[Required]
|
||||
public float PositionY { get; set; }
|
||||
[Required]
|
||||
public float PositionZ { get; set; }
|
||||
public bool LOS { get; set; }
|
||||
public byte Font { get; set; }
|
||||
public float DrawDistance { get; set; }
|
||||
public byte ColorR { get; set; }
|
||||
public byte ColorG { get; set; }
|
||||
public byte ColorB { get; set; }
|
||||
public byte ColorA { get; set; }
|
||||
public byte Dimension { get; set; }
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ using ReallifeGamemode.Server.Entities;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities.Saves
|
||||
{
|
||||
public class SavedVehicle : ServerVehicle
|
||||
public class SavedVehicle : ServerVehicle
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return "Gespeichertes Fahrzeug";
|
||||
}
|
||||
return "Gespeichertes Fahrzeug";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,85 +7,85 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public abstract class ServerVehicle
|
||||
public abstract class ServerVehicle
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public VehicleHash Model { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
[StringLength(8)]
|
||||
public string NumberPlate { get; set; }
|
||||
public int PrimaryColor { get; set; }
|
||||
public int SecondaryColor { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public float DistanceDriven { get; set; }
|
||||
public float TankAmount { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(PositionX, PositionY, PositionZ);
|
||||
|
||||
[NotMapped]
|
||||
public Vehicle Vehicle => VehicleManager.GetVehicleFromServerVehicle(this);
|
||||
|
||||
public Vehicle Spawn(Vehicle currentVeh = null)
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh);
|
||||
Vector3 position = this.Position;
|
||||
uint model = (uint)this.Model;
|
||||
float heading = this.Heading;
|
||||
int c1 = this.PrimaryColor;
|
||||
int c2 = this.SecondaryColor;
|
||||
string np = this.NumberPlate;
|
||||
Vehicle veh = NAPI.Vehicle.CreateVehicle(Model, position, heading, c1, c2, "", 255, false, false);
|
||||
VehicleStreaming.SetEngineState(veh, false);
|
||||
VehicleStreaming.SetLockStatus(veh, this.Locked);
|
||||
VehicleManager.AddVehicle(this, veh);
|
||||
|
||||
public VehicleHash Model { get; set; }
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
public float Heading { get; set; }
|
||||
[StringLength(8)]
|
||||
public string NumberPlate { get; set; }
|
||||
public int PrimaryColor { get; set; }
|
||||
public int SecondaryColor { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public float DistanceDriven { get; set; }
|
||||
public float TankAmount { get; set; }
|
||||
veh.SetSharedData("drivenDistance", this.DistanceDriven);
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(PositionX, PositionY, PositionZ);
|
||||
string numberplate = $"{this.Id}";
|
||||
|
||||
[NotMapped]
|
||||
public Vehicle Vehicle => VehicleManager.GetVehicleFromServerVehicle(this);
|
||||
if (this is FactionVehicle fV)
|
||||
{
|
||||
numberplate = $"F{fV.FactionId} " + numberplate;
|
||||
}
|
||||
|
||||
public Vehicle Spawn(Vehicle currentVeh = null)
|
||||
{
|
||||
if (currentVeh != null) VehicleManager.DeleteVehicle(currentVeh);
|
||||
Vector3 position = this.Position;
|
||||
uint model = (uint)this.Model;
|
||||
float heading = this.Heading;
|
||||
int c1 = this.PrimaryColor;
|
||||
int c2 = this.SecondaryColor;
|
||||
string np = this.NumberPlate;
|
||||
Vehicle veh = NAPI.Vehicle.CreateVehicle(Model, position, heading, c1, c2, "", 255, false, false);
|
||||
VehicleStreaming.SetEngineState(veh, false);
|
||||
VehicleStreaming.SetLockStatus(veh, this.Locked);
|
||||
VehicleManager.AddVehicle(this, veh);
|
||||
if (this is UserVehicle uV)
|
||||
{
|
||||
numberplate = $"U{uV.UserId} " + numberplate;
|
||||
}
|
||||
|
||||
veh.SetSharedData("drivenDistance", this.DistanceDriven);
|
||||
if (this is ShopVehicle sV)
|
||||
{
|
||||
numberplate = "Shop";
|
||||
VehicleStreaming.SetLockStatus(veh, false);
|
||||
TextLabel label = NAPI.TextLabel.CreateTextLabel("SHOPVEHICLE\n" + "~g~" + sV.Price.ToMoneyString(),
|
||||
veh.Position.Add(new Vector3(0, 0, 1.3)), 10.0f, 1f, 1, new Color(255, 255, 255));
|
||||
|
||||
string numberplate = $"{this.Id}";
|
||||
veh.SetSharedData("shopVehicleTextLabel", label.Handle.Value);
|
||||
}
|
||||
|
||||
if (this is FactionVehicle fV)
|
||||
{
|
||||
numberplate = $"F{fV.FactionId} " + numberplate;
|
||||
}
|
||||
if (this is GroupVehicle gV)
|
||||
{
|
||||
numberplate = $"G{gV.GroupId} " + numberplate;
|
||||
}
|
||||
|
||||
if (this is UserVehicle uV)
|
||||
{
|
||||
numberplate = $"U{uV.UserId} " + numberplate;
|
||||
}
|
||||
if (this is JobVehicle jV)
|
||||
{
|
||||
numberplate = $"J{jV.JobId} " + numberplate;
|
||||
}
|
||||
|
||||
if (this is ShopVehicle sV)
|
||||
{
|
||||
numberplate = "Shop";
|
||||
VehicleStreaming.SetLockStatus(veh, false);
|
||||
TextLabel label = NAPI.TextLabel.CreateTextLabel("SHOPVEHICLE\n" + "~g~" + sV.Price.ToMoneyString(),
|
||||
veh.Position.Add(new Vector3(0, 0, 1.3)), 10.0f, 1f, 1, new Color(255, 255, 255));
|
||||
veh.NumberPlate = numberplate;
|
||||
|
||||
veh.SetSharedData("shopVehicleTextLabel", label.Handle.Value);
|
||||
}
|
||||
|
||||
if (this is GroupVehicle gV)
|
||||
{
|
||||
numberplate = $"G{gV.GroupId} " + numberplate;
|
||||
}
|
||||
|
||||
if(this is JobVehicle jV)
|
||||
{
|
||||
numberplate = $"J{jV.JobId} " + numberplate;
|
||||
}
|
||||
|
||||
veh.NumberPlate = numberplate;
|
||||
|
||||
return veh;
|
||||
}
|
||||
|
||||
public abstract override string ToString();
|
||||
return veh;
|
||||
}
|
||||
|
||||
public abstract override string ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
[Table("ShopVehicles")]
|
||||
public class ShopVehicle : ServerVehicle
|
||||
{
|
||||
public int BusinessId { get; set; }
|
||||
public int Price { get; set; }
|
||||
[Table("ShopVehicles")]
|
||||
public class ShopVehicle : ServerVehicle
|
||||
{
|
||||
public int BusinessId { get; set; }
|
||||
public int Price { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "ShopVehicle | Shop: " + BusinessManager.GetBusiness(BusinessId).Name;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return "ShopVehicle | Shop: " + BusinessManager.GetBusiness(BusinessId).Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,19 +7,19 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class TuningGarage
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class TuningGarage
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public float X { get; set; }
|
||||
public float X { get; set; }
|
||||
|
||||
public float Y { get; set; }
|
||||
public float Y { get; set; }
|
||||
|
||||
public float Z { get; set; }
|
||||
public float Z { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(X, Y, Z);
|
||||
}
|
||||
[NotMapped]
|
||||
public Vector3 Position => new Vector3(X, Y, Z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,101 +17,101 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class User : IBankAccountOwner
|
||||
public class User : IBankAccountOwner
|
||||
{
|
||||
[NotMapped]
|
||||
private int _wanteds;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Name { get; set; }
|
||||
[StringLength(32)]
|
||||
public string SocialClubName { get; set; }
|
||||
[StringLength(64)]
|
||||
public string Password { get; set; }
|
||||
public int LogUserId { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public DateTime RegistrationDate { get; set; }
|
||||
|
||||
[EmailAddress]
|
||||
[StringLength(64)]
|
||||
public string Email { get; set; }
|
||||
public AdminLevel AdminLevel { get; set; }
|
||||
|
||||
public bool Dead { get; set; }
|
||||
public int Handmoney { get; set; }
|
||||
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
|
||||
[ForeignKey("Character")]
|
||||
public int? CharacterId { get; set; }
|
||||
public Character Character { get; set; }
|
||||
|
||||
[ForeignKey("Ban")]
|
||||
public int? BanId { get; set; }
|
||||
public Ban Ban { get; set; }
|
||||
|
||||
public int? BusinessId { get; set; }
|
||||
|
||||
public int? FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public bool FactionLeader { get; set; }
|
||||
|
||||
public int? FactionRankId { get; set; }
|
||||
public FactionRank FactionRank { get; set; }
|
||||
|
||||
public Group Group { get; set; }
|
||||
|
||||
public GroupRank GroupRank { get; set; }
|
||||
|
||||
[ForeignKey("House")]
|
||||
public int? HouseId { get; set; }
|
||||
public House House { get; set; }
|
||||
|
||||
public int? JobId { get; set; }
|
||||
|
||||
public int Wanteds
|
||||
{
|
||||
[NotMapped]
|
||||
private int _wanteds;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Name { get; set; }
|
||||
[StringLength(32)]
|
||||
public string SocialClubName { get; set; }
|
||||
[StringLength(64)]
|
||||
public string Password { get; set; }
|
||||
public int LogUserId { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public DateTime RegistrationDate { get; set; }
|
||||
|
||||
[EmailAddress]
|
||||
[StringLength(64)]
|
||||
public string Email { get; set; }
|
||||
public AdminLevel AdminLevel { get; set; }
|
||||
|
||||
public bool Dead { get; set; }
|
||||
public int Handmoney { get; set; }
|
||||
|
||||
public float PositionX { get; set; }
|
||||
public float PositionY { get; set; }
|
||||
public float PositionZ { get; set; }
|
||||
|
||||
[ForeignKey("Character")]
|
||||
public int? CharacterId { get; set; }
|
||||
public Character Character { get; set; }
|
||||
|
||||
[ForeignKey("Ban")]
|
||||
public int? BanId { get; set; }
|
||||
public Ban Ban { get; set; }
|
||||
|
||||
public int? BusinessId { get; set; }
|
||||
|
||||
public int? FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public bool FactionLeader { get; set; }
|
||||
|
||||
public int? FactionRankId { get; set; }
|
||||
public FactionRank FactionRank { get; set; }
|
||||
|
||||
public Group Group { get; set; }
|
||||
|
||||
public GroupRank GroupRank { get; set; }
|
||||
|
||||
[ForeignKey("House")]
|
||||
public int? HouseId { get; set; }
|
||||
public House House { get; set; }
|
||||
|
||||
public int? JobId { get; set; }
|
||||
|
||||
public int Wanteds
|
||||
{
|
||||
get => _wanteds;
|
||||
set
|
||||
{
|
||||
this._wanteds = value;
|
||||
Client.TriggerEvent("SERVER:SetWanteds", value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Wage { get; set; }
|
||||
|
||||
public int JailTime { get; set; }
|
||||
|
||||
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Client Client
|
||||
{
|
||||
get => NAPI.Pools.GetAllPlayers().Where(c => c.Name.ToLower() == this.Name.ToLower()).FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
get => _wanteds;
|
||||
set
|
||||
{
|
||||
this._wanteds = value;
|
||||
Client.TriggerEvent("SERVER:SetWanteds", value);
|
||||
}
|
||||
}
|
||||
|
||||
public int Wage { get; set; }
|
||||
|
||||
public int JailTime { get; set; }
|
||||
|
||||
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
{
|
||||
if (databaseContext == null)
|
||||
{
|
||||
using (databaseContext = new DatabaseContext())
|
||||
{
|
||||
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Client Client
|
||||
{
|
||||
get => NAPI.Pools.GetAllPlayers().Where(c => c.Name.ToLower() == this.Name.ToLower()).FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,33 +13,33 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class UserBankAccount : IBankAccount
|
||||
{
|
||||
[NotMapped]
|
||||
private int _balance;
|
||||
public class UserBankAccount : IBankAccount
|
||||
{
|
||||
[NotMapped]
|
||||
private int _balance;
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
[StringLength(12)]
|
||||
public string Bic { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Iban { get; set; }
|
||||
public int Balance
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
[StringLength(12)]
|
||||
public string Bic { get; set; }
|
||||
[StringLength(32)]
|
||||
public string Iban { get; set; }
|
||||
public int Balance
|
||||
{
|
||||
get => _balance;
|
||||
set
|
||||
{
|
||||
_balance = value;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
get => _balance;
|
||||
set
|
||||
{
|
||||
_balance = value;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ClientService.GetClientByNameOrId(dbContext.Users.First(u => u.Id == UserId).Name).TriggerEvent("updateMoney", value);
|
||||
}
|
||||
}
|
||||
ClientService.GetClientByNameOrId(dbContext.Users.First(u => u.Id == UserId).Name).TriggerEvent("updateMoney", value);
|
||||
}
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
public bool Active { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -11,27 +11,27 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class UserItem
|
||||
public class UserItem
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int ItemId { get; set; }
|
||||
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public int Amount { get; set; }
|
||||
public int Slot { get; set; }
|
||||
|
||||
public User GetUser()
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int ItemId { get; set; }
|
||||
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public int Amount { get; set; }
|
||||
public int Slot { get; set; }
|
||||
|
||||
public User GetUser()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
|
||||
}
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,31 +10,31 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
[Table("UserVehicles")]
|
||||
public class UserVehicle : ServerVehicle
|
||||
[Table("UserVehicles")]
|
||||
public class UserVehicle : ServerVehicle
|
||||
{
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
[ForeignKey("User")]
|
||||
public int UserId { get; set; }
|
||||
public User User { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Spieler Fahrzeug | Besitzer: " + GetOwner().Name;
|
||||
}
|
||||
|
||||
public User GetOwner(DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
|
||||
}
|
||||
}
|
||||
return "Spieler Fahrzeug | Besitzer: " + GetOwner().Name;
|
||||
}
|
||||
|
||||
public User GetOwner(DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Users.FirstOrDefault(u => u.Id == UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,17 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class VehicleMod
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public class VehicleMod
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[ForeignKey("Vehicle")]
|
||||
public int ServerVehicleId { get; set; }
|
||||
public ServerVehicle Vehicle { get; set; }
|
||||
[ForeignKey("Vehicle")]
|
||||
public int ServerVehicleId { get; set; }
|
||||
public ServerVehicle Vehicle { get; set; }
|
||||
|
||||
public int Slot { get; set; }
|
||||
public int ModId { get; set; }
|
||||
}
|
||||
public int Slot { get; set; }
|
||||
public int ModId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
public class Whitelist
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public string SocialClubName { get; set; }
|
||||
}
|
||||
public class Whitelist
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
public string SocialClubName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,17 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Chat : Script
|
||||
public class Chat : Script
|
||||
{
|
||||
[ServerEvent(Event.ChatMessage)]
|
||||
public void ChatEvent(Client player, string message)
|
||||
{
|
||||
[ServerEvent(Event.ChatMessage)]
|
||||
public void ChatEvent(Client player, string message)
|
||||
{
|
||||
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
if (serverMsg.Trim().Length == 0) return;
|
||||
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p =>
|
||||
{
|
||||
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");
|
||||
});
|
||||
}
|
||||
string serverMsg = Regex.Replace(message, "(~[a-zA-Z]~)|(!{(.*)})", "");
|
||||
if (serverMsg.Trim().Length == 0) return;
|
||||
NAPI.Player.GetPlayersInRadiusOfPlayer(10, player).ForEach(p =>
|
||||
{
|
||||
ChatService.SendMessage(p, $"{player.Name} sagt: {serverMsg}");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,78 +14,78 @@ using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Connect : Script
|
||||
class Connect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerConnected)]
|
||||
public void OnPlayerConnected(Client player)
|
||||
{
|
||||
[ServerEvent(Event.PlayerConnected)]
|
||||
public void OnPlayerConnected(Client player)
|
||||
player.SetData("isLoggedIn", false);
|
||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||
player.FreezePosition = true;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
|
||||
{
|
||||
player.SetData("isLoggedIn", false);
|
||||
player.Position = new Vector3(-1883.736, -781.4911, -10);
|
||||
player.FreezePosition = true;
|
||||
string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist.";
|
||||
ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN);
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!dbContext.WhitelistEntries.Any(w => w.SocialClubName.ToLower() == player.SocialClubName.ToLower()))
|
||||
{
|
||||
string msg2 = "~m~*** " + player.Name + "[" + player.SocialClubName + "] (" + player.Address + ") hat versucht, sich einzuloggen, steht aber nicht auf der Whitelist.";
|
||||
ChatService.BroadcastAdmin(msg2, AdminLevel.ADMIN);
|
||||
NAPI.Util.ConsoleOutput(player.Name + " tried to join without whitelist entry");
|
||||
|
||||
NAPI.Util.ConsoleOutput(player.Name + " tried to join without whitelist entry");
|
||||
|
||||
ChatService.SendMessage(player, "~m~Du stehst nicht auf der Whitelist");
|
||||
|
||||
player.Kick();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsPlayerBanned(player)) return;
|
||||
player.TriggerEvent("SERVER:Login_ShowBrowser");
|
||||
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")";
|
||||
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
|
||||
ChatService.SendMessage(player, "~m~Du stehst nicht auf der Whitelist");
|
||||
|
||||
player.Kick();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsPlayerBanned(Client player)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = dbContext.Users.SingleOrDefault(b => b.Name == player.Name);
|
||||
if (user == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (user.BanId != null)
|
||||
{
|
||||
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
var bannedUser = dbContext.Bans.SingleOrDefault(u => u.Id == user.BanId);
|
||||
if (bannedUser.Applied == bannedUser.UntilDateTime)
|
||||
{
|
||||
ChatService.SendMessage(player, "!{#FF4040}Du wurdest permanent gebannt! [" + bannedUser.Reason + "]");
|
||||
player.Kick();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var timeStamp = bannedUser.UntilDateTime;
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
if (IsPlayerBanned(player)) return;
|
||||
player.TriggerEvent("SERVER:Login_ShowBrowser");
|
||||
string msg = "~m~*** " + player.Name + " [" + player.SocialClubName + "] [ID:" + player.Handle.Value + "] (" + player.Address + ")";
|
||||
ChatService.BroadcastAdmin(msg, AdminLevel.ADMIN);
|
||||
|
||||
if (timeStamp > unixTimestamp)
|
||||
{
|
||||
ChatService.SendMessage(player, "Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]");
|
||||
player.Kick();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
user.BanId = null;
|
||||
dbContext.SaveChanges();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsPlayerBanned(Client player)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = dbContext.Users.SingleOrDefault(b => b.Name == player.Name);
|
||||
if (user == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (user.BanId != null)
|
||||
{
|
||||
var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
var bannedUser = dbContext.Bans.SingleOrDefault(u => u.Id == user.BanId);
|
||||
if (bannedUser.Applied == bannedUser.UntilDateTime)
|
||||
{
|
||||
ChatService.SendMessage(player, "!{#FF4040}Du wurdest permanent gebannt! [" + bannedUser.Reason + "]");
|
||||
player.Kick();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var timeStamp = bannedUser.UntilDateTime;
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
|
||||
if (timeStamp > unixTimestamp)
|
||||
{
|
||||
ChatService.SendMessage(player, "Du bist noch bis zum !{#FF4040}" + dt.AddSeconds(timeStamp).ToLocalTime() + " Uhr ~s~gebannt. [" + bannedUser.Reason + "]");
|
||||
player.Kick();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
user.BanId = null;
|
||||
dbContext.SaveChanges();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,112 +15,112 @@ using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Death : Script
|
||||
public class Death : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
public void OnPlayerDeath(Client player, Client killer, uint reason)
|
||||
{
|
||||
[ServerEvent(Event.PlayerDeath)]
|
||||
public void OnPlayerDeath(Client player, Client killer, uint reason)
|
||||
if (!player.IsLoggedIn()) player.Kick();
|
||||
player.SetData("isDead", true);
|
||||
|
||||
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
}
|
||||
|
||||
//var dutyMedics = 0;
|
||||
//var allPlayers = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
//foreach (Client medic in allPlayers)
|
||||
//{
|
||||
// if (medic.GetUser()?.FactionId == 2)
|
||||
// {
|
||||
// dutyMedics++;
|
||||
// }
|
||||
//}
|
||||
//player.TriggerEvent("medicInfo", dutyMedics);
|
||||
|
||||
//TODO: Zum Full Release entfernen
|
||||
ChatService.SendMessage(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
float killerPosY;
|
||||
float killerPosZ;
|
||||
float killerHeading;
|
||||
|
||||
if (killer.IsNull)
|
||||
{
|
||||
killerId = null;
|
||||
killerPosX = -1;
|
||||
killerPosY = -1;
|
||||
killerPosZ = -1;
|
||||
killerHeading = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
killerId = killer.GetUser().Id;
|
||||
killerPosX = killer.Position.X;
|
||||
killerPosY = killer.Position.Y;
|
||||
killerPosZ = killer.Position.Z;
|
||||
killerHeading = killer.Heading;
|
||||
if (player != killer)
|
||||
{
|
||||
if (!player.IsLoggedIn()) player.Kick();
|
||||
player.SetData("isDead", true);
|
||||
|
||||
if (player.GetUser().IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
}
|
||||
|
||||
//var dutyMedics = 0;
|
||||
//var allPlayers = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
//foreach (Client medic in allPlayers)
|
||||
//{
|
||||
// if (medic.GetUser()?.FactionId == 2)
|
||||
// {
|
||||
// dutyMedics++;
|
||||
// }
|
||||
//}
|
||||
//player.TriggerEvent("medicInfo", dutyMedics);
|
||||
|
||||
//TODO: Zum Full Release entfernen
|
||||
ChatService.SendMessage(player, "Du bist durch " + killer.Name + " gestorben: " + reason.ToString());
|
||||
|
||||
int? killerId;
|
||||
float killerPosX;
|
||||
float killerPosY;
|
||||
float killerPosZ;
|
||||
float killerHeading;
|
||||
|
||||
if (killer.IsNull)
|
||||
{
|
||||
killerId = null;
|
||||
killerPosX = -1;
|
||||
killerPosY = -1;
|
||||
killerPosZ = -1;
|
||||
killerHeading = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
killerId = killer.GetUser().Id;
|
||||
killerPosX = killer.Position.X;
|
||||
killerPosY = killer.Position.Y;
|
||||
killerPosZ = killer.Position.Z;
|
||||
killerHeading = killer.Heading;
|
||||
if (player != killer)
|
||||
{
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + NAPI.Player.GetPlayerCurrentWeapon(killer) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
}
|
||||
}
|
||||
|
||||
//JailTime.cs
|
||||
Jail.Check_PutBehindBars(player);
|
||||
|
||||
|
||||
//MEDIC AUFTRAG
|
||||
MedicTask reviveTask = new MedicTask()
|
||||
{
|
||||
Victim = player.Name,
|
||||
Position = player.Position,
|
||||
CauseOfDeath = reason.ToString(),
|
||||
Caller = null,
|
||||
Description = "Gestorben",
|
||||
Time = DateTime.Now,
|
||||
Type = MedicTaskType.REVIVE,
|
||||
MedicName = "none"
|
||||
};
|
||||
Medic.AddTaskToList(reviveTask);
|
||||
|
||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
{
|
||||
var dead = new Entities.Logs.Death
|
||||
{
|
||||
VictimId = player.GetUser().Id,
|
||||
KillerId = killerId,
|
||||
KillerPositionX = killerPosX,
|
||||
KillerPositionY = killerPosY,
|
||||
KillerPositionZ = killerPosZ,
|
||||
KillerHeading = killerHeading,
|
||||
VictimPositionX = player.Position.X,
|
||||
VictimPositionY = player.Position.Y,
|
||||
VictimPositionZ = player.Position.Z,
|
||||
VictimHeading = player.Heading,
|
||||
CauseOfDeath = reason.ToString()
|
||||
};
|
||||
userDeath.DeathLogs.Add(dead);
|
||||
userDeath.SaveChanges();
|
||||
}
|
||||
string message = "~y~[HINWEIS]: " + killer.Name + " hat " + player.Name + " getötet (" + NAPI.Player.GetPlayerCurrentWeapon(killer) + ")";
|
||||
ChatService.BroadcastAdmin(message, AdminLevel.ADMIN);
|
||||
}
|
||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||
public void RespawnPlayerAtHospital(Client player)
|
||||
}
|
||||
|
||||
//JailTime.cs
|
||||
Jail.Check_PutBehindBars(player);
|
||||
|
||||
|
||||
//MEDIC AUFTRAG
|
||||
MedicTask reviveTask = new MedicTask()
|
||||
{
|
||||
Victim = player.Name,
|
||||
Position = player.Position,
|
||||
CauseOfDeath = reason.ToString(),
|
||||
Caller = null,
|
||||
Description = "Gestorben",
|
||||
Time = DateTime.Now,
|
||||
Type = MedicTaskType.REVIVE,
|
||||
MedicName = "none"
|
||||
};
|
||||
Medic.AddTaskToList(reviveTask);
|
||||
|
||||
//TODO PICTURE NOTIFICATION + SOUND für Medics
|
||||
|
||||
using (var userDeath = new DatabaseContext())
|
||||
{
|
||||
var dead = new Entities.Logs.Death
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
player.RemoveAllWeapons();
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||
}
|
||||
VictimId = player.GetUser().Id,
|
||||
KillerId = killerId,
|
||||
KillerPositionX = killerPosX,
|
||||
KillerPositionY = killerPosY,
|
||||
KillerPositionZ = killerPosZ,
|
||||
KillerHeading = killerHeading,
|
||||
VictimPositionX = player.Position.X,
|
||||
VictimPositionY = player.Position.Y,
|
||||
VictimPositionZ = player.Position.Z,
|
||||
VictimHeading = player.Heading,
|
||||
CauseOfDeath = reason.ToString()
|
||||
};
|
||||
userDeath.DeathLogs.Add(dead);
|
||||
userDeath.SaveChanges();
|
||||
}
|
||||
}
|
||||
[RemoteEvent("RespawnPlayerAtHospital")]
|
||||
public void RespawnPlayerAtHospital(Client player)
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
player.RemoveAllWeapons();
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,41 +16,41 @@ using ReallifeGamemode.Server.Models;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Disconnect : Script
|
||||
public class Disconnect : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Client player, DisconnectionType type, string reason)
|
||||
{
|
||||
[ServerEvent(Event.PlayerDisconnected)]
|
||||
public void OnPlayerDisconnected(Client player, DisconnectionType type, string reason)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (!player.IsLoggedIn()) return;
|
||||
|
||||
if (type == DisconnectionType.Left)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||
}
|
||||
if (type == DisconnectionType.Kicked)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||
}
|
||||
if (type == DisconnectionType.Timeout)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||
}
|
||||
if (type == DisconnectionType.Left)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||
}
|
||||
if (type == DisconnectionType.Kicked)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " kicked");
|
||||
}
|
||||
if (type == DisconnectionType.Timeout)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput(player.Name + " Timeoutet");
|
||||
}
|
||||
|
||||
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
||||
if (job != null) job.StopJob(player, true);
|
||||
JobBase job = JobManager.GetJob(player.GetUser().JobId ?? -1);
|
||||
if (job != null) job.StopJob(player, true);
|
||||
|
||||
using (var saveUser = new DatabaseContext())
|
||||
{
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
using (var saveUser = new DatabaseContext())
|
||||
{
|
||||
var user = player.GetUser(saveUser);
|
||||
Vector3 pos = player.Position;
|
||||
|
||||
user.PositionX = pos.X;
|
||||
user.PositionY = pos.Y;
|
||||
user.PositionZ = pos.Z;
|
||||
saveUser.SaveChanges();
|
||||
user.Dead = player.HasData("isDead") ? (bool)player.GetData("isDead") : false;
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
user.PositionX = pos.X;
|
||||
user.PositionY = pos.Y;
|
||||
user.PositionZ = pos.Z;
|
||||
saveUser.SaveChanges();
|
||||
user.Dead = player.HasData("isDead") ? (bool)player.GetData("isDead") : false;
|
||||
}
|
||||
player.SetData("isLoggedIn", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,28 +8,28 @@ using ReallifeGamemode.Server.Extensions;
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
|
||||
public class EnterVehicleAttempt : Script
|
||||
public class EnterVehicleAttempt : Script
|
||||
{
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
public void OnPlayerEnterVehicleAttempt(Client player, Vehicle vehicle, sbyte seat)
|
||||
{
|
||||
[ServerEvent(Event.PlayerEnterVehicleAttempt)]
|
||||
public void OnPlayerEnterVehicleAttempt(Client player, Vehicle vehicle, sbyte seat)
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
||||
{
|
||||
if (seat == 1) seat = 0;
|
||||
else if (seat == 0) seat = 1;
|
||||
}
|
||||
|
||||
if (seat != 0) return;
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
if (veh.FactionId != player.GetUser().FactionId)
|
||||
{
|
||||
if ((VehicleHash)vehicle.Model == VehicleHash.Dune3)
|
||||
{
|
||||
if (seat == 1) seat = 0;
|
||||
else if (seat == 0) seat = 1;
|
||||
}
|
||||
|
||||
if (seat != 0) return;
|
||||
|
||||
if (vehicle.GetServerVehicle() is FactionVehicle veh)
|
||||
{
|
||||
if (veh.FactionId != player.GetUser().FactionId)
|
||||
{
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.StopAnimation();
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht benutzen!", true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,60 +9,60 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Faction : Script
|
||||
class Faction : Script
|
||||
{
|
||||
[RemoteEvent("OnFactionRanksEdit")]
|
||||
public void OnFactionRanksEdit(Client player, string jsonData)
|
||||
{
|
||||
[RemoteEvent("OnFactionRanksEdit")]
|
||||
public void OnFactionRanksEdit(Client player, string jsonData)
|
||||
FactionRankHelper helper = JsonConvert.DeserializeObject<FactionRankHelper>(jsonData);
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
Entities.Faction f = context.Factions.FirstOrDefault(x => x.Id == helper.FactionId);
|
||||
if (f == null)
|
||||
{
|
||||
FactionRankHelper helper = JsonConvert.DeserializeObject<FactionRankHelper>(jsonData);
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
Entities.Faction f = context.Factions.FirstOrDefault(x => x.Id == helper.FactionId);
|
||||
if (f == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Bei der Bearbeitung der Ränge ist ein Fehler aufgetreten: Die Fraktion existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Rank> ranks = helper.Ranks;
|
||||
int length = ranks.Count;
|
||||
|
||||
List<FactionRank> factionRanks = context.FactionRanks.ToList().FindAll(fR => fR.FactionId == f.Id);
|
||||
|
||||
List<int> found = new List<int>();
|
||||
|
||||
for (int i = 0; i < ranks.Count; i++)
|
||||
{
|
||||
Rank newRank = ranks[i];
|
||||
if (newRank.Id == 0)
|
||||
{
|
||||
context.FactionRanks.Add(new FactionRank
|
||||
{
|
||||
RankName = newRank.Name,
|
||||
FactionId = f.Id,
|
||||
Order = length - i
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
FactionRank factionRank = factionRanks.Find(r => r.Id == newRank.Id);
|
||||
factionRank.RankName = newRank.Name;
|
||||
factionRank.Order = length - i;
|
||||
found.Add(factionRank.Id);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < factionRanks.Count; i++)
|
||||
{
|
||||
if (!found.Contains(factionRanks[i].Id))
|
||||
{
|
||||
context.FactionRanks.Remove(factionRanks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ChatService.SendMessage(player, "~g~Die Ränge wurden erfolgreich gespeichert.");
|
||||
context.SaveChanges();
|
||||
}
|
||||
ChatService.ErrorMessage(player, "Bei der Bearbeitung der Ränge ist ein Fehler aufgetreten: Die Fraktion existiert nicht");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Rank> ranks = helper.Ranks;
|
||||
int length = ranks.Count;
|
||||
|
||||
List<FactionRank> factionRanks = context.FactionRanks.ToList().FindAll(fR => fR.FactionId == f.Id);
|
||||
|
||||
List<int> found = new List<int>();
|
||||
|
||||
for (int i = 0; i < ranks.Count; i++)
|
||||
{
|
||||
Rank newRank = ranks[i];
|
||||
if (newRank.Id == 0)
|
||||
{
|
||||
context.FactionRanks.Add(new FactionRank
|
||||
{
|
||||
RankName = newRank.Name,
|
||||
FactionId = f.Id,
|
||||
Order = length - i
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
FactionRank factionRank = factionRanks.Find(r => r.Id == newRank.Id);
|
||||
factionRank.RankName = newRank.Name;
|
||||
factionRank.Order = length - i;
|
||||
found.Add(factionRank.Id);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < factionRanks.Count; i++)
|
||||
{
|
||||
if (!found.Contains(factionRanks[i].Id))
|
||||
{
|
||||
context.FactionRanks.Remove(factionRanks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ChatService.SendMessage(player, "~g~Die Ränge wurden erfolgreich gespeichert.");
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,290 +19,290 @@ using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Key : Script
|
||||
public class Key : Script
|
||||
{
|
||||
[RemoteEvent("keyPress:NUM2")]
|
||||
public void KeyPressNUM2(Client player)
|
||||
{
|
||||
[RemoteEvent("keyPress:NUM2")]
|
||||
public void KeyPressNUM2(Client player)
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (player.GetData("editmode") == true && player.GetUser().IsAdmin(AdminLevel.HEADADMIN) == true)
|
||||
{
|
||||
var saveMode = player.GetData("quicksavemode");
|
||||
switch (saveMode)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (player.GetData("editmode") == true && player.GetUser().IsAdmin(AdminLevel.HEADADMIN) == true)
|
||||
case "none":
|
||||
ChatService.SendMessage(player, "~r~Keinen Modus ausgewählt! ~y~/quicksavemode ~r~für mehr Infos!");
|
||||
break;
|
||||
|
||||
case "blip":
|
||||
TempBlip tempBlip = NAPI.Data.GetWorldData("blipTemplate");
|
||||
SaveManager.OnSaveBlipData(player, tempBlip.Sprite.ToString(), tempBlip.Name, tempBlip.Scale.ToString(), tempBlip.Color.ToString(),
|
||||
tempBlip.Transparency.ToString(), 200.ToString(), tempBlip.ShortRange.ToString(), 0.ToString(), 0.ToString());
|
||||
player.SendNotification("~y~Blip~s~ erstellt!", false);
|
||||
break;
|
||||
case "atm":
|
||||
SaveManager.OnSaveBlipData(player, "500", "Geldautomat", 0.7.ToString(), "11",
|
||||
"0", "200", true.ToString(), 0.ToString(), 0.ToString());
|
||||
player.SendNotification("~y~ATM~s~ erstellt!", false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GroundItem.PickUpGroundItem(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:UP_ARROW")]
|
||||
public void KeyPressUpArrow(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (player.HasData("nearATM"))
|
||||
{
|
||||
ATMManager.ShowAtmUi(player, player.GetData("nearATM"));
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:LEFT_ARROW")]
|
||||
public void KeyPressLeftArrow(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
List<Client> nearbyPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(3, player);
|
||||
|
||||
if (nearbyPlayers.Count > 1)
|
||||
{
|
||||
List<string> nearbyPlayerList = new List<string>();
|
||||
foreach (Client nearPlayer in nearbyPlayers)
|
||||
{
|
||||
if (nearPlayer.Name != player.Name)
|
||||
{
|
||||
nearbyPlayerList.Add(nearPlayer.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("showPlayerInteraction", JsonConvert.SerializeObject(nearbyPlayerList));
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:RIGHT_ARROW")]
|
||||
public void KeyPressRightArrow(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
User user = player.GetUser();
|
||||
switch (user.FactionId)
|
||||
{
|
||||
//LSFD
|
||||
case 2:
|
||||
player.TriggerEvent("showFactionInteraction", user.FactionId, user.GetData<bool>("duty"), user.Faction.Name, user.FactionLeader, Medic.ReviveTasks.Count.ToString(), Medic.HealTasks.Count.ToString(), Medic.FireTasks.Count.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:DOWN_ARROW")]
|
||||
public void KeyPressDownArrow(Client player)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
var accountData = new
|
||||
{
|
||||
regDate = u.RegistrationDate.ToShortDateString(),
|
||||
adminLevel = u.AdminLevel.GetName(),
|
||||
faction = u.Faction?.Name ?? "Zivilist",
|
||||
factionRank = u.GetFactionRank().RankName,
|
||||
group = u.Group?.Name ?? "Keine",
|
||||
groupRank = u.GroupRank.GetName(),
|
||||
job = JobManager.GetJob(u.JobId ?? 0)?.Name ?? "Keiner"
|
||||
};
|
||||
|
||||
string faction = u.FactionLeader ? u.Faction.Name : null;
|
||||
string group = u.Group != null && u.GroupRank >= GroupRank.MANAGER ? u.Group.Name : null;
|
||||
bool factionInvite = player.HasData("accept_faction_invite");
|
||||
bool groupInvite = player.HasData("accept_group_invite");
|
||||
|
||||
player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), faction, group, factionInvite, groupInvite);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:E")]
|
||||
public void KeyPressE(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
var user = player.GetUser();
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5 && d.FactionId == user.FactionId);
|
||||
if (nearest == null) return;
|
||||
var nameTagColor = new Color(0, 0, 0);
|
||||
var factionId = user.FactionId;
|
||||
|
||||
if (user.GetData<bool>("duty") == false)
|
||||
{
|
||||
user.SetData("duty", true);
|
||||
player.SendNotification("Du bist nun ~g~im Dienst.");
|
||||
if (player.GetUser().FactionId == 2) //Fire Department
|
||||
{
|
||||
int medicCount = 0;
|
||||
foreach (Client c in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
var saveMode = player.GetData("quicksavemode");
|
||||
switch (saveMode)
|
||||
if ((c.GetUser()?.Faction.Id ?? 0) == 2)
|
||||
{
|
||||
medicCount++;
|
||||
}
|
||||
}
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", medicCount);
|
||||
}
|
||||
switch (factionId)
|
||||
{
|
||||
//LSPD
|
||||
case 1:
|
||||
nameTagColor = new Color(28, 134, 238);
|
||||
break;
|
||||
}
|
||||
player.NametagColor = nameTagColor;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> clothes = context.CharacterClothes.Where(u => u.UserId == user.Id && u.Duty == true).ToList();
|
||||
|
||||
foreach (var cloth in clothes)
|
||||
{
|
||||
if (cloth.SlotType == 0)
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
case "none":
|
||||
ChatService.SendMessage(player, "~r~Keinen Modus ausgewählt! ~y~/quicksavemode ~r~für mehr Infos!");
|
||||
break;
|
||||
|
||||
case "blip":
|
||||
TempBlip tempBlip = NAPI.Data.GetWorldData("blipTemplate");
|
||||
SaveManager.OnSaveBlipData(player, tempBlip.Sprite.ToString(), tempBlip.Name, tempBlip.Scale.ToString(), tempBlip.Color.ToString(),
|
||||
tempBlip.Transparency.ToString(), 200.ToString(), tempBlip.ShortRange.ToString(), 0.ToString(), 0.ToString());
|
||||
player.SendNotification("~y~Blip~s~ erstellt!", false);
|
||||
break;
|
||||
case "atm":
|
||||
SaveManager.OnSaveBlipData(player, "500", "Geldautomat", 0.7.ToString(), "11",
|
||||
"0", "200", true.ToString(), 0.ToString(), 0.ToString());
|
||||
player.SendNotification("~y~ATM~s~ erstellt!", false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GroundItem.PickUpGroundItem(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:UP_ARROW")]
|
||||
public void KeyPressUpArrow(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (player.HasData("nearATM"))
|
||||
{
|
||||
ATMManager.ShowAtmUi(player, player.GetData("nearATM"));
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:LEFT_ARROW")]
|
||||
public void KeyPressLeftArrow(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
List<Client> nearbyPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(3, player);
|
||||
|
||||
if (nearbyPlayers.Count > 1)
|
||||
{
|
||||
List<string> nearbyPlayerList = new List<string>();
|
||||
foreach (Client nearPlayer in nearbyPlayers)
|
||||
{
|
||||
if (nearPlayer.Name != player.Name)
|
||||
{
|
||||
nearbyPlayerList.Add(nearPlayer.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("showPlayerInteraction", JsonConvert.SerializeObject(nearbyPlayerList));
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:RIGHT_ARROW")]
|
||||
public void KeyPressRightArrow(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
User user = player.GetUser();
|
||||
switch (user.FactionId)
|
||||
{
|
||||
//LSFD
|
||||
case 2:
|
||||
player.TriggerEvent("showFactionInteraction", user.FactionId, user.GetData<bool>("duty"), user.Faction.Name, user.FactionLeader, Medic.ReviveTasks.Count.ToString(), Medic.HealTasks.Count.ToString(), Medic.FireTasks.Count.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:DOWN_ARROW")]
|
||||
public void KeyPressDownArrow(Client player)
|
||||
{
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
var accountData = new
|
||||
{
|
||||
regDate = u.RegistrationDate.ToShortDateString(),
|
||||
adminLevel = u.AdminLevel.GetName(),
|
||||
faction = u.Faction?.Name ?? "Zivilist",
|
||||
factionRank = u.GetFactionRank().RankName,
|
||||
group = u.Group?.Name ?? "Keine",
|
||||
groupRank = u.GroupRank.GetName(),
|
||||
job = JobManager.GetJob(u.JobId ?? 0)?.Name ?? "Keiner"
|
||||
};
|
||||
|
||||
string faction = u.FactionLeader ? u.Faction.Name : null;
|
||||
string group = u.Group != null && u.GroupRank >= GroupRank.MANAGER ? u.Group.Name : null;
|
||||
bool factionInvite = player.HasData("accept_faction_invite");
|
||||
bool groupInvite = player.HasData("accept_group_invite");
|
||||
|
||||
player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), faction, group, factionInvite, groupInvite);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:E")]
|
||||
public void KeyPressE(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
var user = player.GetUser();
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5 && d.FactionId == user.FactionId);
|
||||
if (nearest == null) return;
|
||||
var nameTagColor = new Color(0, 0, 0);
|
||||
var factionId = user.FactionId;
|
||||
|
||||
if (user.GetData<bool>("duty") == false)
|
||||
{
|
||||
user.SetData("duty", true);
|
||||
player.SendNotification("Du bist nun ~g~im Dienst.");
|
||||
if (player.GetUser().FactionId == 2) //Fire Department
|
||||
{
|
||||
int medicCount = 0;
|
||||
foreach (Client c in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
if ((c.GetUser()?.Faction.Id ?? 0) == 2)
|
||||
{
|
||||
medicCount++;
|
||||
}
|
||||
}
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", medicCount);
|
||||
}
|
||||
switch (factionId)
|
||||
{
|
||||
//LSPD
|
||||
case 1:
|
||||
nameTagColor = new Color(28, 134, 238);
|
||||
break;
|
||||
}
|
||||
player.NametagColor = nameTagColor;
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> clothes = context.CharacterClothes.Where(u => u.UserId == user.Id && u.Duty == true).ToList();
|
||||
|
||||
foreach (var cloth in clothes)
|
||||
{
|
||||
if (cloth.SlotType == 0)
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.ClearAccessory(cloth.SlotId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.SetData("duty", false);
|
||||
player.SendNotification("Du bist nun ~r~außer Dienst.");
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false);
|
||||
player.NametagColor = new Color(255, 255, 255);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
player.ClearAccessory(cloth.SlotId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:I")]
|
||||
public void KeyPressI(Client player)
|
||||
else
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
InventoryManager.GetUserItems(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:O")]
|
||||
public void KeyPressJ(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
List<Client> players = NAPI.Pools.GetAllPlayers();
|
||||
var listPlayers = players.Select(p => new
|
||||
{
|
||||
Id = p.Handle.Value,
|
||||
p.Name,
|
||||
p.Ping
|
||||
});
|
||||
player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(listPlayers));
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:K")]
|
||||
public void KeyPressK(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
var user = player.GetUser();
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5);
|
||||
if (nearest == null) return;
|
||||
if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId)
|
||||
{
|
||||
List<string> hats = new List<string>();
|
||||
List<string> tops = new List<string>();
|
||||
List<string> legs = new List<string>();
|
||||
List<string> shoes = new List<string>();
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<DutyCloth> clothes = context.DutyClothes.ToList().FindAll(c => c.FactionId == user.FactionId && c.Gender == user.GetCharacter().Gender);
|
||||
foreach (var cloth in clothes)
|
||||
{
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
hats.Add(cloth.ClothId.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
hats.Add("Keinen");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (cloth.SlotId)
|
||||
{
|
||||
case 11:
|
||||
tops.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
case 4:
|
||||
legs.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
case 6:
|
||||
shoes.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:L")]
|
||||
public void KeyPressL(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
DoorManager.ChangeDoorState(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:N")]
|
||||
public void KeyPressN(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:X")]
|
||||
public void KeyPressX(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
ServerVehicle veh = player.Vehicle.GetServerVehicle();
|
||||
if (veh != null)
|
||||
{
|
||||
if (veh is FactionVehicle fV && fV.FactionId != player.GetUser()?.FactionId && (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (veh is ShopVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("ToggleVehicleMenu");
|
||||
}
|
||||
user.SetData("duty", false);
|
||||
player.SendNotification("Du bist nun ~r~außer Dienst.");
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("updateDutyMedics", false);
|
||||
player.NametagColor = new Color(255, 255, 255);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:I")]
|
||||
public void KeyPressI(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
InventoryManager.GetUserItems(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:O")]
|
||||
public void KeyPressJ(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
List<Client> players = NAPI.Pools.GetAllPlayers();
|
||||
var listPlayers = players.Select(p => new
|
||||
{
|
||||
Id = p.Handle.Value,
|
||||
p.Name,
|
||||
p.Ping
|
||||
});
|
||||
player.TriggerEvent("fetchPlayerList", JsonConvert.SerializeObject(listPlayers));
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:K")]
|
||||
public void KeyPressK(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
var user = player.GetUser();
|
||||
if (user?.FactionId != null)
|
||||
{
|
||||
DutyPoint nearest = PositionManager.DutyPoints.Find(d => d.Position.DistanceTo(player.Position) <= 1.5);
|
||||
if (nearest == null) return;
|
||||
if (player.Position.DistanceTo(nearest.Position) <= 1.5 && nearest.FactionId == user.FactionId)
|
||||
{
|
||||
List<string> hats = new List<string>();
|
||||
List<string> tops = new List<string>();
|
||||
List<string> legs = new List<string>();
|
||||
List<string> shoes = new List<string>();
|
||||
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<DutyCloth> clothes = context.DutyClothes.ToList().FindAll(c => c.FactionId == user.FactionId && c.Gender == user.GetCharacter().Gender);
|
||||
foreach (var cloth in clothes)
|
||||
{
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
if (cloth.ClothId != -1)
|
||||
{
|
||||
hats.Add(cloth.ClothId.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
hats.Add("Keinen");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (cloth.SlotId)
|
||||
{
|
||||
case 11:
|
||||
tops.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
case 4:
|
||||
legs.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
case 6:
|
||||
shoes.Add(cloth.ClothId.ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("showDutyClothMenu", hats.ToArray(), tops.ToArray(), legs.ToArray(), shoes.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:L")]
|
||||
public void KeyPressL(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
DoorManager.ChangeDoorState(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:N")]
|
||||
public void KeyPressN(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
}
|
||||
|
||||
[RemoteEvent("keyPress:X")]
|
||||
public void KeyPressX(Client player)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
ServerVehicle veh = player.Vehicle.GetServerVehicle();
|
||||
if (veh != null)
|
||||
{
|
||||
if (veh is FactionVehicle fV && fV.FactionId != player.GetUser()?.FactionId && (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN3) ?? false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (veh is ShopVehicle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("ToggleVehicleMenu");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,109 +15,109 @@ using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class Login : Script
|
||||
public class Login : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:Login_LoginRequest")]
|
||||
public void OnPlayerLogin(Client player, string username, string password)
|
||||
{
|
||||
[RemoteEvent("CLIENT:Login_LoginRequest")]
|
||||
public void OnPlayerLogin(Client player, string username, string password)
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = dbContext.Users
|
||||
.Include(u => u.Group)
|
||||
.SingleOrDefault(b => b.Name == username);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var user = dbContext.Users
|
||||
.Include(u => u.Group)
|
||||
.SingleOrDefault(b => b.Name == username);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!");
|
||||
//TODO ?? Log einbauen für den bösen Bub.
|
||||
player.Kick();
|
||||
}
|
||||
if (user.Password != NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Name = username;
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("spec", true);
|
||||
player.SetData("duty", false);
|
||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN) == true)
|
||||
{
|
||||
player.SetData("editmode", false);
|
||||
player.SetData("quicksavemode", "none");
|
||||
}
|
||||
|
||||
var userBankAccount = user.GetBankAccount();
|
||||
userBankAccount.Balance = userBankAccount.Balance;
|
||||
|
||||
user.Wanteds = user.Wanteds;
|
||||
|
||||
if(user.Group != null)
|
||||
{
|
||||
string msg = $"{player.Name} ist wieder online.";
|
||||
ChatService.BroadcastGroup(msg, user.Group);
|
||||
}
|
||||
|
||||
var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
player.SetData("items", userItems);
|
||||
|
||||
if (user.CharacterId == null)
|
||||
{
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
player.TriggerEvent("toggleCreator");
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterCreator.ApplyCharacter(player);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
if(user.JailTime == 0)
|
||||
{
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
if (user.Dead == true)
|
||||
{
|
||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
player.Health = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
player.Health = 0;
|
||||
}
|
||||
player.SetData("isDead", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
player.TriggerEvent("SERVER:Login_Error", "Benutzer existiert nicht! Registriere dich zuerst!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.SocialClubName != player.SocialClubName && user.Password == NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzer gehört dir nicht!");
|
||||
//TODO ?? Log einbauen für den bösen Bub.
|
||||
player.Kick();
|
||||
}
|
||||
if (user.Password != NAPI.Util.GetHashSha256(password))
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Passwort inkorrekt!");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Name = username;
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("spec", true);
|
||||
player.SetData("duty", false);
|
||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||
|
||||
if (user.IsAdmin(AdminLevel.HEADADMIN) == true)
|
||||
{
|
||||
player.SetData("editmode", false);
|
||||
player.SetData("quicksavemode", "none");
|
||||
}
|
||||
|
||||
var userBankAccount = user.GetBankAccount();
|
||||
userBankAccount.Balance = userBankAccount.Balance;
|
||||
|
||||
user.Wanteds = user.Wanteds;
|
||||
|
||||
if (user.Group != null)
|
||||
{
|
||||
string msg = $"{player.Name} ist wieder online.";
|
||||
ChatService.BroadcastGroup(msg, user.Group);
|
||||
}
|
||||
|
||||
var userItems = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
player.SetData("items", userItems);
|
||||
|
||||
if (user.CharacterId == null)
|
||||
{
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
player.TriggerEvent("toggleCreator");
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterCreator.ApplyCharacter(player);
|
||||
UpdateCharacterCloth.LoadCharacterDefaults(player);
|
||||
if (user.JailTime == 0)
|
||||
{
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(user.PositionX, user.PositionY, user.PositionZ), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jail.Check_PutBehindBars(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
player.TriggerEvent("draw", player.Name, player.Handle.Value);
|
||||
if (user.Dead == true)
|
||||
{
|
||||
if (user.IsAdmin(AdminLevel.ADMIN) == true)
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", true);
|
||||
player.Health = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("startDeathTimer", false);
|
||||
player.Health = 0;
|
||||
}
|
||||
player.SetData("isDead", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetData("isDead", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,59 +10,59 @@ using ReallifeGamemode.Server.Models;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Register : Script
|
||||
class Register : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:Login_RegisterRequest")]
|
||||
public void OnPlayerRegister(Client player, string username, string password, string passwordRepeat)
|
||||
{
|
||||
[RemoteEvent("CLIENT:Login_RegisterRequest")]
|
||||
public void OnPlayerRegister(Client player, string username, string password, string passwordRepeat)
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!dbContext.Users.Any(u => u.Name.ToLower() == username.ToLower().Trim()))
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (!dbContext.Users.Any(u => u.Name.ToLower() == username.ToLower().Trim()))
|
||||
{
|
||||
var user = new Entities.User
|
||||
{
|
||||
Name = player.Name,
|
||||
SocialClubName = player.SocialClubName,
|
||||
Password = NAPI.Util.GetHashSha256(password),
|
||||
PositionX = Main.DEFAULT_SPAWN_POSITION.X,
|
||||
PositionY = Main.DEFAULT_SPAWN_POSITION.Y,
|
||||
PositionZ = Main.DEFAULT_SPAWN_POSITION.Z
|
||||
};
|
||||
var user = new Entities.User
|
||||
{
|
||||
Name = player.Name,
|
||||
SocialClubName = player.SocialClubName,
|
||||
Password = NAPI.Util.GetHashSha256(password),
|
||||
PositionX = Main.DEFAULT_SPAWN_POSITION.X,
|
||||
PositionY = Main.DEFAULT_SPAWN_POSITION.Y,
|
||||
PositionZ = Main.DEFAULT_SPAWN_POSITION.Z
|
||||
};
|
||||
|
||||
dbContext.Users.Add(user);
|
||||
dbContext.SaveChanges();
|
||||
var userBankAccount = new Entities.UserBankAccount
|
||||
{
|
||||
UserId = user.Id,
|
||||
Balance = 5000,
|
||||
Active = true
|
||||
};
|
||||
dbContext.Users.Add(user);
|
||||
dbContext.SaveChanges();
|
||||
var userBankAccount = new Entities.UserBankAccount
|
||||
{
|
||||
UserId = user.Id,
|
||||
Balance = 5000,
|
||||
Active = true
|
||||
};
|
||||
|
||||
dbContext.UserBankAccounts.Add(userBankAccount);
|
||||
dbContext.SaveChanges();
|
||||
dbContext.UserBankAccounts.Add(userBankAccount);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("isDead", false);
|
||||
player.TriggerEvent("SERVER:Login_Success");
|
||||
player.SetData("isLoggedIn", true);
|
||||
player.SetData("isDead", false);
|
||||
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.TriggerEvent("toggleCreator");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
var currentPlayerCreatorDimension = (uint)NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
currentPlayerCreatorDimension++;
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", currentPlayerCreatorDimension);
|
||||
player.Dimension = NAPI.Data.GetWorldData("playerCreatorDimension");
|
||||
player.TriggerEvent("toggleCreator");
|
||||
player.Position = new Vector3(402.8664, -996.4108, -99.00027);
|
||||
//player.Position = new Vector3(user.PositionX, user.PositionY, user.PositionZ);
|
||||
|
||||
}
|
||||
else if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Es sind schon 3 Konten mit dieser Socialclub-ID registriert.");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzername kann nicht registriert werden.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dbContext.Users.Where(u => u.SocialClubName == player.SocialClubName).Count() >= 3)
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Es sind schon 3 Konten mit dieser Socialclub-ID registriert.");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.TriggerEvent("SERVER:Login_Error", "Dieser Benutzername kann nicht registriert werden.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,25 +15,25 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class ResourceStop : Script
|
||||
public class ResourceStop : Script
|
||||
{
|
||||
[ServerEvent(Event.ResourceStop)]
|
||||
public void OnResourceStop()
|
||||
{
|
||||
[ServerEvent(Event.ResourceStop)]
|
||||
public void OnResourceStop()
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
foreach (Client user in users)
|
||||
{
|
||||
using (var saveUsers = new DatabaseContext())
|
||||
{
|
||||
var users = NAPI.Pools.GetAllPlayers();
|
||||
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
||||
|
||||
foreach (Client user in users)
|
||||
{
|
||||
using (var saveUsers = new DatabaseContext())
|
||||
{
|
||||
var saveUser = saveUsers.Users.SingleOrDefault(u => u.Name == user.Name);
|
||||
|
||||
saveUser.PositionX = user.Position.X;
|
||||
saveUser.PositionY = user.Position.Y;
|
||||
saveUser.PositionZ = user.Position.Z;
|
||||
saveUsers.SaveChanges();
|
||||
}
|
||||
}
|
||||
saveUser.PositionX = user.Position.X;
|
||||
saveUser.PositionY = user.Position.Y;
|
||||
saveUser.PositionZ = user.Position.Z;
|
||||
saveUsers.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,22 +5,22 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Siren : Script
|
||||
class Siren : Script
|
||||
{
|
||||
private readonly Dictionary<NetHandle, bool> _sirenStates = new Dictionary<NetHandle, bool>();
|
||||
|
||||
[RemoteEvent("keyPress:B:toggleSiren")]
|
||||
public void ToggleSirenEvent(Client player)
|
||||
{
|
||||
private readonly Dictionary<NetHandle, bool> _sirenStates = new Dictionary<NetHandle, bool>();
|
||||
if (!player.IsInVehicle || player.VehicleSeat != -1) return;
|
||||
Vehicle pV = player.Vehicle;
|
||||
bool oldValue = _sirenStates.ContainsKey(pV.Handle) ? _sirenStates[pV.Handle] : false;
|
||||
bool newValue = !oldValue;
|
||||
|
||||
[RemoteEvent("keyPress:B:toggleSiren")]
|
||||
public void ToggleSirenEvent(Client player)
|
||||
{
|
||||
if (!player.IsInVehicle || player.VehicleSeat != -1) return;
|
||||
Vehicle pV = player.Vehicle;
|
||||
bool oldValue = _sirenStates.ContainsKey(pV.Handle) ? _sirenStates[pV.Handle] : false;
|
||||
bool newValue = !oldValue;
|
||||
_sirenStates[pV.Handle] = newValue;
|
||||
pV.SetSharedData("sirenSound", newValue);
|
||||
|
||||
_sirenStates[pV.Handle] = newValue;
|
||||
pV.SetSharedData("sirenSound", newValue);
|
||||
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("toggleVehicleSiren", pV, newValue);
|
||||
}
|
||||
NAPI.ClientEvent.TriggerClientEventForAll("toggleVehicleSiren", pV, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Update : Script
|
||||
class Update : Script
|
||||
{
|
||||
[ServerEvent(Event.Update)]
|
||||
public void UpdateEvent()
|
||||
{
|
||||
[ServerEvent(Event.Update)]
|
||||
public void UpdateEvent()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,147 +8,147 @@ using ReallifeGamemode.Server.Models;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class UpdateCharacterCloth : Script
|
||||
public class UpdateCharacterCloth : Script
|
||||
{
|
||||
[RemoteEvent("updateDutyProp")]
|
||||
public void UpdateDutyProp(Client player, int componentId, int componentVariation)
|
||||
{
|
||||
[RemoteEvent("updateDutyProp")]
|
||||
public void UpdateDutyProp(Client player, int componentId, int componentVariation)
|
||||
{
|
||||
if (componentId != -1)
|
||||
{
|
||||
player.SetAccessories(componentId, componentVariation, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.ClearAccessory(0);
|
||||
}
|
||||
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())
|
||||
{
|
||||
var character = player.GetUser().GetCharacter();
|
||||
|
||||
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
|
||||
player.SetClothes(11, componentVariation, 0);
|
||||
if (combination != null)
|
||||
{
|
||||
player.SetClothes(3, combination.Torso, 0);
|
||||
player.SetClothes(8, combination.Undershirt, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(componentId, componentVariation, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("saveCharacterCloth")]
|
||||
public void SaveDutyCloth(Client client, string JSlotType, string JSlotId, string JClothId)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||
|
||||
User user = client.GetUser();
|
||||
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
|
||||
var character = client.GetUser().GetCharacter();
|
||||
|
||||
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
||||
if (charClothes == null)
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = (byte)slotType[x],
|
||||
SlotId = slotId[x],
|
||||
ClothId = clothId[x]
|
||||
};
|
||||
context.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
if (user.GetCharacter().Gender == false)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
|
||||
};
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
|
||||
};
|
||||
context.CharacterClothes.Add(newTorso);
|
||||
context.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
||||
loopCloth.ClothId = clothId[x];
|
||||
}
|
||||
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
||||
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
||||
|
||||
torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
|
||||
undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
LoadCharacterDefaults(client);
|
||||
}
|
||||
|
||||
[RemoteEvent("defaultCharacterCloth")]
|
||||
public static void LoadCharacterDefaults(Client player)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
player.ClearAccessory(6);
|
||||
player.ClearAccessory(7);
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[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())
|
||||
{
|
||||
var character = player.GetUser().GetCharacter();
|
||||
|
||||
var combination = context.ClothCombinations.FirstOrDefault(c => c.Top == componentVariation && c.Gender == character.Gender);
|
||||
player.SetClothes(11, componentVariation, 0);
|
||||
if (combination != null)
|
||||
{
|
||||
player.SetClothes(3, combination.Torso, 0);
|
||||
player.SetClothes(8, combination.Undershirt, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(componentId, componentVariation, 0);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("saveCharacterCloth")]
|
||||
public void SaveDutyCloth(Client client, string JSlotType, string JSlotId, string JClothId)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
int[] slotType = JsonConvert.DeserializeObject<int[]>(JSlotType);
|
||||
int[] slotId = JsonConvert.DeserializeObject<int[]>(JSlotId);
|
||||
int[] clothId = JsonConvert.DeserializeObject<int[]>(JClothId);
|
||||
|
||||
User user = client.GetUser();
|
||||
user = context.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
|
||||
var character = client.GetUser().GetCharacter();
|
||||
|
||||
var charClothes = context.CharacterClothes.FirstOrDefault(c => c.UserId == user.Id);
|
||||
if (charClothes == null)
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
CharacterCloth newCloth = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = (byte)slotType[x],
|
||||
SlotId = slotId[x],
|
||||
ClothId = clothId[x]
|
||||
};
|
||||
context.CharacterClothes.Add(newCloth);
|
||||
}
|
||||
if (user.GetCharacter().Gender == false)
|
||||
{
|
||||
CharacterCloth newTorso = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 3,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso
|
||||
};
|
||||
CharacterCloth newUndershirt = new CharacterCloth
|
||||
{
|
||||
UserId = user.Id,
|
||||
|
||||
Duty = true,
|
||||
|
||||
SlotType = 0,
|
||||
SlotId = 8,
|
||||
ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt
|
||||
};
|
||||
context.CharacterClothes.Add(newTorso);
|
||||
context.CharacterClothes.Add(newUndershirt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var x = 0; x < slotType.Length; x++)
|
||||
{
|
||||
var loopCloth = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == slotType[x] && u.SlotId == slotId[x]);
|
||||
loopCloth.ClothId = clothId[x];
|
||||
}
|
||||
CharacterCloth torso = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 3);
|
||||
CharacterCloth undershirt = context.CharacterClothes.FirstOrDefault(u => u.UserId == user.Id && u.SlotType == 0 && u.SlotId == 8);
|
||||
|
||||
torso.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Torso;
|
||||
undershirt.ClothId = context.ClothCombinations.FirstOrDefault(c => c.Top == clothId[1] && c.Gender == character.Gender).Undershirt;
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
LoadCharacterDefaults(client);
|
||||
}
|
||||
|
||||
[RemoteEvent("defaultCharacterCloth")]
|
||||
public static void LoadCharacterDefaults(Client player)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
List<CharacterCloth> charClothes = context.CharacterClothes.ToList().FindAll(c => c.UserId == user.Id && c.Duty == false);
|
||||
player.ClearAccessory(0);
|
||||
player.ClearAccessory(1);
|
||||
player.ClearAccessory(2);
|
||||
player.ClearAccessory(6);
|
||||
player.ClearAccessory(7);
|
||||
|
||||
foreach (var cloth in charClothes)
|
||||
{
|
||||
if (cloth.SlotType == 1)
|
||||
{
|
||||
player.SetAccessories(cloth.SlotId, cloth.ClothId, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SetClothes(cloth.SlotId, cloth.ClothId, cloth.Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,195 +9,195 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
public class VehicleMenu : Script
|
||||
public class VehicleMenu : Script
|
||||
{
|
||||
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
||||
public void VehicleMenuToggleEngineEvent(Client player)
|
||||
{
|
||||
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
||||
public void VehicleMenuToggleEngineEvent(Client player)
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
bool state = VehicleStreaming.GetEngineState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (fV.FactionId != u.FactionId && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1)
|
||||
{
|
||||
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
||||
return;
|
||||
}
|
||||
|
||||
bool state = VehicleStreaming.GetEngineState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (fV.FactionId != u.FactionId && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if(gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(sV is JobVehicle jV)
|
||||
{
|
||||
if(!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
VehicleStreaming.SetEngineState(v, !state);
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_LockCar")]
|
||||
public void VehicleMenuLockCarEvent(Client player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
bool state = VehicleStreaming.GetLockState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (fV.FactionId != u.FactionId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(v, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.SendNotification(msg);
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
|
||||
public void VehicleMenuParkCarEvent(Client player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
}
|
||||
else if (sV is JobVehicle jV)
|
||||
{
|
||||
if (!jV.GetJob().GetUsersInJob().Contains(player) && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ServerVehicle sV = v.GetServerVehicle(dbContext);
|
||||
|
||||
if (sV == null) return;
|
||||
|
||||
if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(sV is FactionVehicle fV)
|
||||
{
|
||||
if(fV.FactionId != u.FactionId || !u.FactionLeader)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 pos = v.Position;
|
||||
|
||||
sV.PositionX = pos.X;
|
||||
sV.PositionY = pos.Y;
|
||||
sV.PositionZ = pos.Z;
|
||||
sV.Heading = v.Heading;
|
||||
|
||||
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
||||
public void VehicleMenuToggleSingleDoorEvent(Client player, int door)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
Vehicle veh = player.Vehicle;
|
||||
|
||||
DoorID doorId = (DoorID)door;
|
||||
|
||||
DoorState state = VehicleStreaming.GetDoorState(veh, doorId);
|
||||
|
||||
VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen);
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_OpenAllDoors")]
|
||||
public void VehicleMenuOpenAllDoorsEvent(Client player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_CloseAllDoors")]
|
||||
public void VehicleMenuCloseAllDoorsEvent(Client player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed);
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
VehicleStreaming.SetEngineState(v, !state);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_LockCar")]
|
||||
public void VehicleMenuLockCarEvent(Client player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
bool state = VehicleStreaming.GetLockState(v);
|
||||
ServerVehicle sV = v.GetServerVehicle();
|
||||
|
||||
if (sV != null)
|
||||
{
|
||||
if (sV is ShopVehicle)
|
||||
{
|
||||
VehicleStreaming.SetEngineState(v, false);
|
||||
return;
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (fV.FactionId != u.FactionId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(v, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.SendNotification(msg);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
|
||||
public void VehicleMenuParkCarEvent(Client player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ServerVehicle sV = v.GetServerVehicle(dbContext);
|
||||
|
||||
if (sV == null) return;
|
||||
|
||||
if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (fV.FactionId != u.FactionId || !u.FactionLeader)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 pos = v.Position;
|
||||
|
||||
sV.PositionX = pos.X;
|
||||
sV.PositionY = pos.Y;
|
||||
sV.PositionZ = pos.Z;
|
||||
sV.Heading = v.Heading;
|
||||
|
||||
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
||||
public void VehicleMenuToggleSingleDoorEvent(Client player, int door)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
Vehicle veh = player.Vehicle;
|
||||
|
||||
DoorID doorId = (DoorID)door;
|
||||
|
||||
DoorState state = VehicleStreaming.GetDoorState(veh, doorId);
|
||||
|
||||
VehicleStreaming.SetDoorState(veh, doorId, state == DoorState.DoorOpen ? DoorState.DoorClosed : DoorState.DoorOpen);
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_OpenAllDoors")]
|
||||
public void VehicleMenuOpenAllDoorsEvent(Client player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorOpen);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_CloseAllDoors")]
|
||||
public void VehicleMenuCloseAllDoorsEvent(Client player)
|
||||
{
|
||||
if (!player.IsInVehicle) return;
|
||||
Vehicle veh = player.Vehicle;
|
||||
|
||||
foreach (DoorID doorId in Enum.GetValues(typeof(DoorID)))
|
||||
{
|
||||
VehicleStreaming.SetDoorState(veh, doorId, DoorState.DoorClosed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,18 +8,18 @@
|
||||
|
||||
namespace ReallifeGamemode.Server.Events
|
||||
{
|
||||
class Voice : Script
|
||||
class Voice : Script
|
||||
{
|
||||
[RemoteEvent("CLIENT:AddVoiceListener")]
|
||||
public void AddPlayerVoiceListenerEvent(Client player, Client target)
|
||||
{
|
||||
[RemoteEvent("CLIENT:AddVoiceListener")]
|
||||
public void AddPlayerVoiceListenerEvent(Client player, Client target)
|
||||
{
|
||||
player.EnableVoiceTo(target);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:RemoveVoiceListener")]
|
||||
public void RemovePlayerVoiceListenerEvent(Client player, Client target)
|
||||
{
|
||||
player.DisableVoiceTo(target);
|
||||
}
|
||||
player.EnableVoiceTo(target);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:RemoveVoiceListener")]
|
||||
public void RemovePlayerVoiceListenerEvent(Client player, Client target)
|
||||
{
|
||||
player.DisableVoiceTo(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,164 +16,164 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class ClientExtension
|
||||
public static class ClientExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt das User-Objekt eines Client's zurück.
|
||||
/// Gibt nichts zurück, wenn der Client nicht eingeloggt ist
|
||||
/// </summary>
|
||||
/// <param name="client">Der Client, dessen User man bekommen möchte</param>
|
||||
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
|
||||
/// <returns></returns>
|
||||
public static User GetUser(this Client client, DatabaseContext context = null)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt das User-Objekt eines Client's zurück.
|
||||
/// Gibt nichts zurück, wenn der Client nicht eingeloggt ist
|
||||
/// </summary>
|
||||
/// <param name="client">Der Client, dessen User man bekommen möchte</param>
|
||||
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
|
||||
/// <returns></returns>
|
||||
public static User GetUser(this Client client, DatabaseContext context = null)
|
||||
{
|
||||
context = context ?? new DatabaseContext();
|
||||
if (!client.IsLoggedIn()) return null;
|
||||
return context
|
||||
.Users
|
||||
.Include(u => u.Faction)
|
||||
.Include(u => u.FactionRank)
|
||||
.Include(u => u.Group)
|
||||
.Include(u => u.House)
|
||||
.Where(u => u.Name == client.Name)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static Character GetCharacter(this User user, DatabaseContext context = null)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
using (context = new DatabaseContext())
|
||||
{
|
||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt zurück, ob ein Client eingeloggt ist
|
||||
/// </summary>
|
||||
/// <param name="player">Der Client, dessen Login-Status man bekommen möchte</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsLoggedIn(this Client player)
|
||||
{
|
||||
return player.HasData("isLoggedIn") ? player.GetData("isLoggedIn") : false;
|
||||
}
|
||||
|
||||
public static Vector3 GetPositionFromPlayer(Client player, float distance, int offset = 0)
|
||||
{
|
||||
var pos = player.Position;
|
||||
var a = player.Heading + offset;
|
||||
var rad = a * Math.PI / 180;
|
||||
var newpos = new Vector3(pos.X + (distance * Math.Sin(-rad)),
|
||||
pos.Y + (distance * Math.Cos(-rad)),
|
||||
pos.Z);
|
||||
return newpos;
|
||||
}
|
||||
|
||||
internal static T GetData<T>(this User user, string key, T nullValue)
|
||||
{
|
||||
key += "data_";
|
||||
if (!user.Client.HasData(key)) return nullValue;
|
||||
return JsonConvert.DeserializeObject<T>(user.Client.GetData(key));
|
||||
}
|
||||
|
||||
internal static T GetData<T>(this User user, string key) => user.GetData<T>(key, default);
|
||||
|
||||
internal static void SetData(this User user, string key, object value)
|
||||
{
|
||||
key += "data_";
|
||||
user.Client.SetData(key, JsonConvert.SerializeObject(value));
|
||||
}
|
||||
|
||||
internal static void GiveWanteds(this User user, Client cop, int amount, string reason)
|
||||
{
|
||||
if (user.Wanteds + amount > 40)
|
||||
{
|
||||
ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 40 nicht überschreiten");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||
dbUser.Wanteds += amount;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
public static FactionRank GetFactionRank(this User user)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
FactionRank toReturn = dbContext.FactionRanks.FirstOrDefault(fR => fR.Id == user.FactionRankId);
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = dbContext.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == user.FactionId);
|
||||
}
|
||||
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = new FactionRank
|
||||
{
|
||||
RankName = "Rang-Fehler"
|
||||
};
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
||||
public static void BanPlayer(this User user, Client admin, string reason, int mins)
|
||||
{
|
||||
using (var banUserContext = new DatabaseContext())
|
||||
{
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
Ban banUser;
|
||||
|
||||
if (mins == 0)
|
||||
{
|
||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
||||
|
||||
user.Client?.Kick();
|
||||
|
||||
mins--;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
||||
user.Client?.Kick();
|
||||
}
|
||||
|
||||
banUserContext.Bans.Add(banUser);
|
||||
banUserContext.SaveChanges();
|
||||
|
||||
var targetUser = banUserContext.Users.Where(u => u.Name == user.Name).FirstOrDefault();
|
||||
targetUser.BanId = banUser.Id;
|
||||
banUserContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnbanPlayer(this User user)
|
||||
{
|
||||
using (var unbanUser = new DatabaseContext())
|
||||
{
|
||||
var targetUser = unbanUser.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||
targetUser.BanId = null;
|
||||
unbanUser.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<UserItem> GetItems(this User user)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
}
|
||||
}
|
||||
context = context ?? new DatabaseContext();
|
||||
if (!client.IsLoggedIn()) return null;
|
||||
return context
|
||||
.Users
|
||||
.Include(u => u.Faction)
|
||||
.Include(u => u.FactionRank)
|
||||
.Include(u => u.Group)
|
||||
.Include(u => u.House)
|
||||
.Where(u => u.Name == client.Name)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static Character GetCharacter(this User user, DatabaseContext context = null)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
using (context = new DatabaseContext())
|
||||
{
|
||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return context.Characters.FirstOrDefault(u => u.UserId == user.Id);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt zurück, ob ein Client eingeloggt ist
|
||||
/// </summary>
|
||||
/// <param name="player">Der Client, dessen Login-Status man bekommen möchte</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsLoggedIn(this Client player)
|
||||
{
|
||||
return player.HasData("isLoggedIn") ? player.GetData("isLoggedIn") : false;
|
||||
}
|
||||
|
||||
public static Vector3 GetPositionFromPlayer(Client player, float distance, int offset = 0)
|
||||
{
|
||||
var pos = player.Position;
|
||||
var a = player.Heading + offset;
|
||||
var rad = a * Math.PI / 180;
|
||||
var newpos = new Vector3(pos.X + (distance * Math.Sin(-rad)),
|
||||
pos.Y + (distance * Math.Cos(-rad)),
|
||||
pos.Z);
|
||||
return newpos;
|
||||
}
|
||||
|
||||
internal static T GetData<T>(this User user, string key, T nullValue)
|
||||
{
|
||||
key += "data_";
|
||||
if (!user.Client.HasData(key)) return nullValue;
|
||||
return JsonConvert.DeserializeObject<T>(user.Client.GetData(key));
|
||||
}
|
||||
|
||||
internal static T GetData<T>(this User user, string key) => user.GetData<T>(key, default);
|
||||
|
||||
internal static void SetData(this User user, string key, object value)
|
||||
{
|
||||
key += "data_";
|
||||
user.Client.SetData(key, JsonConvert.SerializeObject(value));
|
||||
}
|
||||
|
||||
internal static void GiveWanteds(this User user, Client cop, int amount, string reason)
|
||||
{
|
||||
if (user.Wanteds + amount > 40)
|
||||
{
|
||||
ChatService.ErrorMessage(cop, "Die Wanteds dürfen ein Limit von 40 nicht überschreiten");
|
||||
return;
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User dbUser = dbContext.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||
dbUser.Wanteds += amount;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
public static FactionRank GetFactionRank(this User user)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
FactionRank toReturn = dbContext.FactionRanks.FirstOrDefault(fR => fR.Id == user.FactionRankId);
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = dbContext.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == user.FactionId);
|
||||
}
|
||||
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = new FactionRank
|
||||
{
|
||||
RankName = "Rang-Fehler"
|
||||
};
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
||||
public static void BanPlayer(this User user, Client admin, string reason, int mins)
|
||||
{
|
||||
using (var banUserContext = new DatabaseContext())
|
||||
{
|
||||
int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
||||
Ban banUser;
|
||||
|
||||
if (mins == 0)
|
||||
{
|
||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
||||
|
||||
user.Client?.Kick();
|
||||
|
||||
mins--;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatService.Broadcast("!{#FF4040}[BAN] " + user.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = user.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
||||
user.Client?.Kick();
|
||||
}
|
||||
|
||||
banUserContext.Bans.Add(banUser);
|
||||
banUserContext.SaveChanges();
|
||||
|
||||
var targetUser = banUserContext.Users.Where(u => u.Name == user.Name).FirstOrDefault();
|
||||
targetUser.BanId = banUser.Id;
|
||||
banUserContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnbanPlayer(this User user)
|
||||
{
|
||||
using (var unbanUser = new DatabaseContext())
|
||||
{
|
||||
var targetUser = unbanUser.Users.Where(u => u.Id == user.Id).FirstOrDefault();
|
||||
targetUser.BanId = null;
|
||||
unbanUser.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<UserItem> GetItems(this User user)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,45 +6,45 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class EnumExtensions
|
||||
public static class EnumExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt den richtigen Namen eines Admin Levels zurück
|
||||
/// </summary>
|
||||
/// <param name="level">Das Admin Level, dessen Namen man bekommen möchte</param>
|
||||
/// <returns></returns>
|
||||
public static string GetName(this AdminLevel level)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt den richtigen Namen eines Admin Levels zurück
|
||||
/// </summary>
|
||||
/// <param name="level">Das Admin Level, dessen Namen man bekommen möchte</param>
|
||||
/// <returns></returns>
|
||||
public static string GetName(this AdminLevel level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case SUPPORTER:
|
||||
return "Supporter";
|
||||
case ADMIN:
|
||||
case ADMIN2:
|
||||
case ADMIN3:
|
||||
return "Admin";
|
||||
case HEADADMIN:
|
||||
return "Headadmin";
|
||||
case PROJEKTLEITUNG:
|
||||
return "Projektleiter";
|
||||
default:
|
||||
return "Spieler";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetName(this GroupRank rank)
|
||||
{
|
||||
switch(rank)
|
||||
{
|
||||
case GroupRank.OWNER:
|
||||
return "Besitzer";
|
||||
case GroupRank.MANAGER:
|
||||
return "Manager";
|
||||
case GroupRank.MEMBER:
|
||||
return "Mitglied";
|
||||
default:
|
||||
return "Keiner";
|
||||
}
|
||||
}
|
||||
switch (level)
|
||||
{
|
||||
case SUPPORTER:
|
||||
return "Supporter";
|
||||
case ADMIN:
|
||||
case ADMIN2:
|
||||
case ADMIN3:
|
||||
return "Admin";
|
||||
case HEADADMIN:
|
||||
return "Headadmin";
|
||||
case PROJEKTLEITUNG:
|
||||
return "Projektleiter";
|
||||
default:
|
||||
return "Spieler";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetName(this GroupRank rank)
|
||||
{
|
||||
switch (rank)
|
||||
{
|
||||
case GroupRank.OWNER:
|
||||
return "Besitzer";
|
||||
case GroupRank.MANAGER:
|
||||
return "Manager";
|
||||
case GroupRank.MEMBER:
|
||||
return "Mitglied";
|
||||
default:
|
||||
return "Keiner";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
static class HouseExtensions
|
||||
static class HouseExtensions
|
||||
{
|
||||
public static House Refresh(this House house)
|
||||
{
|
||||
public static House Refresh(this House house)
|
||||
{
|
||||
using(var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Houses.Where(h => h.Id == house.Id).Include(h => h.Owner).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Houses.Where(h => h.Id == house.Id).Include(h => h.Owner).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class IntegerExtension
|
||||
public static class IntegerExtension
|
||||
{
|
||||
public static string ToMoneyString(this int? money)
|
||||
{
|
||||
public static string ToMoneyString(this int? money)
|
||||
{
|
||||
return ToMoneyString(money ?? 0);
|
||||
}
|
||||
public static string ToMoneyString(this int money)
|
||||
{
|
||||
return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "");
|
||||
}
|
||||
return ToMoneyString(money ?? 0);
|
||||
}
|
||||
public static string ToMoneyString(this int money)
|
||||
{
|
||||
return "$" + string.Format(Main.SERVER_CULTURE, "{0:C0}", money).Replace("€", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
static class ListExtensions
|
||||
static class ListExtensions
|
||||
{
|
||||
public static bool Contains(this List<Client> list, Client client)
|
||||
{
|
||||
public static bool Contains(this List<Client> list, Client client)
|
||||
{
|
||||
return list.Any(l => l.Handle.Value == client.Handle.Value);
|
||||
}
|
||||
return list.Any(l => l.Handle.Value == client.Handle.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Extensions
|
||||
{
|
||||
public static class VehicleExtension
|
||||
public static class VehicleExtension
|
||||
{
|
||||
public static ServerVehicle GetServerVehicle(this Vehicle veh, DatabaseContext context = null)
|
||||
{
|
||||
public static ServerVehicle GetServerVehicle(this Vehicle veh, DatabaseContext context = null)
|
||||
{
|
||||
return VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||
}
|
||||
|
||||
public static Client GetDriver(this Vehicle veh)
|
||||
{
|
||||
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == -1).FirstOrDefault();
|
||||
}
|
||||
return VehicleManager.GetServerVehicleFromVehicle(veh, context);
|
||||
}
|
||||
|
||||
public static Client GetDriver(this Vehicle veh)
|
||||
{
|
||||
return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == -1).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,84 +14,84 @@ using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Factions.Medic
|
||||
{
|
||||
public class Medic : Script
|
||||
public class Medic : Script
|
||||
{
|
||||
public static List<MedicTask> ReviveTasks = new List<MedicTask>();
|
||||
public static List<MedicTask> HealTasks = new List<MedicTask>();
|
||||
public static List<MedicTask> FireTasks = new List<MedicTask>();
|
||||
|
||||
public static void AddTaskToList(MedicTask task)
|
||||
{
|
||||
public static List<MedicTask> ReviveTasks = new List<MedicTask>();
|
||||
public static List<MedicTask> HealTasks = new List<MedicTask>();
|
||||
public static List<MedicTask> FireTasks = new List<MedicTask>();
|
||||
if (task == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public static void AddTaskToList(MedicTask task)
|
||||
{
|
||||
if (task == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (task.Type)
|
||||
{
|
||||
case MedicTaskType.REVIVE:
|
||||
ReviveTasks.Add(task);
|
||||
break;
|
||||
case MedicTaskType.HEAL:
|
||||
HealTasks.Add(task);
|
||||
break;
|
||||
case MedicTaskType.FIRE:
|
||||
FireTasks.Add(task);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveTaskFromList(MedicTask task)
|
||||
{
|
||||
if(task == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (task.Type)
|
||||
{
|
||||
case MedicTaskType.REVIVE:
|
||||
ReviveTasks.Remove(task);
|
||||
break;
|
||||
case MedicTaskType.HEAL:
|
||||
HealTasks.Remove(task);
|
||||
break;
|
||||
case MedicTaskType.FIRE:
|
||||
FireTasks.Remove(task);
|
||||
break;
|
||||
}
|
||||
}
|
||||
[RemoteEvent("loadMedicTasks")]
|
||||
public void LoadMedicTasks(Client player, int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks));
|
||||
break;
|
||||
case 1:
|
||||
player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks));
|
||||
break;
|
||||
case 2:
|
||||
player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks));
|
||||
break;
|
||||
}
|
||||
}
|
||||
[RemoteEvent("updateMedicTask")]
|
||||
public void UpdateMedicTasks(Client player, int type, int index, string medicName)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
ReviveTasks[index].MedicName = medicName;
|
||||
break;
|
||||
case 1:
|
||||
HealTasks[index].MedicName = medicName;
|
||||
break;
|
||||
case 2:
|
||||
FireTasks[index].MedicName = medicName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (task.Type)
|
||||
{
|
||||
case MedicTaskType.REVIVE:
|
||||
ReviveTasks.Add(task);
|
||||
break;
|
||||
case MedicTaskType.HEAL:
|
||||
HealTasks.Add(task);
|
||||
break;
|
||||
case MedicTaskType.FIRE:
|
||||
FireTasks.Add(task);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveTaskFromList(MedicTask task)
|
||||
{
|
||||
if (task == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (task.Type)
|
||||
{
|
||||
case MedicTaskType.REVIVE:
|
||||
ReviveTasks.Remove(task);
|
||||
break;
|
||||
case MedicTaskType.HEAL:
|
||||
HealTasks.Remove(task);
|
||||
break;
|
||||
case MedicTaskType.FIRE:
|
||||
FireTasks.Remove(task);
|
||||
break;
|
||||
}
|
||||
}
|
||||
[RemoteEvent("loadMedicTasks")]
|
||||
public void LoadMedicTasks(Client player, int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
player.TriggerEvent("showMedicTasks", 0, JsonConvert.SerializeObject(ReviveTasks));
|
||||
break;
|
||||
case 1:
|
||||
player.TriggerEvent("showMedicTasks", 1, JsonConvert.SerializeObject(HealTasks));
|
||||
break;
|
||||
case 2:
|
||||
player.TriggerEvent("showMedicTasks", 2, JsonConvert.SerializeObject(FireTasks));
|
||||
break;
|
||||
}
|
||||
}
|
||||
[RemoteEvent("updateMedicTask")]
|
||||
public void UpdateMedicTasks(Client player, int type, int index, string medicName)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
ReviveTasks[index].MedicName = medicName;
|
||||
break;
|
||||
case 1:
|
||||
HealTasks[index].MedicName = medicName;
|
||||
break;
|
||||
case 2:
|
||||
FireTasks[index].MedicName = medicName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,22 +12,22 @@ using GTANetworkAPI;
|
||||
|
||||
namespace ReallifeGamemode.Server.Factions.Medic
|
||||
{
|
||||
public class MedicTask
|
||||
{
|
||||
public string Victim { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
public MedicTaskType Type { get; set; }
|
||||
public string CauseOfDeath { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Caller { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
public string MedicName { get; set; }
|
||||
}
|
||||
public class MedicTask
|
||||
{
|
||||
public string Victim { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
public MedicTaskType Type { get; set; }
|
||||
public string CauseOfDeath { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Caller { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
public string MedicName { get; set; }
|
||||
}
|
||||
|
||||
public enum MedicTaskType
|
||||
{
|
||||
REVIVE,
|
||||
HEAL,
|
||||
FIRE
|
||||
}
|
||||
public enum MedicTaskType
|
||||
{
|
||||
REVIVE,
|
||||
HEAL,
|
||||
FIRE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,169 +17,169 @@ using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Finance
|
||||
{
|
||||
public class Economy
|
||||
public class Economy
|
||||
{
|
||||
public static Dictionary<int, Paycheck> Paychecks { get; set; } = new Dictionary<int, Paycheck>();
|
||||
|
||||
public static (int, float, float) GetEconomyClass(Client client, int wage)
|
||||
{
|
||||
public static Dictionary<int, Paycheck> Paychecks { get; set; } = new Dictionary<int, Paycheck>();
|
||||
int bankAccount = client.GetUser().GetBankAccount().Balance;
|
||||
float financialHelp = -(float)Math.Pow(1.0005, -bankAccount) * -1000;
|
||||
float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1;
|
||||
if (financialInterest >= 0.7)
|
||||
financialInterest = 0.7f;
|
||||
|
||||
public static (int, float, float) GetEconomyClass(Client client, int wage)
|
||||
{
|
||||
int bankAccount = client.GetUser().GetBankAccount().Balance;
|
||||
float financialHelp = -(float)Math.Pow(1.0005, -bankAccount) * -1000;
|
||||
float financialInterest = 1 - (float)Math.Pow(1.00006, -wage) * 1;
|
||||
if (financialInterest >= 0.7)
|
||||
financialInterest = 0.7f;
|
||||
|
||||
return (bankAccount, financialHelp, financialInterest);
|
||||
}
|
||||
|
||||
public static int GetVehicleTaxation(Client client)
|
||||
{
|
||||
int vehicleTaxation = 0;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser(dbContext);
|
||||
foreach (VehicleHash vehHash in dbContext.UserVehicles.Where(u => u.UserId == user.Id).Select(u => u.Model))
|
||||
{
|
||||
int type = NAPI.Vehicle.GetVehicleClass(vehHash);
|
||||
switch (type)
|
||||
{
|
||||
/*
|
||||
0 Compacts
|
||||
1 Sedans
|
||||
2 SUVs
|
||||
3 Coupes
|
||||
4 Muscle
|
||||
5 Sports
|
||||
6 Sports
|
||||
7 Super
|
||||
8 Motorcycles
|
||||
9 Off-Road
|
||||
10 Industrial
|
||||
11 Utility
|
||||
12 Vans
|
||||
13 Cycles
|
||||
14 Boats
|
||||
15 Helicopters
|
||||
16 Planes
|
||||
17 Service
|
||||
18 Emergency
|
||||
19 Military
|
||||
20 Commercial
|
||||
21 Trains
|
||||
*/
|
||||
|
||||
case 0:
|
||||
vehicleTaxation += 250;
|
||||
break;
|
||||
case 1:
|
||||
vehicleTaxation += 350;
|
||||
break;
|
||||
case 2:
|
||||
vehicleTaxation += 500;
|
||||
break;
|
||||
case 3:
|
||||
vehicleTaxation += 400;
|
||||
break;
|
||||
case 4:
|
||||
vehicleTaxation += 300;
|
||||
break;
|
||||
case 5:
|
||||
vehicleTaxation += 800;
|
||||
break;
|
||||
case 6:
|
||||
vehicleTaxation += 950;
|
||||
break;
|
||||
case 7:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 8:
|
||||
vehicleTaxation += 400;
|
||||
break;
|
||||
case 9:
|
||||
vehicleTaxation += 500;
|
||||
break;
|
||||
case 10:
|
||||
vehicleTaxation += 300;
|
||||
break;
|
||||
case 11:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 12:
|
||||
vehicleTaxation += 350;
|
||||
break;
|
||||
case 13:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 14:
|
||||
vehicleTaxation += 500;
|
||||
break;
|
||||
case 15:
|
||||
vehicleTaxation += 650;
|
||||
break;
|
||||
case 16:
|
||||
vehicleTaxation += 750;
|
||||
break;
|
||||
case 17:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 18:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 19:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 20:
|
||||
vehicleTaxation += 400;
|
||||
break;
|
||||
case 21:
|
||||
vehicleTaxation += 69696969;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return vehicleTaxation;
|
||||
}
|
||||
|
||||
public static float GetPropertyTaxation(Client client)
|
||||
{
|
||||
float propertyTaxation = 0;
|
||||
User user = client.GetUser();
|
||||
if (user.HouseId != null)
|
||||
{
|
||||
propertyTaxation += user.House.Price * 0.005f;
|
||||
}
|
||||
|
||||
return propertyTaxation;
|
||||
}
|
||||
|
||||
|
||||
public static void SetPaycheck(Client client, int wage)
|
||||
{
|
||||
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
|
||||
float propertyTax = GetPropertyTaxation(client);
|
||||
int vehicleTaxation = GetVehicleTaxation(client);
|
||||
|
||||
int amount = wage - (int)(wage * financialInterest) - vehicleTaxation - (int)propertyTax + (int)financialHelp;
|
||||
|
||||
Paycheck paycheck = new Paycheck(financialHelp, financialInterest, vehicleTaxation, propertyTax, wage, amount);
|
||||
User user = client.GetUser();
|
||||
Paychecks[user.Id] = paycheck;
|
||||
ReleasePayDay(client, paycheck);
|
||||
}
|
||||
|
||||
public static void ReleasePayDay(Client client, Paycheck paycheck)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
client.GetUser().GetBankAccount(dbContext).Balance += paycheck.Amount;
|
||||
client.GetUser(dbContext).Wage = 0;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
if (paycheck.Amount > 0)
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Du hast einen Payday von ~g~$" + paycheck.Amount + "~s~ bekommen.");
|
||||
else
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Du hast einen Payday von ~r~$" + paycheck.Amount + "~s~ bekommen.");
|
||||
|
||||
}
|
||||
return (bankAccount, financialHelp, financialInterest);
|
||||
}
|
||||
|
||||
public static int GetVehicleTaxation(Client client)
|
||||
{
|
||||
int vehicleTaxation = 0;
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User user = client.GetUser(dbContext);
|
||||
foreach (VehicleHash vehHash in dbContext.UserVehicles.Where(u => u.UserId == user.Id).Select(u => u.Model))
|
||||
{
|
||||
int type = NAPI.Vehicle.GetVehicleClass(vehHash);
|
||||
switch (type)
|
||||
{
|
||||
/*
|
||||
0 Compacts
|
||||
1 Sedans
|
||||
2 SUVs
|
||||
3 Coupes
|
||||
4 Muscle
|
||||
5 Sports
|
||||
6 Sports
|
||||
7 Super
|
||||
8 Motorcycles
|
||||
9 Off-Road
|
||||
10 Industrial
|
||||
11 Utility
|
||||
12 Vans
|
||||
13 Cycles
|
||||
14 Boats
|
||||
15 Helicopters
|
||||
16 Planes
|
||||
17 Service
|
||||
18 Emergency
|
||||
19 Military
|
||||
20 Commercial
|
||||
21 Trains
|
||||
*/
|
||||
|
||||
case 0:
|
||||
vehicleTaxation += 250;
|
||||
break;
|
||||
case 1:
|
||||
vehicleTaxation += 350;
|
||||
break;
|
||||
case 2:
|
||||
vehicleTaxation += 500;
|
||||
break;
|
||||
case 3:
|
||||
vehicleTaxation += 400;
|
||||
break;
|
||||
case 4:
|
||||
vehicleTaxation += 300;
|
||||
break;
|
||||
case 5:
|
||||
vehicleTaxation += 800;
|
||||
break;
|
||||
case 6:
|
||||
vehicleTaxation += 950;
|
||||
break;
|
||||
case 7:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 8:
|
||||
vehicleTaxation += 400;
|
||||
break;
|
||||
case 9:
|
||||
vehicleTaxation += 500;
|
||||
break;
|
||||
case 10:
|
||||
vehicleTaxation += 300;
|
||||
break;
|
||||
case 11:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 12:
|
||||
vehicleTaxation += 350;
|
||||
break;
|
||||
case 13:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 14:
|
||||
vehicleTaxation += 500;
|
||||
break;
|
||||
case 15:
|
||||
vehicleTaxation += 650;
|
||||
break;
|
||||
case 16:
|
||||
vehicleTaxation += 750;
|
||||
break;
|
||||
case 17:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 18:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 19:
|
||||
vehicleTaxation += 0;
|
||||
break;
|
||||
case 20:
|
||||
vehicleTaxation += 400;
|
||||
break;
|
||||
case 21:
|
||||
vehicleTaxation += 69696969;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return vehicleTaxation;
|
||||
}
|
||||
|
||||
public static float GetPropertyTaxation(Client client)
|
||||
{
|
||||
float propertyTaxation = 0;
|
||||
User user = client.GetUser();
|
||||
if (user.HouseId != null)
|
||||
{
|
||||
propertyTaxation += user.House.Price * 0.005f;
|
||||
}
|
||||
|
||||
return propertyTaxation;
|
||||
}
|
||||
|
||||
|
||||
public static void SetPaycheck(Client client, int wage)
|
||||
{
|
||||
(int bankAccount, float financialHelp, float financialInterest) = GetEconomyClass(client, wage);
|
||||
float propertyTax = GetPropertyTaxation(client);
|
||||
int vehicleTaxation = GetVehicleTaxation(client);
|
||||
|
||||
int amount = wage - (int)(wage * financialInterest) - vehicleTaxation - (int)propertyTax + (int)financialHelp;
|
||||
|
||||
Paycheck paycheck = new Paycheck(financialHelp, financialInterest, vehicleTaxation, propertyTax, wage, amount);
|
||||
User user = client.GetUser();
|
||||
Paychecks[user.Id] = paycheck;
|
||||
ReleasePayDay(client, paycheck);
|
||||
}
|
||||
|
||||
public static void ReleasePayDay(Client client, Paycheck paycheck)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
client.GetUser().GetBankAccount(dbContext).Balance += paycheck.Amount;
|
||||
client.GetUser(dbContext).Wage = 0;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
if (paycheck.Amount > 0)
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Du hast einen Payday von ~g~$" + paycheck.Amount + "~s~ bekommen.");
|
||||
else
|
||||
ChatService.SendMessage(client, "~g~[PAYDAY]~s~ Du hast einen Payday von ~r~$" + paycheck.Amount + "~s~ bekommen.");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,25 +10,25 @@ using ReallifeGamemode.Server.Services;
|
||||
|
||||
namespace ReallifeGamemode.Server.Finance
|
||||
{
|
||||
public class Paycheck
|
||||
public class Paycheck
|
||||
{
|
||||
public float FinancialHelp { get; set; } = 0;
|
||||
public float FinancialInterest { get; set; } = 0;
|
||||
public int VehicleTaxation { get; set; } = 0;
|
||||
public float PropertyTaxation { get; set; } = 0;
|
||||
public int Wage { get; set; } = 0;
|
||||
public int Amount { get; set; } = 0;
|
||||
|
||||
public Paycheck(float FinancialHelp, float FinancialInterest, int VehicleTaxation, float PropertyTaxation, int Wage, int Amount)
|
||||
{
|
||||
public float FinancialHelp { get; set; } = 0;
|
||||
public float FinancialInterest { get; set; } = 0;
|
||||
public int VehicleTaxation { get; set; } = 0;
|
||||
public float PropertyTaxation { get; set; } = 0;
|
||||
public int Wage { get; set; } = 0;
|
||||
public int Amount { get; set; } = 0;
|
||||
|
||||
public Paycheck(float FinancialHelp, float FinancialInterest, int VehicleTaxation, float PropertyTaxation, int Wage, int Amount)
|
||||
{
|
||||
this.FinancialHelp = FinancialHelp;
|
||||
this.FinancialInterest = FinancialInterest;
|
||||
this.VehicleTaxation = VehicleTaxation;
|
||||
this.PropertyTaxation = PropertyTaxation;
|
||||
this.Wage = Wage;
|
||||
this.Amount = Amount;
|
||||
}
|
||||
|
||||
|
||||
this.FinancialHelp = FinancialHelp;
|
||||
this.FinancialInterest = FinancialInterest;
|
||||
this.VehicleTaxation = VehicleTaxation;
|
||||
this.PropertyTaxation = PropertyTaxation;
|
||||
this.Wage = Wage;
|
||||
this.Amount = Amount;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,102 +9,102 @@ using ReallifeGamemode.Server.Models;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory
|
||||
{
|
||||
public class GroundItem : Script
|
||||
public class GroundItem : Script
|
||||
{
|
||||
public int ItemId { get; set; }
|
||||
public int Amount { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
|
||||
public static List<GroundItem> GroundItems = new List<GroundItem>();
|
||||
public static List<GTANetworkAPI.Object> GroundObjects = new List<GTANetworkAPI.Object>();
|
||||
public static List<TextLabel> GroundTextLabels = new List<TextLabel>();
|
||||
|
||||
public static void AddGroundItem(GroundItem grndItem, GTANetworkAPI.Object grndObject, TextLabel grndTextLabel)
|
||||
{
|
||||
public int ItemId { get; set; }
|
||||
public int Amount { get; set; }
|
||||
public Vector3 Position { get; set; }
|
||||
|
||||
public static List<GroundItem> GroundItems = new List<GroundItem>();
|
||||
public static List<GTANetworkAPI.Object> GroundObjects = new List<GTANetworkAPI.Object>();
|
||||
public static List<TextLabel> GroundTextLabels = new List<TextLabel>();
|
||||
|
||||
public static void AddGroundItem(GroundItem grndItem, GTANetworkAPI.Object grndObject, TextLabel grndTextLabel)
|
||||
{
|
||||
GroundItems.Add(grndItem);
|
||||
GroundObjects.Add(grndObject);
|
||||
GroundTextLabels.Add(grndTextLabel);
|
||||
}
|
||||
|
||||
public static void PickUpGroundItem(Client player)
|
||||
{
|
||||
GroundItem nearest = GroundItems.FirstOrDefault(d => d.Position.DistanceTo(player.Position) <= 1.2);
|
||||
if (nearest != null)
|
||||
{
|
||||
var invWeight = InventoryManager.GetUserInventoryWeight(player);
|
||||
var itemsToAdd = 0;
|
||||
GTANetworkAPI.Object nearestObject = GroundObjects.FirstOrDefault(d => d.Position == nearest.Position);
|
||||
TextLabel nearestTextLabel = GroundTextLabels.FirstOrDefault(d => d.Position == nearest.Position);
|
||||
IItem nearestItem = InventoryManager.GetItemById(nearest.ItemId);
|
||||
UserItem existingItem = InventoryManager.UserHasThisItem(player, nearest.ItemId);
|
||||
var user = player.GetUser();
|
||||
if (nearestItem.Gewicht * nearest.Amount + invWeight > 40000)
|
||||
{
|
||||
for (var i = 1; i <= nearest.Amount; i++)
|
||||
{
|
||||
if (invWeight + (i * nearestItem.Gewicht) > 40000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemsToAdd = i;
|
||||
}
|
||||
}
|
||||
if (itemsToAdd < 1)
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Platz im Inventar!", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existingItem != null)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
UserItem existingUserItem = context.UserItems.FirstOrDefault(i => i.Id == existingItem.Id);
|
||||
existingUserItem.Amount += itemsToAdd;
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UserItem newItem = new UserItem { ItemId = nearest.ItemId, UserId = user.Id, Amount = nearest.Amount };
|
||||
InventoryManager.AddItemToInventory(player, newItem);
|
||||
}
|
||||
nearest.Amount -= itemsToAdd;
|
||||
nearestTextLabel.Text = nearestItem.Name + " ~s~(~y~" + nearest.Amount + "~s~)";
|
||||
player.SendNotification("Du hast nur ~g~" + itemsToAdd + " ~y~" + nearestItem.Name + "~s~ aufgehoben.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existingItem != null)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
UserItem existingUserItem = context.UserItems.FirstOrDefault(i => i.Id == existingItem.Id && i.UserId == user.Id);
|
||||
existingUserItem.Amount += nearest.Amount;
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UserItem item = new UserItem() { ItemId = nearest.ItemId, UserId = user.Id, Amount = nearest.Amount };
|
||||
InventoryManager.AddItemToInventory(player, item);
|
||||
}
|
||||
RemoveGroundItem(nearest, nearestObject, nearestTextLabel);
|
||||
player.SendNotification("Du hast ~g~" + nearest.Amount + " ~y~" + nearestItem.Name + " ~s~aufgehoben.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveGroundItem(GroundItem grndItem, GTANetworkAPI.Object grndObject, TextLabel grndTextLabel)
|
||||
{
|
||||
GroundItems.Remove(grndItem);
|
||||
NAPI.Entity.DeleteEntity(grndObject);
|
||||
NAPI.Entity.DeleteEntity(grndTextLabel);
|
||||
GroundObjects.Remove(grndObject);
|
||||
GroundTextLabels.Remove(grndTextLabel);
|
||||
}
|
||||
GroundItems.Add(grndItem);
|
||||
GroundObjects.Add(grndObject);
|
||||
GroundTextLabels.Add(grndTextLabel);
|
||||
}
|
||||
|
||||
public static void PickUpGroundItem(Client player)
|
||||
{
|
||||
GroundItem nearest = GroundItems.FirstOrDefault(d => d.Position.DistanceTo(player.Position) <= 1.2);
|
||||
if (nearest != null)
|
||||
{
|
||||
var invWeight = InventoryManager.GetUserInventoryWeight(player);
|
||||
var itemsToAdd = 0;
|
||||
GTANetworkAPI.Object nearestObject = GroundObjects.FirstOrDefault(d => d.Position == nearest.Position);
|
||||
TextLabel nearestTextLabel = GroundTextLabels.FirstOrDefault(d => d.Position == nearest.Position);
|
||||
IItem nearestItem = InventoryManager.GetItemById(nearest.ItemId);
|
||||
UserItem existingItem = InventoryManager.UserHasThisItem(player, nearest.ItemId);
|
||||
var user = player.GetUser();
|
||||
if (nearestItem.Gewicht * nearest.Amount + invWeight > 40000)
|
||||
{
|
||||
for (var i = 1; i <= nearest.Amount; i++)
|
||||
{
|
||||
if (invWeight + (i * nearestItem.Gewicht) > 40000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemsToAdd = i;
|
||||
}
|
||||
}
|
||||
if (itemsToAdd < 1)
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Platz im Inventar!", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existingItem != null)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
UserItem existingUserItem = context.UserItems.FirstOrDefault(i => i.Id == existingItem.Id);
|
||||
existingUserItem.Amount += itemsToAdd;
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UserItem newItem = new UserItem { ItemId = nearest.ItemId, UserId = user.Id, Amount = nearest.Amount };
|
||||
InventoryManager.AddItemToInventory(player, newItem);
|
||||
}
|
||||
nearest.Amount -= itemsToAdd;
|
||||
nearestTextLabel.Text = nearestItem.Name + " ~s~(~y~" + nearest.Amount + "~s~)";
|
||||
player.SendNotification("Du hast nur ~g~" + itemsToAdd + " ~y~" + nearestItem.Name + "~s~ aufgehoben.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existingItem != null)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
UserItem existingUserItem = context.UserItems.FirstOrDefault(i => i.Id == existingItem.Id && i.UserId == user.Id);
|
||||
existingUserItem.Amount += nearest.Amount;
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UserItem item = new UserItem() { ItemId = nearest.ItemId, UserId = user.Id, Amount = nearest.Amount };
|
||||
InventoryManager.AddItemToInventory(player, item);
|
||||
}
|
||||
RemoveGroundItem(nearest, nearestObject, nearestTextLabel);
|
||||
player.SendNotification("Du hast ~g~" + nearest.Amount + " ~y~" + nearestItem.Name + " ~s~aufgehoben.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveGroundItem(GroundItem grndItem, GTANetworkAPI.Object grndObject, TextLabel grndTextLabel)
|
||||
{
|
||||
GroundItems.Remove(grndItem);
|
||||
NAPI.Entity.DeleteEntity(grndObject);
|
||||
NAPI.Entity.DeleteEntity(grndTextLabel);
|
||||
GroundObjects.Remove(grndObject);
|
||||
GroundTextLabels.Remove(grndTextLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||
{
|
||||
public interface IDroppableItem : IItem
|
||||
{
|
||||
uint Object { get; }
|
||||
}
|
||||
public interface IDroppableItem : IItem
|
||||
{
|
||||
uint Object { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||
{
|
||||
public interface IItem
|
||||
{
|
||||
int Id { get; }
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
int Gewicht { get; }
|
||||
string Einheit { get; }
|
||||
}
|
||||
public interface IItem
|
||||
{
|
||||
int Id { get; }
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
int Gewicht { get; }
|
||||
string Einheit { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Interfaces
|
||||
{
|
||||
public interface IUsableItem : IItem, IDroppableItem
|
||||
{
|
||||
void Use(UserItem uItem);
|
||||
}
|
||||
public interface IUsableItem : IItem, IDroppableItem
|
||||
{
|
||||
void Use(UserItem uItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,14 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Cheeseburger : FoodItem
|
||||
{
|
||||
public override int Id => 2;
|
||||
public override string Name => "Cheeseburger";
|
||||
public override string Description => "Wie der Hamburger, nur mit Käse.";
|
||||
public override int Gewicht => 320;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 2240524752;
|
||||
}
|
||||
public class Cheeseburger : FoodItem
|
||||
{
|
||||
public override int Id => 2;
|
||||
public override string Name => "Cheeseburger";
|
||||
public override string Description => "Wie der Hamburger, nur mit Käse.";
|
||||
public override int Gewicht => 320;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 2240524752;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,14 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Chickenburger : FoodItem
|
||||
{
|
||||
public override int Id => 3;
|
||||
public override string Name => "Chickenburger";
|
||||
public override string Description => "Hühnchenburger";
|
||||
public override int Gewicht => 330;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 25;
|
||||
public override uint Object => 2240524752;
|
||||
}
|
||||
public class Chickenburger : FoodItem
|
||||
{
|
||||
public override int Id => 3;
|
||||
public override string Name => "Chickenburger";
|
||||
public override string Description => "Hühnchenburger";
|
||||
public override int Gewicht => 330;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 25;
|
||||
public override uint Object => 2240524752;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,20 +9,20 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public abstract class DropItem : IDroppableItem
|
||||
{
|
||||
public abstract int HpAmount { get; }
|
||||
public abstract int Id { get; }
|
||||
public abstract string Name { get; }
|
||||
public abstract string Description { get; }
|
||||
public abstract int Gewicht { get; }
|
||||
public abstract string Einheit { get; }
|
||||
public abstract uint Object { get; }
|
||||
public abstract class DropItem : IDroppableItem
|
||||
{
|
||||
public abstract int HpAmount { get; }
|
||||
public abstract int Id { get; }
|
||||
public abstract string Name { get; }
|
||||
public abstract string Description { get; }
|
||||
public abstract int Gewicht { get; }
|
||||
public abstract string Einheit { get; }
|
||||
public abstract uint Object { get; }
|
||||
|
||||
public void Drop(UserItem uItem, Client player, int amount)
|
||||
{
|
||||
player.SendNotification("Du hast ~g~" + amount + " ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~weggeworfen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, amount);
|
||||
}
|
||||
public void Drop(UserItem uItem, Client player, int amount)
|
||||
{
|
||||
player.SendNotification("Du hast ~g~" + amount + " ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~weggeworfen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,29 +9,29 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public abstract class FoodItem : IUsableItem
|
||||
public abstract class FoodItem : IUsableItem
|
||||
{
|
||||
public abstract int HpAmount { get; }
|
||||
public abstract int Id { get; }
|
||||
public abstract string Name { get; }
|
||||
public abstract string Description { get; }
|
||||
public abstract int Gewicht { get; }
|
||||
public abstract string Einheit { get; }
|
||||
public abstract uint Object { get; }
|
||||
|
||||
public void Use(UserItem uItem)
|
||||
{
|
||||
public abstract int HpAmount { get; }
|
||||
public abstract int Id { get; }
|
||||
public abstract string Name { get; }
|
||||
public abstract string Description { get; }
|
||||
public abstract int Gewicht { get; }
|
||||
public abstract string Einheit { get; }
|
||||
public abstract uint Object { get; }
|
||||
Client player = uItem.GetUser().Client;
|
||||
|
||||
public void Use(UserItem uItem)
|
||||
{
|
||||
Client player = uItem.GetUser().Client;
|
||||
int amountToAdd = HpAmount;
|
||||
if (player.Health + amountToAdd > 100)
|
||||
{
|
||||
amountToAdd = 100 - player.Health;
|
||||
}
|
||||
|
||||
int amountToAdd = HpAmount;
|
||||
if (player.Health + amountToAdd > 100)
|
||||
{
|
||||
amountToAdd = 100 - player.Health;
|
||||
}
|
||||
|
||||
player.Health += amountToAdd;
|
||||
player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
}
|
||||
player.Health += amountToAdd;
|
||||
player.SendNotification("Du hast ein/einen ~y~" + InventoryManager.GetItemById(uItem.ItemId).Name + " ~s~gegessen.", false);
|
||||
InventoryManager.RemoveUserItem(player.GetUser(), uItem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,14 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Hamburger : FoodItem
|
||||
{
|
||||
public override int Id => 1;
|
||||
public override string Name => "Hamburger";
|
||||
public override string Description => "Ein leckerer Hamburger.";
|
||||
public override int Gewicht => 300;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 2240524752;
|
||||
}
|
||||
public class Hamburger : FoodItem
|
||||
{
|
||||
public override int Id => 1;
|
||||
public override string Name => "Hamburger";
|
||||
public override string Description => "Ein leckerer Hamburger.";
|
||||
public override int Gewicht => 300;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 2240524752;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Holz : IDroppableItem
|
||||
{
|
||||
public int Id => 4;
|
||||
public string Name => "Holz";
|
||||
public string Description => "Ich und mein Holz.";
|
||||
public int Gewicht => 1000;
|
||||
public string Einheit => "g";
|
||||
public uint Object => 1805779401;
|
||||
}
|
||||
public class Holz : IDroppableItem
|
||||
{
|
||||
public int Id => 4;
|
||||
public string Name => "Holz";
|
||||
public string Description => "Ich und mein Holz.";
|
||||
public int Gewicht => 1000;
|
||||
public string Einheit => "g";
|
||||
public uint Object => 1805779401;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,14 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Inventory.Items
|
||||
{
|
||||
public class Kraftstoff : DropItem
|
||||
{
|
||||
public override int Id => 5;
|
||||
public override string Name => "Kraftstoff";
|
||||
public override string Description => "Der Stoff gibt dir Kraft.";
|
||||
public override int Gewicht => 1000;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 786272259;
|
||||
}
|
||||
public class Kraftstoff : DropItem
|
||||
{
|
||||
public override int Id => 5;
|
||||
public override string Name => "Kraftstoff";
|
||||
public override string Description => "Der Stoff gibt dir Kraft.";
|
||||
public override int Gewicht => 1000;
|
||||
public override string Einheit => "g";
|
||||
public override int HpAmount => 20;
|
||||
public override uint Object => 786272259;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
class BusDriverJob : JobBase
|
||||
{
|
||||
public override int Id => 4;
|
||||
class BusDriverJob : JobBase
|
||||
{
|
||||
public override int Id => 4;
|
||||
|
||||
public override string Name => "Busfahrer";
|
||||
public override string Name => "Busfahrer";
|
||||
|
||||
public override bool NeedVehicleToStart => true;
|
||||
}
|
||||
public override bool NeedVehicleToStart => true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,53 +11,53 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
public abstract class JobBase
|
||||
public abstract class JobBase
|
||||
{
|
||||
public delegate void JobStartHandler(Client player);
|
||||
public delegate void JobStopHandler(Client player);
|
||||
|
||||
public event JobStartHandler JobStart;
|
||||
public event JobStopHandler JobStop;
|
||||
|
||||
private readonly List<Client> _inJob = new List<Client>();
|
||||
|
||||
public abstract int Id { get; }
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract bool NeedVehicleToStart { get; }
|
||||
|
||||
public void StartJob(Client player)
|
||||
{
|
||||
public delegate void JobStartHandler(Client player);
|
||||
public delegate void JobStopHandler(Client player);
|
||||
if (_inJob.Contains(player)) return;
|
||||
_inJob.Add(player);
|
||||
|
||||
public event JobStartHandler JobStart;
|
||||
public event JobStopHandler JobStop;
|
||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet.");
|
||||
|
||||
private readonly List<Client> _inJob = new List<Client>();
|
||||
|
||||
public abstract int Id { get; }
|
||||
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract bool NeedVehicleToStart { get; }
|
||||
|
||||
public void StartJob(Client player)
|
||||
{
|
||||
if (_inJob.Contains(player)) return;
|
||||
_inJob.Add(player);
|
||||
|
||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ gestartet.");
|
||||
|
||||
JobStart?.Invoke(player);
|
||||
}
|
||||
|
||||
public void StopJob(Client player, bool quit = false)
|
||||
{
|
||||
if (!_inJob.Contains(player)) return;
|
||||
_inJob.Remove(player);
|
||||
|
||||
if (quit)
|
||||
{
|
||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ beendet.");
|
||||
}
|
||||
|
||||
JobStop?.Invoke(player);
|
||||
}
|
||||
|
||||
public List<JobVehicle> GetJobVehicles()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Client> GetUsersInJob() => _inJob;
|
||||
JobStart?.Invoke(player);
|
||||
}
|
||||
|
||||
public void StopJob(Client player, bool quit = false)
|
||||
{
|
||||
if (!_inJob.Contains(player)) return;
|
||||
_inJob.Remove(player);
|
||||
|
||||
if (quit)
|
||||
{
|
||||
ChatService.SendMessage(player, $"~y~[JOB]~s~ Du hast deinen Job ~o~{this.Name}~s~ beendet.");
|
||||
}
|
||||
|
||||
JobStop?.Invoke(player);
|
||||
}
|
||||
|
||||
public List<JobVehicle> GetJobVehicles()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Client> GetUsersInJob() => _inJob;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
class PilotJob : JobBase
|
||||
{
|
||||
public override int Id => 3;
|
||||
class PilotJob : JobBase
|
||||
{
|
||||
public override int Id => 3;
|
||||
|
||||
public override string Name => "Pilot";
|
||||
public override string Name => "Pilot";
|
||||
|
||||
public override bool NeedVehicleToStart => true;
|
||||
}
|
||||
public override bool NeedVehicleToStart => true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
public class RefuseCollectorJob : JobBase
|
||||
{
|
||||
public override int Id => 2;
|
||||
public class RefuseCollectorJob : JobBase
|
||||
{
|
||||
public override int Id => 2;
|
||||
|
||||
public override string Name => "Müllmann";
|
||||
public override string Name => "Müllmann";
|
||||
|
||||
public override bool NeedVehicleToStart => false;
|
||||
}
|
||||
public override bool NeedVehicleToStart => false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,30 +6,30 @@ using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Job
|
||||
{
|
||||
class TaxiDriverJob : JobBase
|
||||
class TaxiDriverJob : JobBase
|
||||
{
|
||||
public List<TaxiContract> TaxiContracts { get; set; } = new List<TaxiContract>();
|
||||
|
||||
public override int Id => 1;
|
||||
|
||||
public override string Name => "Taxifahrer";
|
||||
|
||||
public override bool NeedVehicleToStart => true;
|
||||
|
||||
public TaxiDriverJob()
|
||||
{
|
||||
public List<TaxiContract> TaxiContracts { get; set; } = new List<TaxiContract>();
|
||||
|
||||
public override int Id => 1;
|
||||
|
||||
public override string Name => "Taxifahrer";
|
||||
|
||||
public override bool NeedVehicleToStart => true;
|
||||
|
||||
public TaxiDriverJob()
|
||||
{
|
||||
JobStart += TaxiDriverJobJobStart;
|
||||
JobStop += TaxiDriverJobJobStop;
|
||||
}
|
||||
|
||||
private void TaxiDriverJobJobStart(Client player)
|
||||
{
|
||||
player.Vehicle.SetSharedData("vehicleTaxiLight", true);
|
||||
}
|
||||
|
||||
private void TaxiDriverJobJobStop(Client player)
|
||||
{
|
||||
player.Vehicle.SetSharedData("vehicleTaxiLight", false);
|
||||
}
|
||||
JobStart += TaxiDriverJobJobStart;
|
||||
JobStop += TaxiDriverJobJobStop;
|
||||
}
|
||||
|
||||
private void TaxiDriverJobJobStart(Client player)
|
||||
{
|
||||
player.Vehicle.SetSharedData("vehicleTaxiLight", true);
|
||||
}
|
||||
|
||||
private void TaxiDriverJobJobStop(Client player)
|
||||
{
|
||||
player.Vehicle.SetSharedData("vehicleTaxiLight", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,60 +13,60 @@ using ReallifeGamemode.Server.Wanted;
|
||||
|
||||
namespace ReallifeGamemode.Server
|
||||
{
|
||||
public class Main : Script
|
||||
public class Main : Script
|
||||
{
|
||||
public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-427.5189, 1116.453, 326.7829);
|
||||
public static readonly float DEFAULT_SPAWN_HEADING = 340.8f;
|
||||
|
||||
public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE");
|
||||
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
public static readonly Vector3 DEFAULT_SPAWN_POSITION = new Vector3(-427.5189, 1116.453, 326.7829);
|
||||
public static readonly float DEFAULT_SPAWN_HEADING = 340.8f;
|
||||
NAPI.Server.SetGlobalServerChat(false);
|
||||
|
||||
public static readonly CultureInfo SERVER_CULTURE = new CultureInfo("de-DE");
|
||||
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
NAPI.Server.SetGlobalServerChat(false);
|
||||
|
||||
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
|
||||
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
|
||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
||||
NAPI.Server.SetCommandErrorMessage("~r~[FEHLER]~s~ Dieser Command existiert nicht.");
|
||||
NAPI.Server.SetDefaultSpawnLocation(DEFAULT_SPAWN_POSITION, DEFAULT_SPAWN_HEADING);
|
||||
NAPI.Server.SetAutoSpawnOnConnect(false);
|
||||
NAPI.Server.SetAutoRespawnAfterDeath(false);
|
||||
NAPI.Data.SetWorldData("playerCreatorDimension", 0);
|
||||
|
||||
|
||||
|
||||
InventoryManager.LoadItems();
|
||||
InventoryManager.LoadItems();
|
||||
|
||||
TuningManager.LoadTuningGarages();
|
||||
TuningManager.LoadTuningGarages();
|
||||
|
||||
TimeManager.StartTimeManager();
|
||||
VehicleManager.StartTimer();
|
||||
TimeManager.StartTimeManager();
|
||||
VehicleManager.StartTimer();
|
||||
|
||||
DatabaseHelper.InitDatabaseFirstTime();
|
||||
DatabaseHelper.InitDatabaseFirstTime();
|
||||
|
||||
FactionHelper.CheckFactionBankAccounts();
|
||||
BusinessManager.LoadBusinesses();
|
||||
InteriorManager.LoadInteriors();
|
||||
DoorManager.LoadDoors();
|
||||
ATMManager.InitATMs();
|
||||
CityHallManager.LoadCityHall();
|
||||
JobManager.LoadJobs();
|
||||
HouseManager.LoadHouses();
|
||||
FactionHelper.CheckFactionBankAccounts();
|
||||
BusinessManager.LoadBusinesses();
|
||||
InteriorManager.LoadInteriors();
|
||||
DoorManager.LoadDoors();
|
||||
ATMManager.InitATMs();
|
||||
CityHallManager.LoadCityHall();
|
||||
JobManager.LoadJobs();
|
||||
HouseManager.LoadHouses();
|
||||
|
||||
|
||||
TempBlip tempBlip = new TempBlip()
|
||||
{
|
||||
Color = 1,
|
||||
Name = "",
|
||||
Transparency = 0,
|
||||
ShortRange = true,
|
||||
Sprite = 1,
|
||||
Scale = 1,
|
||||
};
|
||||
TempBlip tempBlip = new TempBlip()
|
||||
{
|
||||
Color = 1,
|
||||
Name = "",
|
||||
Transparency = 0,
|
||||
ShortRange = true,
|
||||
Sprite = 1,
|
||||
Scale = 1,
|
||||
};
|
||||
|
||||
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
|
||||
NAPI.Data.SetWorldData("blipTemplate", tempBlip);
|
||||
|
||||
WantedEscapeTimer.WantedTimer();
|
||||
Jail.JailTimer();
|
||||
WantedEscapeTimer.WantedTimer();
|
||||
Jail.JailTimer();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,141 +15,141 @@ using ReallifeGamemode.Server.Models;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class ATMManager : Script
|
||||
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, Client client)
|
||||
if (addedATMs > 0)
|
||||
{
|
||||
client.SetData("nearATM", colShape.GetData("id"));
|
||||
NAPI.Util.ConsoleOutput(addedATMs + " Geldautomaten hinzugefügt");
|
||||
}
|
||||
public static void ExitATMRange(ColShape colShape, Client client)
|
||||
else
|
||||
{
|
||||
client.ResetData("nearATM");
|
||||
}
|
||||
public static void ShowAtmUi(Client player, int atmId)
|
||||
{
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||
NAPI.Util.ConsoleOutput("Keine Geldautomaten hinzugefügt");
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")]
|
||||
public void AtmAction(Client client, int site, int inputField1, int inputField2)
|
||||
{
|
||||
var user = client.GetUser();
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
int nearATM = client.GetData("nearATM");
|
||||
//SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen
|
||||
switch (site)
|
||||
{
|
||||
//GELD EINZAHLEN in1
|
||||
case 0:
|
||||
var checkPlayer = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
|
||||
if (checkPlayer.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 updateHandMoneyIn = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
var updateBankMoneyIn = dbContext.UserBankAccounts.FirstOrDefault(b => b.UserId == user.Id);
|
||||
var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
updateHandMoneyIn.Handmoney -= inputField1;
|
||||
updateBankMoneyIn.Balance += inputField1;
|
||||
updateATMBalanceIn.Balance += inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyIn.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD AUSZAHLEN in1
|
||||
case 1:
|
||||
var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
var checkBankAccount = dbContext.UserBankAccounts.FirstOrDefault(b => b.UserId == user.Id);
|
||||
|
||||
if (checkBankAccount.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 updateBankMoneyOut = dbContext.UserBankAccounts.FirstOrDefault(b => b.UserId == user.Id);
|
||||
var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
updateHandMoneyOut.Handmoney += inputField1;
|
||||
updateBankMoneyOut.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, Client client)
|
||||
{
|
||||
client.SetData("nearATM", colShape.GetData("id"));
|
||||
}
|
||||
public static void ExitATMRange(ColShape colShape, Client client)
|
||||
{
|
||||
client.ResetData("nearATM");
|
||||
}
|
||||
public static void ShowAtmUi(Client player, int atmId)
|
||||
{
|
||||
player.TriggerEvent("SERVER:ShowAtmUi", atmId);
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:ATM_MANAGER:ATM_ACTION")]
|
||||
public void AtmAction(Client client, int site, int inputField1, int inputField2)
|
||||
{
|
||||
var user = client.GetUser();
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
int nearATM = client.GetData("nearATM");
|
||||
//SITE //0 Geld einzahlen //1 Geld auszahlen //2 Geld überweisen
|
||||
switch (site)
|
||||
{
|
||||
//GELD EINZAHLEN in1
|
||||
case 0:
|
||||
var checkPlayer = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
|
||||
if (checkPlayer.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 updateHandMoneyIn = dbContext.Users.FirstOrDefault(u => u.Id == user.Id);
|
||||
var updateBankMoneyIn = dbContext.UserBankAccounts.FirstOrDefault(b => b.UserId == user.Id);
|
||||
var updateATMBalanceIn = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
updateHandMoneyIn.Handmoney -= inputField1;
|
||||
updateBankMoneyIn.Balance += inputField1;
|
||||
updateATMBalanceIn.Balance += inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyIn.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD AUSZAHLEN in1
|
||||
case 1:
|
||||
var checkATM = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
var checkBankAccount = dbContext.UserBankAccounts.FirstOrDefault(b => b.UserId == user.Id);
|
||||
|
||||
if (checkBankAccount.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 updateBankMoneyOut = dbContext.UserBankAccounts.FirstOrDefault(b => b.UserId == user.Id);
|
||||
var updateATMBalanceOut = dbContext.ATMs.FirstOrDefault(a => a.Id == nearATM);
|
||||
updateHandMoneyOut.Handmoney += inputField1;
|
||||
updateBankMoneyOut.Balance -= inputField1;
|
||||
updateATMBalanceOut.Balance -= inputField1;
|
||||
client.TriggerEvent("SERVER:SET_HANDMONEY", updateHandMoneyOut.Handmoney);
|
||||
}
|
||||
break;
|
||||
|
||||
//GELD ÜBERWEISEN in1 = Kontonr // in2 = Betrag
|
||||
case 2:
|
||||
|
||||
break;
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,79 +18,79 @@ using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class BankManager
|
||||
public class BankManager
|
||||
{
|
||||
public static TransactionResult SetMoney(Client admin, IBankAccountOwner owner, int amount, string reason = "Von Admin gesetzt")
|
||||
{
|
||||
public static TransactionResult SetMoney(Client 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(IBankAccountOwner sender, IBankAccountOwner receiver, int amount, string origin)
|
||||
{
|
||||
using (var transferMoney = new DatabaseContext())
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
IBankAccount senderAccount = sender.GetBankAccount(transferMoney);
|
||||
IBankAccount receiverAccount = receiver.GetBankAccount(transferMoney);
|
||||
|
||||
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.Name,
|
||||
SenderBalance = senderAccount.Balance,
|
||||
Receiver = receiver.Name,
|
||||
ReceiverBalance = receiverAccount.Balance,
|
||||
NewReceiverBalance = receiverAccount.Balance + amount,
|
||||
NewSenderBalance = senderAccount.Balance - amount,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
// add log
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
|
||||
senderAccount.Balance -= amount;
|
||||
receiverAccount.Balance += amount;
|
||||
|
||||
transferMoney.SaveChanges();
|
||||
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
public static TransactionResult TransferMoney(IBankAccountOwner sender, IBankAccountOwner receiver, int amount, string origin)
|
||||
{
|
||||
using (var transferMoney = new DatabaseContext())
|
||||
{
|
||||
if (amount < 0) return TransactionResult.NEGATIVE_MONEY_SENT;
|
||||
|
||||
IBankAccount senderAccount = sender.GetBankAccount(transferMoney);
|
||||
IBankAccount receiverAccount = receiver.GetBankAccount(transferMoney);
|
||||
|
||||
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.Name,
|
||||
SenderBalance = senderAccount.Balance,
|
||||
Receiver = receiver.Name,
|
||||
ReceiverBalance = receiverAccount.Balance,
|
||||
NewReceiverBalance = receiverAccount.Balance + amount,
|
||||
NewSenderBalance = senderAccount.Balance - amount,
|
||||
MoneySent = amount,
|
||||
Fee = 0,
|
||||
Origin = origin
|
||||
};
|
||||
|
||||
// add log
|
||||
transferMoney.BankAccountTransactionLogs.Add(transactionLog);
|
||||
|
||||
senderAccount.Balance -= amount;
|
||||
receiverAccount.Balance += amount;
|
||||
|
||||
transferMoney.SaveChanges();
|
||||
|
||||
return TransactionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,202 +12,202 @@ using System.Reflection;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
class BusinessManager : Script
|
||||
class BusinessManager : Script
|
||||
{
|
||||
public static List<BusinessBase> Businesses { get; private set; }
|
||||
|
||||
public static void LoadBusinesses()
|
||||
{
|
||||
public static List<BusinessBase> Businesses { get; private set; }
|
||||
Businesses = new List<BusinessBase>();
|
||||
|
||||
public static void LoadBusinesses()
|
||||
IEnumerable<Type> allTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(BusinessBase)));
|
||||
foreach (Type item in allTypes)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput($"Loading Business {item.Name}");
|
||||
if (Activator.CreateInstance(item) is BusinessBase o)
|
||||
{
|
||||
Businesses = new List<BusinessBase>();
|
||||
|
||||
IEnumerable<Type> allTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(BusinessBase)));
|
||||
foreach (Type item in allTypes)
|
||||
{
|
||||
NAPI.Util.ConsoleOutput($"Loading Business {item.Name}");
|
||||
if (Activator.CreateInstance(item) is BusinessBase o)
|
||||
{
|
||||
if (GetBusiness(o.Id) != null)
|
||||
{
|
||||
throw new InvalidOperationException($"Double Business ID found: {o.Id} | {o.Name}");
|
||||
}
|
||||
Businesses.Add(o);
|
||||
o.Setup();
|
||||
o.Load();
|
||||
o.Update();
|
||||
}
|
||||
}
|
||||
if (GetBusiness(o.Id) != null)
|
||||
{
|
||||
throw new InvalidOperationException($"Double Business ID found: {o.Id} | {o.Name}");
|
||||
}
|
||||
Businesses.Add(o);
|
||||
o.Setup();
|
||||
o.Load();
|
||||
o.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static T GetBusiness<T>() where T : BusinessBase
|
||||
{
|
||||
return (T)Businesses.Find(b => b.GetType() == typeof(T));
|
||||
}
|
||||
public static T GetBusiness<T>() where T : BusinessBase
|
||||
{
|
||||
return (T)Businesses.Find(b => b.GetType() == typeof(T));
|
||||
}
|
||||
|
||||
public static BusinessBase GetBusiness(int? id)
|
||||
{
|
||||
return Businesses.Find(b => b.Id == id);
|
||||
}
|
||||
public static BusinessBase GetBusiness(int? id)
|
||||
{
|
||||
return Businesses.Find(b => b.Id == id);
|
||||
}
|
||||
|
||||
[RemoteEvent("Business_DepositMoney")]
|
||||
public void BusinessDepositMoney(Client player, int amount)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
[RemoteEvent("Business_DepositMoney")]
|
||||
public void BusinessDepositMoney(Client player, int amount)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BusinessBase playerBusiness = GetBusiness(user.BusinessId);
|
||||
BusinessBase playerBusiness = GetBusiness(user.BusinessId);
|
||||
|
||||
TransactionResult result = BankManager.TransferMoney(user, playerBusiness, amount, "Überweisung");
|
||||
TransactionResult result = BankManager.TransferMoney(user, playerBusiness, amount, "Überweisung");
|
||||
|
||||
/*if(result == TransactionResult.NEGATIVE_MONEY_SENT)
|
||||
{
|
||||
player.SendNotification("~r~Es können nur positive Beträge überwiesen werden");
|
||||
return;
|
||||
}
|
||||
else if(result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||
{
|
||||
player.SendNotification("~r~Du hast nicht genug Geld");
|
||||
return;
|
||||
}
|
||||
else */
|
||||
if (result == TransactionResult.SUCCESS)
|
||||
{
|
||||
player.TriggerEvent("business_updateMoney", playerBusiness.GetBankAccount().Balance.ToMoneyString());
|
||||
player.SendNotification("~g~Du hast erfolgreich ~s~" + amount.ToMoneyString() + " ~g~ überwiesen");
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*if(result == TransactionResult.NEGATIVE_MONEY_SENT)
|
||||
{
|
||||
player.SendNotification("~r~Es können nur positive Beträge überwiesen werden");
|
||||
return;
|
||||
}
|
||||
else if(result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||
{
|
||||
player.SendNotification("~r~Du hast nicht genug Geld");
|
||||
return;
|
||||
}
|
||||
else */
|
||||
if (result == TransactionResult.SUCCESS)
|
||||
{
|
||||
player.TriggerEvent("business_updateMoney", playerBusiness.GetBankAccount().Balance.ToMoneyString());
|
||||
player.SendNotification("~g~Du hast erfolgreich ~s~" + amount.ToMoneyString() + " ~g~ überwiesen");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("Business_WithdrawMoney")]
|
||||
public void BusinessWithdrawMoney(Client player, int amount)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
[RemoteEvent("Business_WithdrawMoney")]
|
||||
public void BusinessWithdrawMoney(Client player, int amount)
|
||||
{
|
||||
User user = player.GetUser();
|
||||
if (user == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BusinessBase playerBusiness = GetBusiness(user.BusinessId);
|
||||
BusinessBase playerBusiness = GetBusiness(user.BusinessId);
|
||||
|
||||
TransactionResult result = BankManager.TransferMoney(playerBusiness, user, amount, "Überweisung");
|
||||
TransactionResult result = BankManager.TransferMoney(playerBusiness, user, amount, "Überweisung");
|
||||
|
||||
if (result == TransactionResult.NEGATIVE_MONEY_SENT)
|
||||
{
|
||||
player.SendNotification("~r~Es können nur positive Beträge überwiesen werden");
|
||||
return;
|
||||
}
|
||||
else if (result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||
{
|
||||
player.SendNotification("~r~Es ist nicht genug Geld auf der Businesskasse vorhanden");
|
||||
return;
|
||||
}
|
||||
else if (result == TransactionResult.SUCCESS)
|
||||
{
|
||||
player.TriggerEvent("business_updateMoney", playerBusiness.GetBankAccount().Balance.ToMoneyString());
|
||||
player.SendNotification("~g~Du hast erfolgreich ~s~" + amount.ToMoneyString() + " ~g~ überwiesen");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (result == TransactionResult.NEGATIVE_MONEY_SENT)
|
||||
{
|
||||
player.SendNotification("~r~Es können nur positive Beträge überwiesen werden");
|
||||
return;
|
||||
}
|
||||
else if (result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||
{
|
||||
player.SendNotification("~r~Es ist nicht genug Geld auf der Businesskasse vorhanden");
|
||||
return;
|
||||
}
|
||||
else if (result == TransactionResult.SUCCESS)
|
||||
{
|
||||
player.TriggerEvent("business_updateMoney", playerBusiness.GetBankAccount().Balance.ToMoneyString());
|
||||
player.SendNotification("~g~Du hast erfolgreich ~s~" + amount.ToMoneyString() + " ~g~ überwiesen");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerEnterVehicle)]
|
||||
public void CarDealerBusiness_PlayerEnterVehicle(Client player, Vehicle veh, int seat)
|
||||
{
|
||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
if (!(sVeh is ShopVehicle)) return;
|
||||
ShopVehicle shopVehicle = (ShopVehicle)sVeh;
|
||||
[ServerEvent(Event.PlayerEnterVehicle)]
|
||||
public void CarDealerBusiness_PlayerEnterVehicle(Client player, Vehicle veh, int seat)
|
||||
{
|
||||
ServerVehicle sVeh = veh.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
if (!(sVeh is ShopVehicle)) return;
|
||||
ShopVehicle shopVehicle = (ShopVehicle)sVeh;
|
||||
|
||||
List<string> availableTargets = new List<string>()
|
||||
List<string> availableTargets = new List<string>()
|
||||
{
|
||||
"Spieler"
|
||||
};
|
||||
|
||||
if (player.GetUser().FactionLeader && !player.GetUser().Faction.StateOwned) availableTargets.Add("Fraktion");
|
||||
if (player.GetUser().GroupRank == GroupRank.OWNER) availableTargets.Add("Gruppe");
|
||||
if (player.GetUser().FactionLeader && !player.GetUser().Faction.StateOwned) availableTargets.Add("Fraktion");
|
||||
if (player.GetUser().GroupRank == GroupRank.OWNER) availableTargets.Add("Gruppe");
|
||||
|
||||
player.TriggerEvent("ShopVehicle_OpenMenu", GetBusiness(shopVehicle.BusinessId).Name, shopVehicle.Price, availableTargets.ToArray());
|
||||
}
|
||||
|
||||
[RemoteEvent("VehShop_BuyVehicle")]
|
||||
public void CarDealerBusiness_BuyVehicle(Client player, string target)
|
||||
{
|
||||
ServerVehicle sVeh = player.Vehicle?.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
if (!(sVeh is ShopVehicle)) return;
|
||||
ShopVehicle shopVehicle = (ShopVehicle)sVeh;
|
||||
int price = shopVehicle.Price;
|
||||
CarDealerBusinessBase business = GetBusiness(shopVehicle.BusinessId) as CarDealerBusinessBase;
|
||||
TransactionResult result = BankManager.TransferMoney(player.GetUser(), business, price, "Auto gekauft");
|
||||
if (result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||
{
|
||||
player.SendNotification("~r~Du hast nicht genug Geld: " + price.ToMoneyString());
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 spawnPos = business.CarSpawnPositon.Around(3);
|
||||
|
||||
player.TriggerEvent("SERVER:Util_setWaypoint", spawnPos.X, spawnPos.Y);
|
||||
|
||||
ServerVehicle newVeh = null;
|
||||
|
||||
if(target == "Spieler")
|
||||
{
|
||||
newVeh = new UserVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
UserId = player.GetUser().Id,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
}
|
||||
else if(target == "Fraktion")
|
||||
{
|
||||
newVeh = new FactionVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
FactionId = player.GetUser().FactionId,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
}
|
||||
else if(target == "Gruppe")
|
||||
{
|
||||
newVeh = new GroupVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
GroupId = player.GetUser().Group.Id,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
dbContext.ServerVehicles.Add(newVeh);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
newVeh.Spawn();
|
||||
}
|
||||
player.TriggerEvent("ShopVehicle_OpenMenu", GetBusiness(shopVehicle.BusinessId).Name, shopVehicle.Price, availableTargets.ToArray());
|
||||
}
|
||||
|
||||
[RemoteEvent("VehShop_BuyVehicle")]
|
||||
public void CarDealerBusiness_BuyVehicle(Client player, string target)
|
||||
{
|
||||
ServerVehicle sVeh = player.Vehicle?.GetServerVehicle();
|
||||
if (sVeh == null) return;
|
||||
if (!(sVeh is ShopVehicle)) return;
|
||||
ShopVehicle shopVehicle = (ShopVehicle)sVeh;
|
||||
int price = shopVehicle.Price;
|
||||
CarDealerBusinessBase business = GetBusiness(shopVehicle.BusinessId) as CarDealerBusinessBase;
|
||||
TransactionResult result = BankManager.TransferMoney(player.GetUser(), business, price, "Auto gekauft");
|
||||
if (result == TransactionResult.SENDER_NOT_ENOUGH_MONEY)
|
||||
{
|
||||
player.SendNotification("~r~Du hast nicht genug Geld: " + price.ToMoneyString());
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 spawnPos = business.CarSpawnPositon.Around(3);
|
||||
|
||||
player.TriggerEvent("SERVER:Util_setWaypoint", spawnPos.X, spawnPos.Y);
|
||||
|
||||
ServerVehicle newVeh = null;
|
||||
|
||||
if (target == "Spieler")
|
||||
{
|
||||
newVeh = new UserVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
UserId = player.GetUser().Id,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
}
|
||||
else if (target == "Fraktion")
|
||||
{
|
||||
newVeh = new FactionVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
FactionId = player.GetUser().FactionId,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
}
|
||||
else if (target == "Gruppe")
|
||||
{
|
||||
newVeh = new GroupVehicle
|
||||
{
|
||||
Heading = business.CarSpawnHeading,
|
||||
PositionX = spawnPos.X,
|
||||
PositionY = spawnPos.Y,
|
||||
PositionZ = spawnPos.Z,
|
||||
Locked = false,
|
||||
GroupId = player.GetUser().Group.Id,
|
||||
Model = shopVehicle.Model,
|
||||
PrimaryColor = 111,
|
||||
SecondaryColor = 111,
|
||||
Active = true,
|
||||
};
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
dbContext.ServerVehicles.Add(newVeh);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
newVeh.Spawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,326 +6,326 @@ using ReallifeGamemode.Server.Models;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class CharacterCreator : Script
|
||||
public class CharacterCreator : Script
|
||||
{
|
||||
public CharacterCreator()
|
||||
{
|
||||
public CharacterCreator()
|
||||
}
|
||||
|
||||
[RemoteEvent("creatorSave")]
|
||||
public void CreatorSave(Client 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 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 Client, dessen Aussehen man setzen will</param>
|
||||
public static void ApplyCharacter(Client player)
|
||||
{
|
||||
var userId = player.GetUser().Id;
|
||||
using (var loadCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = loadCharacter.Characters.SingleOrDefault(c => c.UserId == userId);
|
||||
|
||||
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(Client 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 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 Client, dessen Aussehen man setzen will</param>
|
||||
public static void ApplyCharacter(Client player)
|
||||
{
|
||||
var userId = player.GetUser().Id;
|
||||
using (var loadCharacter = new DatabaseContext())
|
||||
{
|
||||
var character = loadCharacter.Characters.SingleOrDefault(c => c.UserId == userId);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,58 +12,58 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
class CityHallManager : Script
|
||||
class CityHallManager : Script
|
||||
{
|
||||
private static readonly Vector3 _cityHallPosition = new Vector3(273.22, -278.14, 53.9);
|
||||
|
||||
public static void LoadCityHall()
|
||||
{
|
||||
private static readonly Vector3 _cityHallPosition = new Vector3(273.22, -278.14, 53.9);
|
||||
NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, _cityHallPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.0f, new Color(255, 255, 255));
|
||||
NAPI.TextLabel.CreateTextLabel("~y~Stadthalle~s~\nDrücke ~o~E~s~, um das Menü zu öffnen", _cityHallPosition, 5.0f, 1f, 0, new Color(255, 255, 255));
|
||||
var colShape = NAPI.ColShape.CreateSphereColShape(_cityHallPosition, 1.0f);
|
||||
colShape.OnEntityEnterColShape += (s, c) =>
|
||||
{
|
||||
var jobs = JobManager.GetJobs().Select(j => j.Name).ToArray();
|
||||
c.TriggerEvent("SERVER:CityHall_ShowHelpText", JsonConvert.SerializeObject(jobs));
|
||||
};
|
||||
|
||||
public static void LoadCityHall()
|
||||
{
|
||||
NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, _cityHallPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.0f, new Color(255, 255, 255));
|
||||
NAPI.TextLabel.CreateTextLabel("~y~Stadthalle~s~\nDrücke ~o~E~s~, um das Menü zu öffnen", _cityHallPosition, 5.0f, 1f, 0, new Color(255, 255, 255));
|
||||
var colShape = NAPI.ColShape.CreateSphereColShape(_cityHallPosition, 1.0f);
|
||||
colShape.OnEntityEnterColShape += (s, c) =>
|
||||
{
|
||||
var jobs = JobManager.GetJobs().Select(j => j.Name).ToArray();
|
||||
c.TriggerEvent("SERVER:CityHall_ShowHelpText", JsonConvert.SerializeObject(jobs));
|
||||
};
|
||||
|
||||
colShape.OnEntityExitColShape += (s, c) =>
|
||||
{
|
||||
c.TriggerEvent("SERVER:CityHall_ClearHelpText");
|
||||
};
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:CityHall_CreateGroup")]
|
||||
public void CreateGroup(Client player, string name)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = player.GetUser(dbContext);
|
||||
if(u.Group != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du bist schon in einer Gruppe");
|
||||
return;
|
||||
}
|
||||
if(dbContext.Groups.Any(g => g.Name.ToLower() == name.ToLower()))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Name ist schon vergeben");
|
||||
return;
|
||||
}
|
||||
|
||||
Group group = new Group
|
||||
{
|
||||
Name = name
|
||||
};
|
||||
|
||||
dbContext.Groups.Add(group);
|
||||
|
||||
u.Group = group;
|
||||
u.GroupRank = GroupRank.OWNER;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
ChatService.BroadcastGroup($"Die Gruppe \"{name}\" wurde erfolgreich erstellt.", group);
|
||||
}
|
||||
}
|
||||
colShape.OnEntityExitColShape += (s, c) =>
|
||||
{
|
||||
c.TriggerEvent("SERVER:CityHall_ClearHelpText");
|
||||
};
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:CityHall_CreateGroup")]
|
||||
public void CreateGroup(Client player, string name)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = player.GetUser(dbContext);
|
||||
if (u.Group != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du bist schon in einer Gruppe");
|
||||
return;
|
||||
}
|
||||
if (dbContext.Groups.Any(g => g.Name.ToLower() == name.ToLower()))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Name ist schon vergeben");
|
||||
return;
|
||||
}
|
||||
|
||||
Group group = new Group
|
||||
{
|
||||
Name = name
|
||||
};
|
||||
|
||||
dbContext.Groups.Add(group);
|
||||
|
||||
u.Group = group;
|
||||
u.GroupRank = GroupRank.OWNER;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
ChatService.BroadcastGroup($"Die Gruppe \"{name}\" wurde erfolgreich erstellt.", group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,72 +13,72 @@ using ReallifeGamemode.Server.Util;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class DoorManager : Script
|
||||
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(Client 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, Client 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(Client 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, Client 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,96 +10,96 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
class HouseManager
|
||||
class HouseManager
|
||||
{
|
||||
private static readonly Dictionary<int, NetHandle> houseMarkers = new Dictionary<int, NetHandle>();
|
||||
private static readonly Dictionary<int, NetHandle> houseLabels = new Dictionary<int, NetHandle>();
|
||||
private static readonly Dictionary<int, NetHandle> houseColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static void LoadHouses()
|
||||
{
|
||||
private static readonly Dictionary<int, NetHandle> houseMarkers = new Dictionary<int, NetHandle>();
|
||||
private static readonly Dictionary<int, NetHandle> houseLabels = new Dictionary<int, NetHandle>();
|
||||
private static readonly Dictionary<int, NetHandle> houseColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static void LoadHouses()
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (House house in dbContext.Houses.Include(h => h.Owner))
|
||||
{
|
||||
using(var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (House house in dbContext.Houses.Include(h => h.Owner))
|
||||
{
|
||||
LoadHouse(house, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async static void ReloadAllHouses()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach(House house in await dbContext.Houses.Include(h => h.Owner).ToListAsync())
|
||||
{
|
||||
RemoveHouse(house);
|
||||
LoadHouse(house, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static House GetNearHouse(Vector3 position, DatabaseContext dbContext = null)
|
||||
{
|
||||
if(dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddHouse(string type, int price, Vector3 position)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var house = new House()
|
||||
{
|
||||
Price = price,
|
||||
Type = type,
|
||||
X = position.X,
|
||||
Y = position.Y,
|
||||
Z = position.Z
|
||||
};
|
||||
|
||||
dbContext.Houses.Add(house);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
LoadHouse(house);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadHouse(House house, bool loadUser = true)
|
||||
{
|
||||
if (loadUser) house = house.Refresh();
|
||||
|
||||
houseMarkers[house.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, house.Position.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255));
|
||||
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{house.Price.ToMoneyString()}";
|
||||
if(house.User != null)
|
||||
{
|
||||
text = $"{house.Type}\n~s~Besitzer: ~y~{house.User.Name}";
|
||||
}
|
||||
houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
}
|
||||
|
||||
public static void RemoveHouse(House house)
|
||||
{
|
||||
if (houseMarkers.ContainsKey(house.Id))
|
||||
{
|
||||
houseMarkers[house.Id].Entity<Marker>().Delete();
|
||||
houseMarkers.Remove(house.Id);
|
||||
}
|
||||
|
||||
if(houseLabels.ContainsKey(house.Id))
|
||||
{
|
||||
houseLabels[house.Id].Entity<TextLabel>().Delete();
|
||||
houseLabels.Remove(house.Id);
|
||||
}
|
||||
LoadHouse(house, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async static void ReloadAllHouses()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (House house in await dbContext.Houses.Include(h => h.Owner).ToListAsync())
|
||||
{
|
||||
RemoveHouse(house);
|
||||
LoadHouse(house, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static House GetNearHouse(Vector3 position, DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Houses.Where(h => h.Position.DistanceTo(position) <= 5f).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddHouse(string type, int price, Vector3 position)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var house = new House()
|
||||
{
|
||||
Price = price,
|
||||
Type = type,
|
||||
X = position.X,
|
||||
Y = position.Y,
|
||||
Z = position.Z
|
||||
};
|
||||
|
||||
dbContext.Houses.Add(house);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
LoadHouse(house);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadHouse(House house, bool loadUser = true)
|
||||
{
|
||||
if (loadUser) house = house.Refresh();
|
||||
|
||||
houseMarkers[house.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, house.Position.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255));
|
||||
string text = $"~g~Zum Verkauf\n~s~{house.Type}\nPreis: ~y~{house.Price.ToMoneyString()}";
|
||||
if (house.User != null)
|
||||
{
|
||||
text = $"{house.Type}\n~s~Besitzer: ~y~{house.User.Name}";
|
||||
}
|
||||
houseLabels[house.Id] = NAPI.TextLabel.CreateTextLabel(text, house.Position, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
}
|
||||
|
||||
public static void RemoveHouse(House house)
|
||||
{
|
||||
if (houseMarkers.ContainsKey(house.Id))
|
||||
{
|
||||
houseMarkers[house.Id].Entity<Marker>().Delete();
|
||||
houseMarkers.Remove(house.Id);
|
||||
}
|
||||
|
||||
if (houseLabels.ContainsKey(house.Id))
|
||||
{
|
||||
houseLabels[house.Id].Entity<TextLabel>().Delete();
|
||||
houseLabels.Remove(house.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,318 +19,318 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class InteractionManager : Script
|
||||
public class InteractionManager : Script
|
||||
{
|
||||
#region Umgebungsinteraktionen PFEILTASTE-HOCH
|
||||
#endregion
|
||||
#region Eigeninteraktionen PFEILTASTE-RUNTER
|
||||
[RemoteEvent("CLIENT:InteractionMenu_AcceptInvite")]
|
||||
public void InteractionMenuAcceptInvite(Client player, string type)
|
||||
{
|
||||
#region Umgebungsinteraktionen PFEILTASTE-HOCH
|
||||
#endregion
|
||||
#region Eigeninteraktionen PFEILTASTE-RUNTER
|
||||
[RemoteEvent("CLIENT:InteractionMenu_AcceptInvite")]
|
||||
public void InteractionMenuAcceptInvite(Client player, string type)
|
||||
if (type != "Fraktion" && type != "Gruppe") return;
|
||||
|
||||
if (type == "Fraktion") // Fraktions Invite annehmen
|
||||
{
|
||||
if (!player.HasData("accept_faction_invite"))
|
||||
{
|
||||
if (type != "Fraktion" && type != "Gruppe") return;
|
||||
|
||||
if (type == "Fraktion") // Fraktions Invite annehmen
|
||||
{
|
||||
if (!player.HasData("accept_faction_invite"))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du hast keine Einladung in eine Fraktion erhalten");
|
||||
return;
|
||||
}
|
||||
|
||||
Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_faction_invite"));
|
||||
player.ResetData("accept_faction_invite");
|
||||
|
||||
if (leader == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Die Einladung ist abgelaufen");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = leader.GetUser(dbContext);
|
||||
User own = player.GetUser(dbContext);
|
||||
|
||||
own.FactionId = u.FactionId;
|
||||
own.FactionLeader = false;
|
||||
own.FactionRankId = dbContext
|
||||
.FactionRanks
|
||||
.OrderBy(x => x.Order)
|
||||
.Where(r => r.FactionId == own.FactionId)
|
||||
.FirstOrDefault()?.Id ?? null;
|
||||
|
||||
ChatService.SendMessage(leader, "!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
else if (type == "Gruppe") // Gruppen Einladung annehmen
|
||||
{
|
||||
if (!player.HasData("accept_group_invite"))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du hast keine Einladung in eine Gruppe erhalten");
|
||||
return;
|
||||
}
|
||||
|
||||
Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_group_invite"));
|
||||
player.ResetData("accept_group_invite");
|
||||
|
||||
if (leader == null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Die Einladung ist abgelaufen");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
User u = leader.GetUser(dbContext);
|
||||
User own = player.GetUser(dbContext);
|
||||
|
||||
own.Group = u.Group;
|
||||
own.GroupRank = GroupRank.MEMBER;
|
||||
|
||||
ChatService.SendMessage(leader, "!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
ChatService.ErrorMessage(player, "Du hast keine Einladung in eine Fraktion erhalten");
|
||||
return;
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_Invite")]
|
||||
public void InteractionMenuInviteFaction(Client player, string type, string nameOrId)
|
||||
Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_faction_invite"));
|
||||
player.ResetData("accept_faction_invite");
|
||||
|
||||
if (leader == null)
|
||||
{
|
||||
if (type != "Fraktion" && type != "Gruppe") return;
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
User targetUser = target.GetUser();
|
||||
User playerUser = player.GetUser();
|
||||
|
||||
if (type == "Fraktion")
|
||||
{
|
||||
if (playerUser?.FactionId == null || playerUser?.FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.FactionId != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist schon in einer Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
target.SetData("accept_faction_invite", player.Handle);
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast dem Spieler " + target.Name + " eine Einladung in deine Fraktion gesendet.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du hast von " + player.Name + " eine Einladung in die Fraktion \"" + playerUser.Faction.Name + "\" erhalten.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Benutze das Interaktionsmenü, um die Einladung anzunehmen");
|
||||
}
|
||||
else if (type == "Gruppe")
|
||||
{
|
||||
if (playerUser?.Group == null || playerUser.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.Group != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist schon in einer Gruppe");
|
||||
return;
|
||||
}
|
||||
|
||||
target.SetData("accept_group_invite", player.Handle);
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast dem Spieler " + target.Name + " eine Einladung in deine Gruppe gesendet.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du hast von " + player.Name + " eine Einladung in die Gruppe \"" + playerUser.Group.Name + "\" erhalten.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Benutze das Interaktionsmenü, um die Einladung anzunehmen");
|
||||
}
|
||||
ChatService.ErrorMessage(player, "Die Einladung ist abgelaufen");
|
||||
return;
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_Uninvite")]
|
||||
public void InteractionMenuInviteGroup(Client player, string type, string name)
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
if (type != "Fraktion" && type != "Gruppe") return;
|
||||
User u = leader.GetUser(dbContext);
|
||||
User own = player.GetUser(dbContext);
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(name);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
own.FactionId = u.FactionId;
|
||||
own.FactionLeader = false;
|
||||
own.FactionRankId = dbContext
|
||||
.FactionRanks
|
||||
.OrderBy(x => x.Order)
|
||||
.Where(r => r.FactionId == own.FactionId)
|
||||
.FirstOrDefault()?.Id ?? null;
|
||||
|
||||
User targetUser = target.GetUser();
|
||||
User playerUser = player.GetUser();
|
||||
ChatService.SendMessage(leader, "!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
if (type == "Fraktion")
|
||||
{
|
||||
if (playerUser?.FactionId == null || playerUser.FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.FactionId != playerUser?.FactionId)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht in deiner Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.Handle == target.Handle)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst dich nicht selber uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.FactionLeader ?? false)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst keinen Leader uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
target.GetUser(dbContext).FactionRankId = null;
|
||||
target.GetUser(dbContext).FactionId = null;
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " aus der Fraktion geworfen.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du wurdest von " + player.Name + " aus der Fraktion geworfen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
else if (type == "Gruppe")
|
||||
{
|
||||
if (playerUser?.Group == null || playerUser.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.Group.Id != playerUser?.Group.Id)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht in deiner Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.Handle == target.Handle)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst dich nicht selber uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.GroupRank >= GroupRank.MANAGER && playerUser?.GroupRank != GroupRank.OWNER)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst keinen Leader uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
target.GetUser(dbContext).Group = null;
|
||||
target.GetUser(dbContext).GroupRank = GroupRank.NONE;
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " aus der Gruppe geworfen.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du wurdest von " + player.Name + " aus der Gruppe geworfen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
else if (type == "Gruppe") // Gruppen Einladung annehmen
|
||||
{
|
||||
if (!player.HasData("accept_group_invite"))
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du hast keine Einladung in eine Gruppe erhalten");
|
||||
return;
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_CallService_Taxi")]
|
||||
public void CallServiceTaxi(Client player, string street, string zone)
|
||||
Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_group_invite"));
|
||||
player.ResetData("accept_group_invite");
|
||||
|
||||
if (leader == null)
|
||||
{
|
||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||
|
||||
if(taxiJob.TaxiContracts.Where(t => t.Name == player.Name).Count() != 0)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst nur einmal ein Taxi rufen");
|
||||
return;
|
||||
}
|
||||
|
||||
taxiJob.TaxiContracts.Add(new TaxiContract()
|
||||
{
|
||||
Name = player.Name,
|
||||
Position = player.Position
|
||||
});
|
||||
|
||||
string msg = $"!{{02FCFF}}{player.Name} hat in der Straße {street} in {zone} ein Taxi gerufen.";
|
||||
ChatService.BroadcastJob(msg, taxiJob);
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast erfolgreich ein Taxi zu deiner aktuellen Position gerufen.");
|
||||
}
|
||||
#endregion
|
||||
#region Spielerinteraktionen PFEILTASTE-LINKS
|
||||
[RemoteEvent("openTradeInventory")]
|
||||
public void OpenTradeInventory(Client player, string targetPlayer)
|
||||
{
|
||||
InventoryManager.GetUserItems(player);
|
||||
player.TriggerEvent("openTradeMenu", targetPlayer);
|
||||
ChatService.ErrorMessage(player, "Die Einladung ist abgelaufen");
|
||||
return;
|
||||
}
|
||||
|
||||
[RemoteEvent("sendTradeItemsToPartner")]
|
||||
public void SendTradeItemsToPartner(Client player, string tradeItemArray, int tradePrize, string tradePartnerName)
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var tradeItems = JsonConvert.DeserializeObject<string[][]>(tradeItemArray);
|
||||
Client tradePartner = ClientService.GetClientByNameOrId(tradePartnerName);
|
||||
InventoryManager.GetUserItems(player);
|
||||
tradePartner.TriggerEvent("showTradeRequest", player.Name, tradeItems, tradePrize);
|
||||
player.TriggerEvent("startTradeRequestTimer");
|
||||
User u = leader.GetUser(dbContext);
|
||||
User own = player.GetUser(dbContext);
|
||||
|
||||
own.Group = u.Group;
|
||||
own.GroupRank = GroupRank.MEMBER;
|
||||
|
||||
ChatService.SendMessage(leader, "!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
[RemoteEvent("tradeDecision")]
|
||||
public void TradeDecision(Client player, string tradeSelection, string tradeItemArray, string tradeRequesterName, int tradePrize)
|
||||
{
|
||||
var tradeItems = JsonConvert.DeserializeObject<string[][]>(tradeItemArray);
|
||||
Client tradeRequester = ClientService.GetClientByNameOrId(tradeRequesterName);
|
||||
if (tradeSelection == "accept")
|
||||
{
|
||||
if (player.GetUser().Handmoney < tradePrize)
|
||||
{
|
||||
tradeRequester.TriggerEvent("unlockTradeItems");
|
||||
tradeRequester.SendNotification("~y~" + player.Name + " ~r~hat nicht genügend Bargeld! ~s~Handel abgebrochen.");
|
||||
player.SendNotification("~r~Du hast nicht genügend Bargeld! ~s~Handel abgebrochen.");
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryManager.GetUserItems(player);
|
||||
tradeRequester.TriggerEvent("clearTradeItems");
|
||||
player.TriggerEvent("showTradeItems", tradeItemArray);
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var playerUserId = player.GetUser().Id;
|
||||
var tradeRUserId = tradeRequester.GetUser().Id;
|
||||
var playerUser = dbContext.Users.FirstOrDefault(u => u.Id == playerUserId);
|
||||
var tradeRequesterUser = dbContext.Users.FirstOrDefault(u => u.Id == tradeRUserId);
|
||||
|
||||
playerUser.Handmoney -= tradePrize;
|
||||
player.TriggerEvent("SERVER:WORLD_INTERACTION:UPDATE_HANDMONEY", playerUser.Handmoney);
|
||||
|
||||
tradeRequesterUser.Handmoney += tradePrize;
|
||||
tradeRequester.TriggerEvent("SERVER:WORLD_INTERACTION:UPDATE_HANDMONEY", tradeRequesterUser.Handmoney);
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tradeRequester.TriggerEvent("unlockTradeItems");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Fraktionsinteraktionen / Jobinteraktionen PFEILTASTE-RECHTS
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_Invite")]
|
||||
public void InteractionMenuInviteFaction(Client player, string type, string nameOrId)
|
||||
{
|
||||
if (type != "Fraktion" && type != "Gruppe") return;
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
User targetUser = target.GetUser();
|
||||
User playerUser = player.GetUser();
|
||||
|
||||
if (type == "Fraktion")
|
||||
{
|
||||
if (playerUser?.FactionId == null || playerUser?.FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.FactionId != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist schon in einer Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
target.SetData("accept_faction_invite", player.Handle);
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast dem Spieler " + target.Name + " eine Einladung in deine Fraktion gesendet.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du hast von " + player.Name + " eine Einladung in die Fraktion \"" + playerUser.Faction.Name + "\" erhalten.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Benutze das Interaktionsmenü, um die Einladung anzunehmen");
|
||||
}
|
||||
else if (type == "Gruppe")
|
||||
{
|
||||
if (playerUser?.Group == null || playerUser.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.Group != null)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist schon in einer Gruppe");
|
||||
return;
|
||||
}
|
||||
|
||||
target.SetData("accept_group_invite", player.Handle);
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast dem Spieler " + target.Name + " eine Einladung in deine Gruppe gesendet.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du hast von " + player.Name + " eine Einladung in die Gruppe \"" + playerUser.Group.Name + "\" erhalten.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Benutze das Interaktionsmenü, um die Einladung anzunehmen");
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_Uninvite")]
|
||||
public void InteractionMenuInviteGroup(Client player, string type, string name)
|
||||
{
|
||||
if (type != "Fraktion" && type != "Gruppe") return;
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(name);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
User targetUser = target.GetUser();
|
||||
User playerUser = player.GetUser();
|
||||
|
||||
if (type == "Fraktion")
|
||||
{
|
||||
if (playerUser?.FactionId == null || playerUser.FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.FactionId != playerUser?.FactionId)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht in deiner Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.Handle == target.Handle)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst dich nicht selber uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.FactionLeader ?? false)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst keinen Leader uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
target.GetUser(dbContext).FactionRankId = null;
|
||||
target.GetUser(dbContext).FactionId = null;
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " aus der Fraktion geworfen.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du wurdest von " + player.Name + " aus der Fraktion geworfen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
else if (type == "Gruppe")
|
||||
{
|
||||
if (playerUser?.Group == null || playerUser.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.Group.Id != playerUser?.Group.Id)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Dieser Spieler ist nicht in deiner Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.Handle == target.Handle)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst dich nicht selber uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetUser?.GroupRank >= GroupRank.MANAGER && playerUser?.GroupRank != GroupRank.OWNER)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst keinen Leader uninviten");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
|
||||
target.GetUser(dbContext).Group = null;
|
||||
target.GetUser(dbContext).GroupRank = GroupRank.NONE;
|
||||
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " aus der Gruppe geworfen.");
|
||||
ChatService.SendMessage(target, "!{02FCFF}Du wurdest von " + player.Name + " aus der Gruppe geworfen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_CallService_Taxi")]
|
||||
public void CallServiceTaxi(Client player, string street, string zone)
|
||||
{
|
||||
var taxiJob = JobManager.GetJob<TaxiDriverJob>();
|
||||
|
||||
if (taxiJob.TaxiContracts.Where(t => t.Name == player.Name).Count() != 0)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst nur einmal ein Taxi rufen");
|
||||
return;
|
||||
}
|
||||
|
||||
taxiJob.TaxiContracts.Add(new TaxiContract()
|
||||
{
|
||||
Name = player.Name,
|
||||
Position = player.Position
|
||||
});
|
||||
|
||||
string msg = $"!{{02FCFF}}{player.Name} hat in der Straße {street} in {zone} ein Taxi gerufen.";
|
||||
ChatService.BroadcastJob(msg, taxiJob);
|
||||
ChatService.SendMessage(player, "!{02FCFF}Du hast erfolgreich ein Taxi zu deiner aktuellen Position gerufen.");
|
||||
}
|
||||
#endregion
|
||||
#region Spielerinteraktionen PFEILTASTE-LINKS
|
||||
[RemoteEvent("openTradeInventory")]
|
||||
public void OpenTradeInventory(Client player, string targetPlayer)
|
||||
{
|
||||
InventoryManager.GetUserItems(player);
|
||||
player.TriggerEvent("openTradeMenu", targetPlayer);
|
||||
}
|
||||
|
||||
[RemoteEvent("sendTradeItemsToPartner")]
|
||||
public void SendTradeItemsToPartner(Client player, string tradeItemArray, int tradePrize, string tradePartnerName)
|
||||
{
|
||||
var tradeItems = JsonConvert.DeserializeObject<string[][]>(tradeItemArray);
|
||||
Client tradePartner = ClientService.GetClientByNameOrId(tradePartnerName);
|
||||
InventoryManager.GetUserItems(player);
|
||||
tradePartner.TriggerEvent("showTradeRequest", player.Name, tradeItems, tradePrize);
|
||||
player.TriggerEvent("startTradeRequestTimer");
|
||||
}
|
||||
|
||||
[RemoteEvent("tradeDecision")]
|
||||
public void TradeDecision(Client player, string tradeSelection, string tradeItemArray, string tradeRequesterName, int tradePrize)
|
||||
{
|
||||
var tradeItems = JsonConvert.DeserializeObject<string[][]>(tradeItemArray);
|
||||
Client tradeRequester = ClientService.GetClientByNameOrId(tradeRequesterName);
|
||||
if (tradeSelection == "accept")
|
||||
{
|
||||
if (player.GetUser().Handmoney < tradePrize)
|
||||
{
|
||||
tradeRequester.TriggerEvent("unlockTradeItems");
|
||||
tradeRequester.SendNotification("~y~" + player.Name + " ~r~hat nicht genügend Bargeld! ~s~Handel abgebrochen.");
|
||||
player.SendNotification("~r~Du hast nicht genügend Bargeld! ~s~Handel abgebrochen.");
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryManager.GetUserItems(player);
|
||||
tradeRequester.TriggerEvent("clearTradeItems");
|
||||
player.TriggerEvent("showTradeItems", tradeItemArray);
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var playerUserId = player.GetUser().Id;
|
||||
var tradeRUserId = tradeRequester.GetUser().Id;
|
||||
var playerUser = dbContext.Users.FirstOrDefault(u => u.Id == playerUserId);
|
||||
var tradeRequesterUser = dbContext.Users.FirstOrDefault(u => u.Id == tradeRUserId);
|
||||
|
||||
playerUser.Handmoney -= tradePrize;
|
||||
player.TriggerEvent("SERVER:WORLD_INTERACTION:UPDATE_HANDMONEY", playerUser.Handmoney);
|
||||
|
||||
tradeRequesterUser.Handmoney += tradePrize;
|
||||
tradeRequester.TriggerEvent("SERVER:WORLD_INTERACTION:UPDATE_HANDMONEY", tradeRequesterUser.Handmoney);
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tradeRequester.TriggerEvent("unlockTradeItems");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Fraktionsinteraktionen / Jobinteraktionen PFEILTASTE-RECHTS
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,140 +6,140 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
public class InteriorManager : Script
|
||||
public class InteriorManager : Script
|
||||
{
|
||||
public static Dictionary<int, NetHandle> _interiorEnterTextLabels = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorExitTextLabels = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorEnterMarkers = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorExitMarkers = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorEnterColShapes = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorExitColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static Interior GetInteriorByName(string name, DatabaseContext dbContext = null)
|
||||
{
|
||||
public static Dictionary<int, NetHandle> _interiorEnterTextLabels = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorExitTextLabels = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorEnterMarkers = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorExitMarkers = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorEnterColShapes = new Dictionary<int, NetHandle>();
|
||||
public static Dictionary<int, NetHandle> _interiorExitColShapes = new Dictionary<int, NetHandle>();
|
||||
|
||||
public static Interior GetInteriorByName(string name, DatabaseContext dbContext = null)
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Name.ToLower() == name.ToLower()).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Name.ToLower() == name.ToLower()).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static Interior GetInteriorById(int id, DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Id == id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Id == id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadInteriors()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (Interior interior in dbContext.Interiors)
|
||||
{
|
||||
LoadInterior(interior);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadInterior(Interior interior)
|
||||
{
|
||||
if (interior.EnterPosition != null)
|
||||
{
|
||||
_interiorEnterTextLabels[interior.Id] = NAPI.TextLabel.CreateTextLabel("~y~" + interior.Name + "\n~s~Eingang", interior.EnterPosition, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
_interiorEnterMarkers[interior.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, interior.EnterPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255, 100));
|
||||
_interiorEnterColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.EnterPosition, 1.5f);
|
||||
}
|
||||
|
||||
if (interior.ExitPosition != null)
|
||||
{
|
||||
_interiorExitTextLabels[interior.Id] = NAPI.TextLabel.CreateTextLabel("~y~" + interior.Name + "\n~s~Ausgang", interior.ExitPosition, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
_interiorExitMarkers[interior.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, interior.ExitPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255, 100));
|
||||
_interiorExitColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.ExitPosition, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteInterior(Interior interior)
|
||||
{
|
||||
TextLabel enT = GetInteriorEnterTextLabel(interior);
|
||||
TextLabel exT = GetInteriorExitTextLabel(interior);
|
||||
Marker enM = GetInteriorEnterMarker(interior);
|
||||
Marker exM = GetInteriorExitMarkers(interior);
|
||||
ColShape enC = GetInteriorEnterColShape(interior);
|
||||
ColShape exC = GetInteriorExitColShape(interior);
|
||||
|
||||
if (enT != null) enT.Delete();
|
||||
if (exT != null) exT.Delete();
|
||||
if (enM != null) enM.Delete();
|
||||
if (exM != null) exM.Delete();
|
||||
if (enC != null) enC.Delete();
|
||||
if (exC != null) exC.Delete();
|
||||
|
||||
_interiorEnterTextLabels.Remove(interior.Id);
|
||||
_interiorExitTextLabels.Remove(interior.Id);
|
||||
_interiorEnterMarkers.Remove(interior.Id);
|
||||
_interiorExitMarkers.Remove(interior.Id);
|
||||
_interiorEnterColShapes.Remove(interior.Id);
|
||||
_interiorExitColShapes.Remove(interior.Id);
|
||||
}
|
||||
|
||||
public static TextLabel GetInteriorEnterTextLabel(Interior interior) => NAPI.Pools.GetAllTextLabels().Find(t => t.Handle.Value == _interiorEnterTextLabels.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
public static TextLabel GetInteriorExitTextLabel(Interior interior) => NAPI.Pools.GetAllTextLabels().Find(t => t.Handle.Value == _interiorExitTextLabels.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
|
||||
public static Marker GetInteriorEnterMarker(Interior interior) => NAPI.Pools.GetAllMarkers().Find(t => t.Handle.Value == _interiorEnterMarkers.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
public static Marker GetInteriorExitMarkers(Interior interior) => NAPI.Pools.GetAllMarkers().Find(t => t.Handle.Value == _interiorExitMarkers.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
|
||||
public static ColShape GetInteriorEnterColShape(Interior interior) => NAPI.Pools.GetAllColShapes().Find(t => t.Handle.Value == _interiorEnterColShapes.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
public static ColShape GetInteriorExitColShape(Interior interior) => NAPI.Pools.GetAllColShapes().Find(t => t.Handle.Value == _interiorExitColShapes.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
|
||||
public static int GetInteriorIdFromEnterColShape(NetHandle handle) => _interiorEnterColShapes.FirstOrDefault(c => c.Value.Value == handle.Value).Key;
|
||||
public static int GetInteriorIdFromExitColShape(NetHandle handle) => _interiorExitColShapes.FirstOrDefault(c => c.Value.Value == handle.Value).Key;
|
||||
|
||||
[ServerEvent(Event.PlayerEnterColshape)]
|
||||
public void InteriorManagerPlayerEnterColshapeEvent(ColShape colShape, Client player)
|
||||
{
|
||||
int enterId = GetInteriorIdFromEnterColShape(colShape);
|
||||
int exitId = GetInteriorIdFromExitColShape(colShape);
|
||||
if (enterId != 0)
|
||||
{
|
||||
Interior interior = GetInteriorById(enterId);
|
||||
player.TriggerEvent("InteriorManager_ShowHelpText", interior.Name, interior.Id, 0);
|
||||
}
|
||||
else if (exitId != 0)
|
||||
{
|
||||
Interior interior = GetInteriorById(exitId);
|
||||
player.TriggerEvent("InteriorManager_ShowHelpText", interior.Name, interior.Id, 1);
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerExitColshape)]
|
||||
public void InteriorManagerPlayerExitColshapeEvent(ColShape colShape, Client player)
|
||||
{
|
||||
if (GetInteriorIdFromEnterColShape(colShape) != 0 || GetInteriorIdFromExitColShape(colShape) != 0)
|
||||
{
|
||||
player.TriggerEvent("InteriorManager_ClearHelpText");
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("InteriorManager_UseTeleport")]
|
||||
public void InteriorManagerUseTeleportEvent(Client player, int id, int enterExit)
|
||||
{
|
||||
Interior interior = GetInteriorById(id);
|
||||
player.Position = enterExit == 0 ? interior.ExitPosition : interior.EnterPosition;
|
||||
return dbContext.Interiors.Where(i => i.Name.ToLower() == name.ToLower()).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Name.ToLower() == name.ToLower()).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static Interior GetInteriorById(int id, DatabaseContext dbContext = null)
|
||||
{
|
||||
if (dbContext == null)
|
||||
{
|
||||
using (dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Id == id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return dbContext.Interiors.Where(i => i.Id == id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadInteriors()
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
foreach (Interior interior in dbContext.Interiors)
|
||||
{
|
||||
LoadInterior(interior);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadInterior(Interior interior)
|
||||
{
|
||||
if (interior.EnterPosition != null)
|
||||
{
|
||||
_interiorEnterTextLabels[interior.Id] = NAPI.TextLabel.CreateTextLabel("~y~" + interior.Name + "\n~s~Eingang", interior.EnterPosition, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
_interiorEnterMarkers[interior.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, interior.EnterPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255, 100));
|
||||
_interiorEnterColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.EnterPosition, 1.5f);
|
||||
}
|
||||
|
||||
if (interior.ExitPosition != null)
|
||||
{
|
||||
_interiorExitTextLabels[interior.Id] = NAPI.TextLabel.CreateTextLabel("~y~" + interior.Name + "\n~s~Ausgang", interior.ExitPosition, 10f, 1f, 0, new Color(255, 255, 255));
|
||||
_interiorExitMarkers[interior.Id] = NAPI.Marker.CreateMarker(MarkerType.VerticalCylinder, interior.ExitPosition.Subtract(new Vector3(0, 0, 1.7)), new Vector3(), new Vector3(), 1.6f, new Color(255, 255, 255, 100));
|
||||
_interiorExitColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.ExitPosition, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteInterior(Interior interior)
|
||||
{
|
||||
TextLabel enT = GetInteriorEnterTextLabel(interior);
|
||||
TextLabel exT = GetInteriorExitTextLabel(interior);
|
||||
Marker enM = GetInteriorEnterMarker(interior);
|
||||
Marker exM = GetInteriorExitMarkers(interior);
|
||||
ColShape enC = GetInteriorEnterColShape(interior);
|
||||
ColShape exC = GetInteriorExitColShape(interior);
|
||||
|
||||
if (enT != null) enT.Delete();
|
||||
if (exT != null) exT.Delete();
|
||||
if (enM != null) enM.Delete();
|
||||
if (exM != null) exM.Delete();
|
||||
if (enC != null) enC.Delete();
|
||||
if (exC != null) exC.Delete();
|
||||
|
||||
_interiorEnterTextLabels.Remove(interior.Id);
|
||||
_interiorExitTextLabels.Remove(interior.Id);
|
||||
_interiorEnterMarkers.Remove(interior.Id);
|
||||
_interiorExitMarkers.Remove(interior.Id);
|
||||
_interiorEnterColShapes.Remove(interior.Id);
|
||||
_interiorExitColShapes.Remove(interior.Id);
|
||||
}
|
||||
|
||||
public static TextLabel GetInteriorEnterTextLabel(Interior interior) => NAPI.Pools.GetAllTextLabels().Find(t => t.Handle.Value == _interiorEnterTextLabels.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
public static TextLabel GetInteriorExitTextLabel(Interior interior) => NAPI.Pools.GetAllTextLabels().Find(t => t.Handle.Value == _interiorExitTextLabels.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
|
||||
public static Marker GetInteriorEnterMarker(Interior interior) => NAPI.Pools.GetAllMarkers().Find(t => t.Handle.Value == _interiorEnterMarkers.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
public static Marker GetInteriorExitMarkers(Interior interior) => NAPI.Pools.GetAllMarkers().Find(t => t.Handle.Value == _interiorExitMarkers.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
|
||||
public static ColShape GetInteriorEnterColShape(Interior interior) => NAPI.Pools.GetAllColShapes().Find(t => t.Handle.Value == _interiorEnterColShapes.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
public static ColShape GetInteriorExitColShape(Interior interior) => NAPI.Pools.GetAllColShapes().Find(t => t.Handle.Value == _interiorExitColShapes.FirstOrDefault(x => x.Key == interior.Id).Value.Value);
|
||||
|
||||
public static int GetInteriorIdFromEnterColShape(NetHandle handle) => _interiorEnterColShapes.FirstOrDefault(c => c.Value.Value == handle.Value).Key;
|
||||
public static int GetInteriorIdFromExitColShape(NetHandle handle) => _interiorExitColShapes.FirstOrDefault(c => c.Value.Value == handle.Value).Key;
|
||||
|
||||
[ServerEvent(Event.PlayerEnterColshape)]
|
||||
public void InteriorManagerPlayerEnterColshapeEvent(ColShape colShape, Client player)
|
||||
{
|
||||
int enterId = GetInteriorIdFromEnterColShape(colShape);
|
||||
int exitId = GetInteriorIdFromExitColShape(colShape);
|
||||
if (enterId != 0)
|
||||
{
|
||||
Interior interior = GetInteriorById(enterId);
|
||||
player.TriggerEvent("InteriorManager_ShowHelpText", interior.Name, interior.Id, 0);
|
||||
}
|
||||
else if (exitId != 0)
|
||||
{
|
||||
Interior interior = GetInteriorById(exitId);
|
||||
player.TriggerEvent("InteriorManager_ShowHelpText", interior.Name, interior.Id, 1);
|
||||
}
|
||||
}
|
||||
|
||||
[ServerEvent(Event.PlayerExitColshape)]
|
||||
public void InteriorManagerPlayerExitColshapeEvent(ColShape colShape, Client player)
|
||||
{
|
||||
if (GetInteriorIdFromEnterColShape(colShape) != 0 || GetInteriorIdFromExitColShape(colShape) != 0)
|
||||
{
|
||||
player.TriggerEvent("InteriorManager_ClearHelpText");
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("InteriorManager_UseTeleport")]
|
||||
public void InteriorManagerUseTeleportEvent(Client player, int id, int enterExit)
|
||||
{
|
||||
Interior interior = GetInteriorById(id);
|
||||
player.Position = enterExit == 0 ? interior.ExitPosition : interior.EnterPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user