Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
clrcore: update using to static CitizenFX.Core.Native.API
  • Loading branch information
carmineos committed May 22, 2019
1 parent e860e6c commit a832a9e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions code/client/clrcore/Server/ServerWrappers.cs
Expand Up @@ -2,7 +2,8 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using CitizenFX.Core.Native;

using static CitizenFX.Core.Native.API;

namespace CitizenFX.Core
{
Expand All @@ -22,19 +23,19 @@ internal Player(string sourceString)
m_handle = sourceString;
}

public string Name => API.GetPlayerName(m_handle);
public string Name => GetPlayerName(m_handle);

public int Ping => API.GetPlayerPing(m_handle);
public int Ping => GetPlayerPing(m_handle);

public int LastMsg => API.GetPlayerLastMsg(m_handle);
public int LastMsg => GetPlayerLastMsg(m_handle);

public IdentifierCollection Identifiers => new IdentifierCollection(this);

public string EndPoint => API.GetPlayerEndpoint(m_handle);
public string EndPoint => GetPlayerEndpoint(m_handle);

public Ped Character => Ped.FromPlayerHandle(m_handle);

public void Drop(string reason) => API.DropPlayer(m_handle, reason);
public void Drop(string reason) => DropPlayer(m_handle, reason);

public void TriggerEvent(string eventName, params object[] args)
{
Expand All @@ -44,7 +45,7 @@ public void TriggerEvent(string eventName, params object[] args)
{
fixed (byte* serialized = &argsSerialized[0])
{
API.TriggerClientEventInternal(eventName, m_handle, serialized, argsSerialized.Length);
TriggerClientEventInternal(eventName, m_handle, serialized, argsSerialized.Length);
}
}
}
Expand Down Expand Up @@ -91,11 +92,11 @@ internal IdentifierCollection(Player player)

public IEnumerator<string> GetEnumerator()
{
int numIndices = API.GetNumPlayerIdentifiers(m_player.Handle);
int numIndices = GetNumPlayerIdentifiers(m_player.Handle);

for (var i = 0; i < numIndices; i++)
{
yield return API.GetPlayerIdentifier(m_player.Handle, i);
yield return GetPlayerIdentifier(m_player.Handle, i);
}
}

Expand All @@ -119,11 +120,11 @@ public class PlayerList : IEnumerable<Player>
{
public IEnumerator<Player> GetEnumerator()
{
int numIndices = API.GetNumPlayerIndices();
int numIndices = GetNumPlayerIndices();

for (var i = 0; i < numIndices; i++)
{
yield return new Player(API.GetPlayerFromIndex(i));
yield return new Player(GetPlayerFromIndex(i));
}
}

Expand Down

0 comments on commit a832a9e

Please sign in to comment.