Changed whole project structure (split client and server into separat projects)

This commit is contained in:
hydrant
2019-02-25 22:12:05 +01:00
parent d2181c4987
commit 33abb3d04f
185 changed files with 282 additions and 596 deletions

View File

@@ -0,0 +1,44 @@
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 reallife_gamemode.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;
}
}
}