citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.52k stars 2.07k forks source link

feat(clrcore): add implicit conversion from int to CString in Player #2822

Open geofmigliacci opened 1 week ago

geofmigliacci commented 1 week ago

Goal of this PR

This PR adds an implicit conversion from int to CString in the Player class as a quality of life (QoL) improvement on the server side. This allows for direct conversion without the need to explicitly call Handle.ToString().

See : https://github.com/thorium-cfx/mono_v2_get_started/issues/37

It might be interesting to add this implicit conversion to other entities as well.

How is this PR achieving the goal

This PR adds an implicit operator CString(Player player). With this change, you can now do the following:

Player p1 = new Player(1);
Natives.ThisCoolNative(p1, "hello", 1234); // ThisCoolNative(CString, CString, int)

This PR applies to the following area(s)

Server, ScRT: C#

Successfully tested on

Game builds: Latest

Platforms: Windows

Checklist

Fixes issues

resolves https://github.com/thorium-cfx/mono_v2_get_started/issues/37