Added /remove command for vehicles and goto points
This commit is contained in:
@@ -571,7 +571,7 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
}
|
}
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
Entities.GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == location);
|
GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == location);
|
||||||
|
|
||||||
if(p == null)
|
if(p == null)
|
||||||
{
|
{
|
||||||
@@ -1344,6 +1344,71 @@ namespace reallife_gamemode.Server.Commands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command("remove", "~m~Benutzung: ~s~/remove [Vehicle, Goto] [Option]")]
|
||||||
|
public void CmdAdminRemove(Client player, string type, string option = "")
|
||||||
|
{
|
||||||
|
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(type.ToLower())
|
||||||
|
{
|
||||||
|
case "vehicle":
|
||||||
|
if(!player.IsInVehicle)
|
||||||
|
{
|
||||||
|
player.SendChatMessage("~m~Du sitzt in keinem Fahrzeug!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerVehicle veh = player.Vehicle.GetServerVehicle();
|
||||||
|
if(veh == null)
|
||||||
|
{
|
||||||
|
player.SendChatMessage("~r~[FEHLER]~s~ Dieses Fahrzeug wird nicht von einem Server-System genutzt.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(option.ToLower() != "yes")
|
||||||
|
{
|
||||||
|
player.SendChatMessage("Bist du sicher, dass du folgendes Fahrzeug löschen willst: ~m~" + veh.ToString() + " ~s~?");
|
||||||
|
player.SendChatMessage("Falls ~g~Ja~s~, nutze ~y~/remove vehicle yes");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
VehicleManager.DeleteVehicle(player.Vehicle);
|
||||||
|
dbContext.ServerVehicles.Remove(veh);
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "goto":
|
||||||
|
if(option == "")
|
||||||
|
{
|
||||||
|
player.SendChatMessage("~m~Benutzung: ~s~/remove [Goto] [Punkt]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using (var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == option);
|
||||||
|
if(p == null)
|
||||||
|
{
|
||||||
|
player.SendChatMessage("~r~[FEHLER]~s~ Dieser Goto-Punkt existiert nicht.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbContext.GotoPoints.Remove(p);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
player.SendNotification("Der Goto-Punkt ~r~" + p.Description + "~s~ wurde erfolgreich gelöscht.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region loadCommand
|
#region loadCommand
|
||||||
[Command("load", "~m~Benutzung: ~s~/load [Typ = OnlineBunkers, ArcadiusBusinessCentre, MazeBankBuilding, LomBank, MazeBankWest, ClubWareHouse, SpecialLocations, GRHYacht, DHYacht, PYacht, AircraftCarrier, BridgeTC, BridgeTN, NorthYankton, ONeilsFarmB, ONeilsFarm, Morgue")]
|
[Command("load", "~m~Benutzung: ~s~/load [Typ = OnlineBunkers, ArcadiusBusinessCentre, MazeBankBuilding, LomBank, MazeBankWest, ClubWareHouse, SpecialLocations, GRHYacht, DHYacht, PYacht, AircraftCarrier, BridgeTC, BridgeTN, NorthYankton, ONeilsFarmB, ONeilsFarm, Morgue")]
|
||||||
public void CmdAdminloadlocation(Client player, string typ)
|
public void CmdAdminloadlocation(Client player, string typ)
|
||||||
|
|||||||
@@ -30,5 +30,10 @@ namespace reallife_gamemode.Server.Entities
|
|||||||
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
|
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return "Fraktions Fahrzeug | Fraktion: " + GetFaction().Name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
|
using reallife_gamemode.Model;
|
||||||
using reallife_gamemode.Server.Util;
|
using reallife_gamemode.Server.Util;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,5 +22,25 @@ namespace reallife_gamemode.Server.Entities
|
|||||||
[ForeignKey("User")]
|
[ForeignKey("User")]
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
public User User { 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.BusinessId == Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return dbContext.Users.FirstOrDefault(u => u.BusinessId == Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,10 @@ using reallife_gamemode.Server.Entities;
|
|||||||
namespace reallife_gamemode.Server.Saves
|
namespace reallife_gamemode.Server.Saves
|
||||||
{
|
{
|
||||||
public class SavedVehicle : ServerVehicle
|
public class SavedVehicle : ServerVehicle
|
||||||
{ }
|
{
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return "Gespeichertes Fahrzeug";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user