Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<IsPackable>false</IsPackable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/SampSharp.Core/SampSharp.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Title>SampSharp Server Core</Title>
<Description>The core library of SampSharp which manages the communication with the SA-MP server.</Description>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
1 change: 1 addition & 0 deletions src/SampSharp.Entities/SAMP/Commands/CommandServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Reflection;
using SampSharp.Entities.SAMP.Commands.Parsers;
using SampSharp.Entities.Utilities;
using MethodInvoker = SampSharp.Entities.Utilities.MethodInvoker;

namespace SampSharp.Entities.SAMP.Commands;

Expand Down
15 changes: 13 additions & 2 deletions src/SampSharp.Entities/SAMP/Components/PlayerTextDraw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace SampSharp.Entities.SAMP;
/// <summary>Represents a component which provides the data and functionality of a per-player textdraw.</summary>
public class PlayerTextDraw : Component
{
private Vector2 _position;
private TextDrawAlignment _alignment = TextDrawAlignment.Left;
private Color _backColor = Color.Black;
private Color _boxColor = Color.Transparent;
Expand All @@ -36,7 +37,7 @@ public class PlayerTextDraw : Component
/// <summary>Constructs an instance of PlayerTextDraw, should be used internally.</summary>
protected PlayerTextDraw(Vector2 position, string text)
{
Position = position;
_position = position;
_text = text;
}

Expand Down Expand Up @@ -211,7 +212,17 @@ public virtual int PreviewModel
}

/// <summary>Gets the position of this textdraw.</summary>
public virtual Vector2 Position { get; }
public virtual Vector2 Position
{
get => _position;
set
{
_position = value;
GetComponent<NativePlayerTextDraw>()
.PlayerTextDrawSetPos(value.X, value.Y);
}
}



/// <summary>Sets the preview object rotation and zoom of this textdraw.</summary>
Expand Down
15 changes: 13 additions & 2 deletions src/SampSharp.Entities/SAMP/Components/TextDraw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace SampSharp.Entities.SAMP;
/// <summary>Represents a component which provides the data and functionality of a textdraw.</summary>
public class TextDraw : Component
{
private Vector2 _position = Vector2.Zero;
private TextDrawAlignment _alignment = TextDrawAlignment.Left;
private Color _backColor = Color.Black;
private Color _boxColor = Color.Transparent;
Expand All @@ -36,7 +37,7 @@ public class TextDraw : Component
/// <summary>Constructs an instance of TextDraw, should be used internally.</summary>
protected TextDraw(Vector2 position, string text)
{
Position = position;
_position = position;
_text = text;
}

Expand Down Expand Up @@ -211,7 +212,17 @@ public virtual int PreviewModel
}

/// <summary>Gets the position of this textdraw.</summary>
public virtual Vector2 Position { get; }
public virtual Vector2 Position
{
get => _position;
set
{
_position = value;
GetComponent<NativeTextDraw>()
.TextDrawSetPos(value.X, value.Y);
}

}

/// <summary>Sets the preview object rotation and zoom of this textdraw.</summary>
/// <param name="rotation">The rotation of the preview object.</param>
Expand Down
86 changes: 86 additions & 0 deletions src/SampSharp.Entities/SAMP/Components/Vehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,17 @@ public virtual bool IsBackRightWindowClosed
public virtual bool IsSirenOn => GetComponent<NativeVehicle>()
.GetVehicleParamsSirenState() == 1;

/// <summary>Gets and sets the value indicating this vehicle's siren is on. (Setting added open.mp v1.1.0.2612) </summary>
public virtual bool Siren
{
get => IsSirenOn;
set => GetComponent<NativeVehicle>()
.ToggleVehicleSirenEnabled(value);

}



/// <summary>Gets or sets the rotation of this vehicle.</summary>
/// <remarks>Only the Z angle can be set!</remarks>
public virtual Vector3 Rotation
Expand Down Expand Up @@ -396,6 +407,60 @@ public virtual Quaternion RotationQuaternion
}
}

/// <summary>
/// Sets and gets the respawn delay of the vehicle. (Added open.mp v1.1.0.2612)
/// </summary>
public virtual int RespawnDelay
{
get => GetComponent<NativeVehicle>()
.GetVehicleRespawnDelay();

set => GetComponent<NativeVehicle>()
.SetVehicleRespawnDelay(value);

}

/// <summary>
/// Gets the cab (towing vehicle) (Added open.mp v1.1.0.2612)
/// </summary>
public virtual EntityId GetVehicleCab
{
get
{
var id = GetComponent<NativeVehicle>()
.GetVehicleCab();

return id == 0 ? EntityId.Empty : SampEntities.GetVehicleId(id);
}
}

/// <summary>
/// Gets the hydra reactor (thruster) angle (Added open.mp v1.1.0.2612)
/// </summary>
public virtual int HydraReactorAngle
{
get => GetComponent<NativeVehicle>()
.GetVehicleHydraReactorAngle();
}

/// <summary>
/// Gets the state of the plane landing gears (Added open.mp v1.1.0.2612)
/// </summary>
public virtual LandingGearState LandingGearState
{
get => (LandingGearState)GetComponent<NativeVehicle>()
.GetVehicleLandingGearState();
}

/// <summary>
/// Gets the train speed for the vehicle (Added open.mp v1.1.0.2612)
/// </summary>
public virtual float TrainSpeed
{
get => GetComponent<NativeVehicle>()
.GetVehicleTrainSpeed();
}

/// <summary>
/// This function can be used to calculate the distance (as a float) between this vehicle and another map coordinate. This can be useful to detect how far
/// a vehicle away is from a location.
Expand Down Expand Up @@ -619,6 +684,11 @@ public virtual void SetWindowsParameters(bool driver, bool passenger, bool backL
public virtual void SetWindowsParameters(VehicleParameterValue driver, VehicleParameterValue passenger, VehicleParameterValue backLeft,
VehicleParameterValue backRight)
{
if (driver != VehicleParameterValue.Unset) driver = (VehicleParameterValue)(driver == VehicleParameterValue.On ? 0 : 1);
if (passenger != VehicleParameterValue.Unset) passenger = (VehicleParameterValue)(passenger == VehicleParameterValue.On ? 0 : 1);
if (backLeft != VehicleParameterValue.Unset) backLeft = (VehicleParameterValue)(backLeft == VehicleParameterValue.On ? 0 : 1);
if (backRight != VehicleParameterValue.Unset) backRight = (VehicleParameterValue)(backRight == VehicleParameterValue.On ? 0 : 1);

GetComponent<NativeVehicle>()
.SetVehicleParamsCarWindows((int)driver, (int)passenger, (int)backLeft, (int)backRight);
}
Expand All @@ -634,6 +704,12 @@ public virtual void GetWindowsParameters(out VehicleParameterValue driver, out V
GetComponent<NativeVehicle>()
.GetVehicleParamsCarWindows(out var tmpDriver, out var tmpPassenger, out var tmpBackLeft, out var tmpBackRight);

if (tmpDriver != -1) tmpDriver = (tmpDriver == 0 ? 1 : 0);
if (tmpPassenger != -1) tmpPassenger = (tmpPassenger == 0 ? 1 : 0);
if (tmpBackLeft != -1) tmpBackLeft = (tmpBackLeft == 0 ? 1 : 0);
if (tmpBackRight != -1) tmpBackRight = (tmpBackRight == 0 ? 1 : 0);


driver = (VehicleParameterValue)tmpDriver;
passenger = (VehicleParameterValue)tmpPassenger;
backLeft = (VehicleParameterValue)tmpBackLeft;
Expand Down Expand Up @@ -695,6 +771,16 @@ public virtual void ChangeColor(int color1, int color2)
.ChangeVehicleColor(color1, color2);
}

/// <summary>Get this vehicle's primary and secondary colors.</summary>
/// <param name="color1">The new vehicle's primary Color ID.</param>
/// <param name="color2">The new vehicle's secondary Color ID.</param>
public virtual void GetColor(out int color1, out int color2)
{
GetComponent<NativeVehicle>()
.GetVehicleColours(out color1, out color2);
}


/// <summary>Change this vehicle's paintjob (for plain colors see <see cref="ChangeColor" />).</summary>
/// <param name="paintjobId">The ID of the paintjob to apply. Use 3 to remove a paintjob.</param>
public virtual void ChangePaintjob(int paintjobId)
Expand Down
12 changes: 12 additions & 0 deletions src/SampSharp.Entities/SAMP/Definitions/LandingGearState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace SampSharp.Entities.SAMP
{
public enum LandingGearState
{
Down = 0,
Up = 1,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public virtual bool PlayerTextDrawDestroy()
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual void PlayerTextDrawSetPos(float x, float y)
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual bool PlayerTextDrawLetterSize(float x, float y)
{
Expand Down Expand Up @@ -147,4 +153,5 @@ public virtual bool PlayerTextDrawSetPreviewVehCol(int color1, int color2)
{
throw new NativeNotImplementedException();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public virtual bool TextDrawDestroy()
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual void TextDrawSetPos(float x, float y)
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual bool TextDrawLetterSize(float x, float y)
{
Expand Down
48 changes: 48 additions & 0 deletions src/SampSharp.Entities/SAMP/NativeComponents/NativeVehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,52 @@ public virtual int GetVehicleVirtualWorld()
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual int GetVehicleRespawnDelay()
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual int SetVehicleRespawnDelay(int delay)
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual int GetVehicleCab()
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual int GetVehicleColours(out int col1, out int col2)
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual int GetVehicleHydraReactorAngle()
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual int GetVehicleLandingGearState()
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual float GetVehicleTrainSpeed()
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual int ToggleVehicleSirenEnabled(bool toggle)
{
throw new NativeNotImplementedException();
}
}
2 changes: 1 addition & 1 deletion src/SampSharp.Entities/SampSharp.Entities.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Title>SampSharp Entities</Title>
<Description>An EntityComponentSystem framework for SampSharp.</Description>
</PropertyGroup>
Expand Down
7 changes: 7 additions & 0 deletions src/SampSharp.GameMode/Display/PlayerTextDraw.Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public virtual int CreatePlayerTextDraw(int playerid, float x, float y, string t
throw new NativeNotImplementedException();
}


[NativeMethod]
public virtual void PlayerTextDrawSetPos(int playerid, int text, float x, float y)
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual bool PlayerTextDrawDestroy(int playerid, int text)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SampSharp.GameMode/Display/PlayerTextDraw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public partial class PlayerTextDraw : IdentifiedOwnedPool<PlayerTextDraw, BasePl
public const int InvalidId = 0xFFFF;

/// <summary>Maximum number of player text draws which can exist.</summary>
public const int Max = 256;
public const int Max = 2048; //2048 adjusted for custom impl of omp server

/// <summary>
/// Occurs when the <see cref="BaseMode.OnPlayerClickPlayerTextDraw(BasePlayer,ClickPlayerTextDrawEventArgs)" /> is being called. This callback is called
Expand Down
6 changes: 6 additions & 0 deletions src/SampSharp.GameMode/Display/TextDraw.Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public virtual int TextDrawCreate(float x, float y, string text)
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual void TextDrawSetPos(int text, float x, float y)
{
throw new NativeNotImplementedException();
}

[NativeMethod]
public virtual bool TextDrawDestroy(int text)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SampSharp.GameMode/Display/TextDraw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class TextDraw : IdentifiedPool<TextDraw>
public const int InvalidId = 0xFFFF;

/// <summary>Maximum number of text draws which can exist.</summary>
public const int Max = 2048;
public const int Max = 256;

/// <summary>
/// Occurs when the <see cref="BaseMode.OnPlayerClickTextDraw(BasePlayer,ClickTextDrawEventArgs)" /> is being called. This callback is called when a
Expand Down
2 changes: 1 addition & 1 deletion src/SampSharp.GameMode/SampSharp.GameMode.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Title>SampSharp GameMode Framework</Title>
<Description>A framework for writing SA-MP game modes in C#.</Description>
</PropertyGroup>
Expand Down
Loading