FiveGame SA:MP GameMod, Tutoriale

Alăturați-vă forumului, este rapid și ușor

FiveGame SA:MP GameMod, Tutoriale
FiveGame SA:MP GameMod, Tutoriale
Doriți să reacționați la acest mesaj? Creați un cont în câteva clickuri sau conectați-vă pentru a continua.

FiveGame SA:MP Daca aveti orice fel de intrebari nu ezitati sa ne contactati. O zi buna, Echipa
Forumul FiveGame este in cautare de persoane capabile pentru a modera forumul și pentru a ajuta utilizatorii la nevoie.
Salut, vreau sa va anunț ca în
Ultimele subiecte

In jos
InceMan
InceMan
Administrator
Administrator
Mesaje : 527
Data de inscriere : 02/10/2015
Varsta: : 31
Localizare: : Neamt
https://fivegame.all-up.com

SampSharp - Write game modes in .NET Empty SampSharp - Write game modes in .NET

9/10/2020, 06:03
[Trebuie sa fiti inscris si conectat pentru a vedea acest link]
[Trebuie sa fiti inscris si conectat pentru a vedea acest link]
SampSharp is a plugin and library which allows you to write SA-MP game modes in C#. The plugin works both on Linux and Windows. The library contains various classes for every type of resource available in SA-MP (players, vehicles, textdraws, etc). Aside from this wrapper around native functions, the library also contains a good structure to build your gamemode on. This plugin was initially released in 2014, and has received a good ever since and I'm still available for any questions related to this plugin.

SampSharp provides two structures for developing game modes. SampSharp.GameMode and SampSharp.Entities.

SampSharp.GameMode provides a simple object-oriented structure for developing your game mode. All callbacks are forwarded to the implementation of BaseMode and vanilla callbacks are forwarded as events to the related instances (eg. OnPlayerText fires the PlayerText event on the related Player instance). A simple code sample can be found below.


[ltr]public class GameMode : BaseMode
{
protected override void OnPlayerConnected(BasePlayer player, EventArgs e)
{
base.OnPlayerConnected(player, e);

player.SendClientMessage($"Welcome {player.Name}, to a whole new world!");
}

[Command("spawn")]
public static void VehicleCommand(BasePlayer player, VehicleModelType model)
{
Console.WriteLine($"Spawning a {model} for {player.Name}");
var vehicle = GtaVehicle.Create(model, player.Position + new Vector3(0, 0, 0.5f), player.Rotation.Z);
player.PutInVehicle(vehicle);
player.SendClientMessage(Color.GreenYellow, $"You have spawned a {model}!");
}
} [/ltr]


SampSharp.Entities (only available since early 2020) provides an Entity-Component-System structure with full dependency injection support for developing your game mode. SampSharp.Entities is still in active development but is already stable and usable. Below, a similar code sample can be found:

[ltr]public class SampleSystem : ISystem
{
[Event]
public void OnPlayerConnected(Player player)
{
player.SendClientMessage($"Welcome {player.Name}, to a whole new world!");
}

[PlayerCommand("spawn")]
public static void VehicleCommand(Player player, VehicleModelType model, IWorldService worldService)
{
Console.WriteLine($"Spawning a {model} for {player.Name}");
var vehicle = worldService.CreateVehicle(model, player.Position + new Vector3(0, 0, 0.5f), player.Rotation.Z, -1, -1);
player.PutInVehicle(vehicle);
player.SendClientMessage(Color.GreenYellow, $"You have spawned a {model}!");
}
} [/ltr]


Download
[Trebuie sa fiti inscris si conectat pentru a vedea acest link]
Documentation

Our documentation website is still in development and some vital documentation is still lacking. If you need any assistance, feel free to join our Discord server!

[Trebuie sa fiti inscris si conectat pentru a vedea acest link]
Sus
Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum