Files
reallife-gamemode/ReallifeGamemode.Server.Core.RageMP/RagePlayer.cs
hydrant 1871a97122 fix
2020-03-29 17:36:58 +02:00

86 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using ReallifeGamemode.Server.Core.API;
using ReallifeGamemode.Server.Types;
namespace ReallifeGamemode.Server.Core.RageMP
{
public class RagePlayer : RageEntity, IPlayer
{
private readonly GTANetworkAPI.Player client;
public string Name
{
get => client?.Name;
set
{
if (client != null)
{
client.Name = value;
}
}
}
public string SocialClubName => client?.SocialClubName;
public IPAddress RemoteAddress => IPAddress.Parse(client?.Address);
public IVehicle Vehicle => client != null ? (client.IsInVehicle ? new RageVehicle(client?.Vehicle) : null) : null;
public VehicleSeat VehicleSeat => (VehicleSeat)client?.VehicleSeat;
public bool IsInVehicle => Vehicle != null;
public int Health { get => client?.Health ?? 0; set { if (client != null) client.Health = value; } }
public int Armor { get => client?.Armor ?? 0; set { if (client != null) client.Armor = value; } }
public RagePlayer(GTANetworkAPI.Player client) : base(client)
{
this.client = client;
}
public void SendRawMessage(string message)
{
client?.SendChatMessage(message);
}
public void TriggerEventRaw(string eventName, params object[] args)
{
client?.TriggerEvent(eventName, args);
}
public void SetIntoVehicle(IVehicle vehicle, VehicleSeat seat)
{
client?.SetIntoVehicle(new GTANetworkAPI.NetHandle((ushort)vehicle.Handle, GTANetworkAPI.EntityType.Vehicle), (int)seat - 1);
}
public void Kick() => client?.Kick();
public void SendNotification(string message, bool flashing = true)
{
client.SendNotification(message, flashing);
}
public void Spawn(Position position, float heading = 0)
{
Health = 100;
Armor = 0;
Position = position;
Heading = heading;
}
public void PlayAnimation(string dict, string name, AnimationFlags flags, float speed = 8.0f)
{
GTANetworkAPI.NAPI.Player.PlayPlayerAnimation(client, (int)flags, dict, name, speed);
}
public void CancelAnimation()
{
client?.StopAnimation();
}
}
}