Umstrukturierung
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Database;
|
||||
using ReallifeGamemode.Database.Entities;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Job;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
using GTANetworkAPI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Client Service (ClientService.cs)
|
||||
* @author hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace ReallifeGamemode.Server.Services
|
||||
{
|
||||
class ClientService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt einen Client anhand seines Namens oder der ID zurück
|
||||
/// </summary>
|
||||
/// <param name="nameOrId">Die ID oder der Name, nach dem gesucht werden soll</param>
|
||||
/// <returns></returns>
|
||||
public static Client GetClientByNameOrId(string nameOrId)
|
||||
{
|
||||
Client toReturn = null;
|
||||
nameOrId = nameOrId.ToLower();
|
||||
|
||||
List<Client> playerList = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
if (int.TryParse(nameOrId, out int id))
|
||||
{
|
||||
toReturn = playerList.Find(p => p.Handle.Value == id);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
toReturn = playerList.Find(p => p.Name.ToLower() == nameOrId);
|
||||
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = playerList.Find(p => p.Name.ToLower().StartsWith(nameOrId));
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user