Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
131 lines (111 sloc) 4.47 KB


This guide will get you started building and running your first SampSharp game mode on Windows in development mode. For running your server in production mode see Running in Production.


You'll need to download the following tools in order to start developing SampSharp game modes:

Installing the SampSharp Plugin

Download the latest SampSharp package (SampSharp-*.zip) from the SampSharp releases page on GitHub and copy the contents of the folder to your SA-MP server directory. Open the server.cfg file with your favourite text editor and replace the contents with the following config. Don't forget to change the rcon_password to some other memorable value.

echo Executing Server Config...
lanmode 0
rcon_password changeme
maxplayers 50
port 7777
hostname My First SampSharp Server
gamemode0 empty 1
announce 0
chatlogging 0
onfoot_rate 40
incar_rate 40
weapon_rate 40
stream_distance 300.0
stream_rate 1000
maxnpc 0
logtimeformat [%H:%M:%S]
language English
plugins SampSharp

You should now be able to start your samp-server.exe. The end of the server output should look as follows:

[SampSharp:INFO] Creating pipe \\.\pipe\SampSharp...
[SampSharp:INFO] Pipe created.

Adding the Nuget repository

SampSharp currently hosts its packages in its NuGet repository. You'll need to add this repository to Visual Studio in order to be able to install the SampSharp NuGet packages.

  • Firstly, open Visual Studio
  • If you're seeing the welcoming screen, select "Continue without code".
  • Next, from the top menu open Tools -> Options....
  • Select NuGet Package Manager -> Package Sources in the left-hand side menu
  • Click on the +-symbol in the top-right corner to add a new repository
  • Enter SampSharp as the name of the repository
  • Enter as the source of the repository and click on OK
  • You'll now be able to install SampSharp NuGet packages into your project.

Creating a Game Mode Project

Using the SampSharp Templates for Visual Studio it should be a piece of cake to create your first SampSharp game mode.

  • Open Visual Studio
  • If you're seeing the welcoming screen, select "Create a new project", otherwise select File -> New -> Project...
  • Search for the "SampSharpGameMode" template and hit Next
  • Give your project a nice name like "MyFirstGameMode" and click on Create
  • You should now be able to hit Run and start your game mode

Starting and Stopping your Game Mode

While developing your game mode you can keep the game connected to the server while you start and stop your game mode to make changes to it. Simply keep the samp-server process running while you hit stop and start in Visual Studio.

SampSharp "attaches" your game mode to the samp-server by rotating to the next game mode in the SA-MP server using the "gmx" RCON-command. This might take a few moments after you started your game mode. SampSharp has implemented a "fake gmx" (which doesn't actually rotates to the next game mode) in order to speed this process up, tough it might have some unexpected side effects when calling SA-MP functions which only work when the game mode is initializing.

In order to activate "fake gmx" edit the code in your Program class. By default it should look as follows:

public static void Main(string[] args)
	new GameModeBuilder()

By specifying FakeGmx as the default start behaviour you can enable "fake gmx":

public static void Main(string[] args)
	new GameModeBuilder()
You can’t perform that action at this time.