09.12.2011, 02:56
(
Последний раз редактировалось Iain.Gilbert; 16.12.2011 в 01:05.
)
For the last couple of weeks, in my spare time; i have been working on a Dotnet Script API plugin.
It allows you to write samp scripts in any dotnet language (c#/VB.net/C++CLI).
All interop is done via TCP.
Works in both Windows & Linux (using mono).
Full source code is provided (albeit with a somewhat restrictive license at the moment).
Here's a simple example script:
Install:
Put DotnetServer.dll & DotnetServer.ini in your "\samp\plugins\" directory.
Put DotnetFS.amx in your "\samp\filterscripts\" directory.
Add "plugins DotnetServer" to your server.cfg.
Add "filterscripts DotnetFS" to your server.cfg.
Put DotnetClient.exe & DotnetClient.xml anywhere you want.
Put scripts in "\yourdotnetclientdir\Scripts\". It will auto load any files ending in ".cs/.vb/.dll" from that directory.
Config:
Open DotnetServer.ini & modify Port & AuthKey as desired.
note: Make sure you do change AuthKey to something private, as it is the password required to login to the DotnetServer.
note: If you are not running DotnetClient from a remote location then i recommend you firewall off all outside access to the DotnetServer port.
Open DotnetClient.xml & modify Port & AuthKey to match what you put in DotnetServer.ini & modify Address as desired.
Known Bugs / Missing features:
* No encryption.
* No brute force protection.
* No unicode support.
* Can't return values from native callbacks.
Downloads & source @ http://code.******.com/p/samp-dotnet-script-api/
For a great tutorial, which details intallation & usage; see this thread: https://sampforum.blast.hk/showthread.php?tid=302838 by TopAz
It allows you to write samp scripts in any dotnet language (c#/VB.net/C++CLI).
All interop is done via TCP.
Works in both Windows & Linux (using mono).
Full source code is provided (albeit with a somewhat restrictive license at the moment).
Here's a simple example script:
Код:
/* * PlayerCommandExample * * Player uses '/car' command; a vehicle is spawned & player is put in it */ using System; using Samp.Scripts; using Samp.API; namespace Samp.Scripts.ExampleScripts { public class PlayerCommandExample : ScriptBase { public override void OnLoad() // called when script is loaded { Samp.API.Player.OnPlayerCommandText += OnPlayerCommandText; // subscribe to OnPlayerCommandText event } public override void OnUnload() // called when script is unloaded { Samp.API.Player.OnPlayerCommandText -= OnPlayerCommandText; } public void OnPlayerCommandText(object sender, Player.OnPlayerCommandTextEventArgs args) { string[] cmd = args.text.Split(' '); if (String.Compare(cmd[0], "/car") == 0) { SpawnPlayerCar(args.player); } } public void SpawnPlayerCar(Player pl) { int model = 415; //cheetah Vehicle v = World.CreateVehicle(model, pl.Pos, pl.ZAngle, 0, 0, 600); // spawn the vehicle pl.Vehicle = v; // put player in the vehicle pl.ClientMessage(0, "{00FF00}Spawning vehicle."); // send the player a message } } }
Install:
Put DotnetServer.dll & DotnetServer.ini in your "\samp\plugins\" directory.
Put DotnetFS.amx in your "\samp\filterscripts\" directory.
Add "plugins DotnetServer" to your server.cfg.
Add "filterscripts DotnetFS" to your server.cfg.
Put DotnetClient.exe & DotnetClient.xml anywhere you want.
Put scripts in "\yourdotnetclientdir\Scripts\". It will auto load any files ending in ".cs/.vb/.dll" from that directory.
Config:
Open DotnetServer.ini & modify Port & AuthKey as desired.
note: Make sure you do change AuthKey to something private, as it is the password required to login to the DotnetServer.
note: If you are not running DotnetClient from a remote location then i recommend you firewall off all outside access to the DotnetServer port.
Open DotnetClient.xml & modify Port & AuthKey to match what you put in DotnetServer.ini & modify Address as desired.
Known Bugs / Missing features:
* No encryption.
* No brute force protection.
* No unicode support.
* Can't return values from native callbacks.
Downloads & source @ http://code.******.com/p/samp-dotnet-script-api/
For a great tutorial, which details intallation & usage; see this thread: https://sampforum.blast.hk/showthread.php?tid=302838 by TopAz