SampAccess 1.0.3

dotnet add package SampAccess --version 1.0.3
                    
NuGet\Install-Package SampAccess -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SampAccess" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SampAccess" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="SampAccess" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SampAccess --version 1.0.3
                    
#r "nuget: SampAccess, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SampAccess@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SampAccess&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=SampAccess&version=1.0.3
                    
Install as a Cake Tool

SampAccess Library

This .NET library may simplify your access to SA:MP servers (gathering information about them) and to SA:MP client settings

  • NuGet

Warning

This library was written long ago, and it won't be maintained anymore.

Requirements

Notes

  • I wrote this library as an analogue under the MIT license, since those that I found in the Internet were either proprietary or under the GPL license, which is not always suitable.

  • Client class IS NOT CROSS-PLATFORM. It requires Microsoft.Win32.Registry package, which is working only in Windows.

  • The Query algorithm is based on https://github.com/zeelorenc/SA-MP-Server-Query-Class, but code is rewritten

Query example

SampAccess API is pretty easy and straightforward. Here is an example:

using System;
using SampAccess;

namespace Test
{
    class Program
    {
        public static void Main(string[] args)
        {
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

            using Query query = new(/* IP */ args[1], /* Port */ Convert.ToUInt16(args[2]));
            query.Initialize();

            // Basic information about a server
            Console.WriteLine($"Ping {query.PingInMilliseconds} ms\n");
            Console.WriteLine("Common information:\n" +
                $"Players: {query.CommonInformation.PlayersOnline}/{query.CommonInformation.LimitOfPlayers}\n" +
                $"Has password: {query.CommonInformation.HasPassword}\n" +
                $"Host name: {query.CommonInformation.HostName}\n" +
                $"Game mode: {query.CommonInformation.GameMode}\n" +
                $"Language: {query.CommonInformation.Language}\n");

            // Server rules
            Console.WriteLine("Server rules:");
            foreach(KeyValuePair<string, string> rule in query.ServerRules)
            {
                Console.WriteLine($"Key: {rule.Key}; Value: {rule.Value}");
            }
            Console.WriteLine();

            // Player information
            Console.WriteLine("Players:");
            foreach (Query.Player player in query.PlayersInformation)
            {
                Console.WriteLine($"Player nick: {player.Nick}\n" +
                    $"Ping: {player.Ping}\n" +
                    $"Score: {player.Score}");

                if(player.PlayerID != null)
                {
                    Console.WriteLine($"Player ID: {player.PlayerID}");
                }

                Console.WriteLine();
            }
        }
    }
}

Client example

Client is even more simple, than Query class:

using System;
using SampAccess;

namespace Test
{
    class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine($"Your nickname: {Client.PlayerName}");
            Console.WriteLine($"Game executable path: {Client.GameExecutable}");
            Console.WriteLine("Checkboxes:\n" +
                $"Save RCON passwords: {Client.SaveRconPasswords}\n" +
                $"Save server passwords: {Client.SaveServerPasswords}");

            Console.WriteLine();

            Console.Write("Your new nickname: ");
            Client.PlayerName = Console.ReadLine();

            Console.Write("Your new game executable: ");
            Client.GameExecutable = Console.ReadLine();

            Console.Write("Do you want to save RCON passwords: ");
            Client.SaveRconPasswords = Convert.ToInt32(Console.ReadLine());

            Console.Write("Do you want to save server passwords: ");
            Client.SaveServerPasswords = Convert.ToInt32(Console.ReadLine());
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 190 8/20/2024
1.0.2 194 8/18/2024
1.0.1-stable 443 6/22/2021