Added commands to assign business to user

This commit is contained in:
hydrant
2018-11-19 22:24:06 +01:00
parent 225eb78ced
commit cef42180c9
7 changed files with 130 additions and 9 deletions

View File

@@ -15,6 +15,7 @@ using reallife_gamemode.Server.Services;
using reallife_gamemode.Server.Util;
using reallife_gamemode.Server.Managers;
using reallife_gamemode.Server.Saves;
using reallife_gamemode.Server.Business;
/**
* @overview Life of German Reallife - Admin Commands (Admin.cs)
@@ -172,6 +173,22 @@ namespace reallife_gamemode.Server.Commands
}
}
}
[Command("businesslist", "~m~Benutzung: ~s~/businesslist")]
public void CmdAdminBusinessList(Client player)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
{
ChatService.NotAuthorized(player);
return;
}
player.SendChatMessage("~m~__________ ~s~Businesses ~m~__________");
foreach (Business.BusinessBase b in BusinessManager.Businesses)
{
player.SendChatMessage(b.Id.ToString().PadRight(3) + " | " + b.Name);
}
}
#endregion
@@ -1644,6 +1661,7 @@ namespace reallife_gamemode.Server.Commands
NAPI.Chat.SendChatMessageToPlayer(player, "~w~Das Wetter konnte nicht geändert werden");
}
}
[Command("aspeed", "~m~Benutzung: ~s~/aspeed [Modifier]")] //TODO: Überarbeiten ?? SetPlayerVelocity ??
public void CmdAdminAspeed(Client player, float modifier)
{
@@ -1661,7 +1679,8 @@ namespace reallife_gamemode.Server.Commands
player.Vehicle.EnginePowerMultiplier = modifier;
}
[Command("setmoney")]
[Command("setmoney", "~m~Benutzung: ~s~/setmoney [Name] [Menge]")]
public void SetPlayerMoney(Client player, string receiver, int amount)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
@@ -1685,7 +1704,7 @@ namespace reallife_gamemode.Server.Commands
target.SendChatMessage("~b~[ADMIN]~s~ Dein Geld wurde von Admin " + player.Name + " auf ~g~$" + amount + "~s~ gesetzt.");
}
[Command("givemoney")]
[Command("givemoney", "~m~Benutzung: ~s~/givemoney [Name] [Menge]")]
public void GivePlayerMoney(Client player, string receiver, int amount)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
@@ -1693,6 +1712,7 @@ namespace reallife_gamemode.Server.Commands
ChatService.NotAuthorized(player);
return;
}
Client target = ClientService.GetClientByNameOrId(receiver);
if (target == null || !target.IsLoggedIn())
{
@@ -1708,6 +1728,46 @@ namespace reallife_gamemode.Server.Commands
player.SendChatMessage("~b~[ADMIN]~s~ Du hast " + target.Name + " ~g~$" + amount + "~s~ gegeben.");
target.SendChatMessage("~b~[ADMIN]~s~ Admin " + player.Name + " hat dir ~g~$" + amount + "~s~ gegeben.");
}
[Command("setbusinessowner", "~m~Benutzung: ~s~/setbusinessowner [Name] [Business ID]")]
public void CmdAdminSetbusinessowner(Client player, string name, int businessid)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
{
ChatService.NotAuthorized(player);
return;
}
Client target = ClientService.GetClientByNameOrId(name);
if (target == null || !target.IsLoggedIn())
{
ChatService.PlayerNotFound(player);
return;
}
BusinessBase business = BusinessManager.GetBusiness(businessid);
if(business == null)
{
player.SendChatMessage("~r~[FEHLER]~s~ Dieses Business existiert nicht. ~m~/businesslist");
return;
}
if(business.GetOwner() != null)
{
player.SendChatMessage("~r~[FEHLER]~s~ Das Business hat momentan noch einen Besitzer: ~o~" + business.GetOwner().Name + "~s~. Entferne diesen Besitzer erst mit ~m~/clearbusiness");
return;
}
using(var dbContext = new DatabaseContext())
{
Entities.User targetUser = target.GetUser(dbContext);
targetUser.BusinessId = businessid;
business.Update();
dbContext.SaveChanges();
}
}
#endregion
#region ALevel1338