add cityhall menu, add self interaction menu (Arrow Down), fix freecam, add group creation, move (faction) invite from commands to menu
This commit is contained in:
67
ReallifeGamemode.Server/Managers/CityHallManager.cs
Normal file
67
ReallifeGamemode.Server/Managers/CityHallManager.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
class CityHallManager : Script
|
||||
{
|
||||
private static readonly Vector3 _cityHallPosition = new Vector3(273.22, -278.14, 53.9);
|
||||
|
||||
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) =>
|
||||
{
|
||||
c.TriggerEvent("SERVER:CityHall_ShowHelpText");
|
||||
};
|
||||
|
||||
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.Error(player, "Du bist schon in einer Gruppe");
|
||||
return;
|
||||
}
|
||||
if(dbContext.Groups.Any(g => g.Name.ToLower() == name.ToLower()))
|
||||
{
|
||||
ChatService.Error(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
using GTANetworkAPI;
|
||||
using Newtonsoft.Json;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
@@ -19,6 +23,108 @@ namespace ReallifeGamemode.Server.Managers
|
||||
#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"))
|
||||
{
|
||||
ChatService.Error(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.Error(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;
|
||||
|
||||
leader.SendChatMessage("!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
player.SendChatMessage("!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
else if (type == "Gruppe") // Gruppen Einladung annehmen
|
||||
{
|
||||
if (!player.HasData("accept_group_invite"))
|
||||
{
|
||||
ChatService.Error(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.Error(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;
|
||||
|
||||
leader.SendChatMessage("!{02FCFF}" + player.Name + " hat die Einladung angenommen.");
|
||||
player.SendChatMessage("!{02FCFF}Du hast die Einladung angenommen.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:InteractionMenu_InviteFaction")]
|
||||
public void InteractionMenuInviteFaction(Client player, string nameOrId)
|
||||
{
|
||||
if (player.GetUser()?.FactionId == null || player.GetUser().FactionLeader == false)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Client target = ClientService.GetClientByNameOrId(nameOrId);
|
||||
if (target == null || !target.IsLoggedIn())
|
||||
{
|
||||
ChatService.PlayerNotFound(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.GetUser()?.FactionId != null)
|
||||
{
|
||||
ChatService.Error(player, "Dieser Spieler ist schon in einer Fraktion");
|
||||
return;
|
||||
}
|
||||
|
||||
target.SetData("accept_faction_invite", player.Handle);
|
||||
|
||||
player.SendChatMessage("!{02FCFF}Du hast dem Spieler " + target.Name + " eine Einladung in deine Fraktion gesendet.");
|
||||
target.SendChatMessage("!{02FCFF}Du hast von " + player.Name + " eine Einladung in die Fraktion \"" + player.GetUser().Faction.Name + "\" erhalten.");
|
||||
target.SendChatMessage("!{02FCFF}Benutze das Interaktionsmenü, um die Einladung anzunehmen");
|
||||
}
|
||||
#endregion
|
||||
#region Spielerinteraktionen PFEILTASTE-LINKS
|
||||
[RemoteEvent("openTradeInventory")]
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
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(), 2.0f, new Color(255, 255, 255, 100));
|
||||
_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);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace ReallifeGamemode.Server.Managers
|
||||
{
|
||||
_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.3f);
|
||||
_interiorExitColShapes[interior.Id] = NAPI.ColShape.CreateSphereColShape(interior.ExitPosition, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user