SampSharp - Write gamemodes in .NET -
ikkentim - 06.05.2014
SampSharp is a plugin and library which allows you to write SA-MP gamemodes in C#, VB or any other .NET language. 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.
SampSharp provides wrappers for existing plugins (currently only the streamer plugin) and a number of resources for writing wrappers for existing plugins. There are also a small number of example gamemodes available.
Feedback and suggestions are highly appreciated!
If you have any questions, please leave a message below.
The following snippet shows how easy it is to create a command which spawns a vehicle:
PHP Code:
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 = BaseVehicle.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}!");
}
}
Download SampSharp
https://github.com/ikkentim/SampSharp/releases
Current stable version:
Current unstable version:
Documentation
https://sampsharp.net
Source code
https://www.github.com/ikkentim/SampSharp
Re: SampSharp - Write gamemodes in .NET -
NoahF - 06.05.2014
Nice!!! I am sure some people will find this very helpful.
Re: SampSharp - Write gamemodes in .NET -
Gigi-The-Beast - 06.05.2014
Nice effort, hope it doesn't get abbandoned as other similar projects.
I am not expirienced with c# but I want to learn it, so is there a way to use current plugins with this?
As I prefer to use mysql,streamer,sscanf plugins and some others?
Re: SampSharp - Write gamemodes in .NET -
ikkentim - 06.05.2014
Quote:
Originally Posted by Gigi-The-Beast
Nice effort, hope it doesn't get abbandoned as other similar projects.
|
I'll maintain it as long as possible
Quote:
Originally Posted by Gigi-The-Beast
I am not expirienced with c# but I want to learn it, so is there a way to use current plugins with this?
|
Not the way the plugin works now. However, you shouldn't need to.
Quote:
Originally Posted by Gigi-The-Beast
As I prefer to use mysql,streamer,sscanf plugins and some others?
|
Mysql: you can simply use the c# library from oracle, or, better yet, use entityframework. One great .net library, ****** it and you'll love it.
Streamer: i'm going to implement the most important features in the library.
Sscanf: if you are using it to process commands, sampsharp has something better, check the commandstest class in the testmode project. I'll soon document it and make it more awesome.
Re: SampSharp - Write gamemodes in .NET -
Gigi-The-Beast - 06.05.2014
Okay, thank you for your reply.
![Smiley](images/smilies/smile.png)
But would you be able to implement a way to allow using the current plugins too? As there are lots of other useful plugins there, like fcnpc, ysf, mapandreas and some others?
Re: SampSharp - Write gamemodes in .NET -
Scaleta - 06.05.2014
Seems pretty sweet. I can't wait to see some more documentation on this.
Does this have any effect on how fast things are processed?
Re: SampSharp - Write gamemodes in .NET -
ikkentim - 06.05.2014
Quote:
Originally Posted by Gigi-The-Beast
Okay, thank you for your reply. ![Smiley](images/smilies/smile.png)
But would you be able to implement a way to allow using the current plugins too? As there are lots of other useful plugins there, like fcnpc, ysf, mapandreas and some others?
|
I haven't yet found a way to call natives by name. SampSharp has build in support for mapandreas though.
Quote:
Originally Posted by Scaleta
Seems pretty sweet. I can't wait to see some more documentation on this.
Does this have any effect on how fast things are processed?
|
Havent yet tested it, but I'm quite sure pure pawn or pure sampgdk is faster.
The reason to use this plugin would be OO, .NET and all libraries written for .NET.
Re: SampSharp - Write gamemodes in .NET -
Kar - 07.05.2014
Really.. and I was just looking into C#...
Seems awesome, might test it.
Re: SampSharp - Write gamemodes in .NET -
123marvin123 - 07.05.2014
My Server won't start.
I pasted this into plugins folder:
http://puu.sh/8D0Z2.png
And Config looks like this:
http://puu.sh/8D112.png
But Server will only display this: [19:57:31] [SampSharp] Loading gamemode: RiverShell::GameMode at "plugins/RiverShell.dll". And then crashes. Can you help me?
Re: SampSharp - Write gamemodes in .NET -
iZN - 07.05.2014
Awesome work you've done. I might try to write some script on C# finally.
Re: SampSharp - Write gamemodes in .NET -
ikkentim - 07.05.2014
Quote:
Originally Posted by 123marvin123
My Server won't start.
I pasted this into plugins folder: http://puu.sh/8D0Z2.png
And Config looks like this: http://puu.sh/8D112.png
But Server will only display this: [19:57:31] [SampSharp] Loading gamemode: RiverShell::GameMode at "plugins/RiverShell.dll". And then crashes. Can you help me?
|
Have you copied the mono directory and mono-2.0.dll file into your server directory?
Re: SampSharp - Write gamemodes in .NET -
123marvin123 - 08.05.2014
Yes, I did.
Re: SampSharp - Write gamemodes in .NET -
ikkentim - 08.05.2014
Quote:
Originally Posted by 123marvin123
Yes, I did.
|
Could you use the code from this branch?
https://github.com/ikkentim/SampShar...debug-messages
It has some added debug messages during initialization.
If possible, could you run the project in debug mode from visual studio(assuming you are using visual studio)
Re: SampSharp - Write gamemodes in .NET -
123marvin123 - 08.05.2014
Ok, final output:
"[18:30:01] [SampSharp] Loading gamemode: RiverShell::GameMode at "plugins/RiverShell.dll".
[18:30:01] [SampSharp] Configuring mono paths...
[18:30:01] [SampSharp] Initializing mono runtime..."
Re: SampSharp - Write gamemodes in .NET -
ikkentim - 08.05.2014
Quote:
Originally Posted by 123marvin123
Ok, final output:
"[18:30:01] [SampSharp] Loading gamemode: RiverShell::GameMode at "plugins/RiverShell.dll".
[18:30:01] [SampSharp] Configuring mono paths...
[18:30:01] [SampSharp] Initializing mono runtime..."
|
Could you try running it from the command prompt, to see if it poops out any error messages afterwards that arent written to the server log ?
Re: SampSharp - Write gamemodes in .NET -
123marvin123 - 08.05.2014
Wow, i there really is a error msg:"
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `C:\Users\Marvin\Desktop\Sachen\stock samp
srv/mono/lib/\mono\4.5\mscorlib.dll' directory.
"
Re: SampSharp - Write gamemodes in .NET -
ikkentim - 08.05.2014
Quote:
Originally Posted by 123marvin123
Wow, i there really is a error msg:"
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `C:\Users\Marvin\Desktop\Sachen\stock samp
srv/mono/lib/\mono\4.5\mscorlib.dll' directory.
"
|
I see... For some reason the dlls in the mono directory are being ignored by git... Let me fix that, ill edit this post when i fixed it.
Edit: Pushed it to the master branch, can you try pulling/downloading it and trying again?
Re: SampSharp - Write gamemodes in .NET -
123marvin123 - 08.05.2014
Ok, the server started now
![Smiley](images/smilies/smile.png)
Thanks
I will use your API to create some examples, and then give you my opinion.
Re: SampSharp - Write gamemodes in .NET -
Niko_boy - 09.05.2014
Very nice. I wanted to do samp scripts in C# always. Thanks alot would give it a shoot soon.
Re: SampSharp - Write gamemodes in .NET -
Hwang - 17.05.2014
You should add some images, such stands is very simple.