Removed User.GetFaction()
This commit is contained in:
87
ReallifeGamemode.Server/Commands/UserCommands.cs
Normal file
87
ReallifeGamemode.Server/Commands/UserCommands.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Commands
|
||||
{
|
||||
class UserCommands : Script
|
||||
{
|
||||
[Command("accept", "~m~Benutzung: ~s~/accept [invite]")]
|
||||
public void CmdUserAccept(Client player, string option)
|
||||
{
|
||||
if (!player.IsLoggedIn()) return;
|
||||
|
||||
option = option.ToLower();
|
||||
|
||||
switch(option)
|
||||
{
|
||||
case "invite":
|
||||
{
|
||||
if(!player.HasData("accept_invite"))
|
||||
{
|
||||
player.SendChatMessage("~r~[FEHLER]~s~ Du hast keine Einladung in eine Fraktion erhalten.");
|
||||
return;
|
||||
}
|
||||
|
||||
player.ResetData("accept_data");
|
||||
|
||||
using(var dbContext = new DatabaseContext())
|
||||
{
|
||||
Client leader = NAPI.Player.GetPlayerFromHandle((NetHandle)player.GetData("accept_invite"));
|
||||
|
||||
if(leader == null)
|
||||
{
|
||||
player.SendChatMessage("~r~[FEHLER]~s~ Die Einladung ist abgelaufen.");
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[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))
|
||||
{
|
||||
player.SendChatMessage("~m~" + ((VehicleHash)pVeh.Model) + " | " + veh.ToString() + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendChatMessage("~m~" + ((VehicleHash)pVeh.Model) + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendChatMessage("~m~" + ((VehicleHash)pVeh.Model) + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user