Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - EK.IceFlake

#1
Community Plugins / .NET Core plugin for VCMP
Aug 27, 2018, 02:06 PM
Intro
I've been wanting .NET support in VCMP since over two years now. Now that I have the skills to actually attempt something like this myself... well, I decided why not take a go at it. So put simply this is a collection composed of
  • a VCMP plugin that serves as a CoreCLR host;
  • a .NET interoperability library that basically serves as a VCMP .NET plugin SDK; and
  • hopefully, a wrapper that abstracts the SDK away and provides an experience that feels similar to using other .NET libraries, with OOP paradigms and stock .NET interfaces.

Repository
The main repository of this project can be found on GitLab. You can use this repository for
  • getting its source code;
  • getting pre-built versions of this project;
  • documentation about this project; and
  • reporting bugs and getting support about this project.

dotnet-vcmp repository

Additional support
You can get quick support about this plugin at Developers.cpp. However, if you want more complex or advanced support, you should create an issue on GitLab. This is so that I help not only you but any potential future users of this project as well.

Developers.cpp

Builds
Since I use Linux as my OS, it's not particularly easy for me to support Windows as well. All pre-built binaries you see here are tested on Linux 64 bit. The C# interoperability DLL will very likely work on Windows 64 bit as well. Do not try to use them on a 32 bit architecture - they will not work! I've made the source code platform-agnostic, so you can compile a 32 bit version yourself if you need to.

Note that you should add Fleka.DotnetVcmp.Interop as a Nuget dependency instead of using the DLL directly.


Compiling
The VCMP plugin uses the Meson build system. You need to have Meson installed in order to compile it. If you're on Windows, I recommend that you use Meson to generate a Visual Studio solution and compile it using Visual Studio.

Use dotnet build or dotnet publish to build a managed assembly.

Getting Meson
Meson compilation guide

Setting up a hello world application
  • Installing .NET Core
    .NET Core supports Windows and lots of Linux distributions. Since I can't comprehensively cover all of them here, you can find instructions at Microsoft's official website.
  • Creating a project
    Enter the directory where you want to create your project and execute one of the following commands depending on the language you want to use:
    • C#: dotnet new classlib --language C#
    • F#: dotnet new classlib --language F#
    • VB.Net: dotnet new classlib --language VB
  • Adding the interoperability project as a dependency
    If you open your .csproj file, you should find a root Project tag. You shouldn't have an ItemGroup tag inside it by default, so you should add it manually. If that tag already exists, you don't need to add it. Create a new tag inside ItemGroup with the following content:
    <PackageReference Include="Fleka.DotnetVcmp.Interop" Version="1.1.0" />
  • Creating your class
    You should find a .cs file in your project directory. Replace its contents with the specified test app class.
  • Compiling
    Execute dotnet publish in your project directory.
  • Setting up the server
    After placing the plugin in plugins/ and adding it to server.cfg, create a file called dotnet.json with the specified content. You might need to change clr.runtime-directory to point to your runtime's directory. If you're on Linux, you can execute locate libcoreclr.so to locate it. You can now create a directory called dotnet-assemblies/.
  • Installing your script
    To install your script, copy all DLL files from build/debug/netstandard2.0/publish/ to dotnet-assemblies/. Note that if you update your script, you'll have to execute dotnet publish and copy the generated DLLs again.

.NET core installation instructions
Hello world test app class
dotnet.json example configuration

Windows
If you have an adequate Windows software development installation (with Visual Studio, Meson and .NET Core) and you don't need lots of help with this, you can contact me to volunteer to test and compile this plugin on Windows.

Side note
I don't recommend using this right now for developing scripts. It just exposes VCMP's raw API with no error checking at all, and you can easily run into segmentation faults, crashes or silent failures and you won't even be able to figure out why. You should really only be using this with a wrapper. I'll hopefully release an official wrapper soon, and you can also create unofficial wrappers if you like.
#2
I'm trying to create a C# plugin. I have a PlugunFunctions struct but unfortunately a few functions in it don't work.

If, for example, I execute
pluginFuncs.LogMessage("%s", "Hello World");
it prints Hello World.
If I execute
error = pluginFuncs.GetLastError();
Console.WriteLine(error);
it prints None.

However, if I execute, for example
pluginFuncs.SetMaxPlayers(54);
it causes a segmentation fault somewhere (gdb can't figure it out. it just shows the address of the location)
and if I execute
StringBuilder serverNameBuilder = new StringBuilder(129);
            VcmpError error = pluginFuncs.GetServerName(serverNameBuilder, (UIntPtr) 128);
            Console.WriteLine("Error code: " + error.ToString());
            Console.WriteLine("Server name: " + serverNameBuilder.ToString());
it causes a segmentation fault at strcpy.

Here's the relevant code: https://gist.github.com/iFlake/d0bd57a293d92790480535483de84e74

Any idea? I'm summoning @Stormeus since they're working on VC.Net.

Thanks.
#3
Client Scripting / Cursor system
Jul 19, 2018, 02:38 PM
Here's a cursor system you can use to manage your cursors

Cursor <- {
    "Obtain": function () {
        ++this.Cursors;
        this.Refresh();
    },
    "Release": function () {
        --this.Cursors;
        this.Refresh();
    },

    "ObtainSmart": function (wref) {
        this.Obtain();

        local routine;
        routine = ::Routine(function () {
            if (wref.ref() == null) {
                this.Release();
                routine.Destroy();
            }
        }, 0, 0, this);
    },

    "Refresh": function () {
        ::GUI.SetMouseEnabled(this.Cursors > 0)
    }

    "Cursors": 0
}

You can use Cursor.Obtain() to obtain a cursor and Cursor.Release() to release a cursor. When the total cursor count is 0 the cursor automatically gets destroyed.



Ok that's normal and boring stuff. What's cool is Cursor.ObtainSmart(). Let's say you have a widget class has some elements in it. You construct that class when you want to create that widget and delete all references to it when you want to destroy it. Now squirrel doesn't support a class destructor. This means that you can't release your cursor! But this cursor system will still help you. If you obtain a smart cursor using:
Cursor.ObtainSmart(this.weakref());the cursor will automatically be released once all references to your class have been removed.



Dependencies:



[spoiler=MIT]Copyright © 2018  Fleka

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.[/spoiler]
#4
This is the VCMP SDK in yaml format made so that you can parse it easily in order to generate bindings to it.

https://pastebin.com/Z350QSYp

Some names might be changed, but the order remains the same so they should still work.

-- Update: Removed redundant const ... notation.
-- Update: Made return types easier to parse.
-- Update: Standardize enumerator formats.
-- Update: Make constant-size lists easier to parse.
-- Update: Make dynamic-size lists easier to parse.
-- Update: Made strings easier to parse. Fixed length of string in struct PluginInfo.
-- Update: Made format strings easier to parse. Made PluginFuncs and PluginCalls separate from Structs.
#5
Description
The server tries to load custom vehicles before they're downloaded.

Reproducible
Always

What were you doing when the bug happened
Trying to join a server. I had /showdebug enabled.

What do you think caused the bug
Vehicles were only streamed after spawning before the latest server update, so there wasn't any check to see if a particular vehicle was downloaded before creating it. The devs overlooked this when releasing the new update.
#6
General Discussion / Temporary new masterlist
Jun 29, 2018, 10:03 AM
The official masterlist is currently bugged. You can use an alternative masterlist (master.vc-mp.cf).

Instructions here: https://www.vc-mp.cf/threads/alternative-masterlist.7/

Please note that only servers that announce to this masterlist are visible.
#7
Bugs and Crashes / [CRASH] 0x00661548
Jun 27, 2018, 02:56 PM
rel006 breaks compatibility with WINE on Linux. VCMP works fine on rel003 and rel004. Not tested with rel005.

---

Reproducible: Always
What you were doing at the time of the crash: Spawning
What do you think caused the crash: The new version of libpng maybe
Are you using the steam version: Nope
Crash report: https://pastebin.com/eXGXukGU
#8
Off-Topic General / Happy world Pi day
Mar 14, 2018, 04:35 PM
Merry 3/14!
#9
Since VCMP's domain is expiring on January 28, I've decided to set up an alternative forum and (open source) masterlist. You can find both of them here: https://www.vc-mp.cf/
:edit: Okay, the devs have renewed it. You can still use it though.
#10
Videos & Screenshots / VCMP in Linux Mint
Nov 23, 2017, 06:07 PM
Took some slight work in order to get started, but here it is.

#11
Videos & Screenshots / Minecraft in VCMP
Sep 03, 2017, 11:52 AM
Credits: Xmair





#12
I'm writing a very extensive client-side library for VCMP and am wondering which license to use.
Here are my options:

CLNS
I use this license a lot for my projects. However, the problem is that it is written by me and I am not a lawyer.
Here is the text:
[spoiler=CLNS]CLNS
You may use and redistribute this license, however, changing it is not allowed.

This software comes with NO WARRANTIES, read section 2.

PREAMBLE:
      This is a copyleft license--
      While most software licenses are designed to take away your freedom, this license, on the contrary, will preserve your freedom, even when redistributed.
      To preserve its and your freedom, any user or contributor to this software must retain the freedoms of this license.
      The freedoms provided by this license are:
            Every user is permitted to use or modify this software in any way
            Every user is permitted to override any technical limitations, including overriding activation features
            Every user is permitted to decompile or disassemble this software
            Every contributor is permitted to commercialize this software
            Every contributor is permitted to apply technical limitations to this software
      Please read this agreement carefully

TERMS AND CONDITIONS:
1>    Definitions:
       1>   "Technical limitation" means preventing an action without legal intervention.
       2>   "User" means any person using the front-end.
       3>   "Contributor" means any person using the source code or developing directly on the binaries.
       4>   "You" means any user or contributor.
       5>   "Deriative" means any work based on this software.
       6>   "This software" means any work distributed under this license.
       6>   "You" means the licensee of this software.
       7>   "Including" implies 'but not limited to'.
       8>   All definitions are case-insensitive.
       9>   All definitions are plurality-insensitive.
2>    No liablity:
       1>   This software is provided without any warranties, implied or otherwise.
       2>   The authors of this software are not liable for any losses or lost profits that occur by the use of this product, directly or otherwise.
       3>   You agree to indemnify the authors of this software free from any liabilities you cause.
3>    Application:
       1>   This license applies to any user or contributor of this software.
       2>   This license grants you explicit permission to use, modify and/or redistribute this software.
       2>   This license may be revoked by removing all copies and traces of the software.
4>    Scope:
       1>   This license applies to the source code, its binaries and any deriatives.
       2>   Additional license terms may apply.
       3>   Additional license terms may not conflict with this license.
       4>   This license will not apply and you will not be allowed to use this software if any law forces you to override it in any way.
5>    Freedoms
       1>   You are permitted to modify this software, by source if available, binary or otherwise.
       2>   You are permitted to override any technical limitations in this software, including activation/commercialization features.
       3>   You are permitted to commercialize this software.
       4>   You are permitted to apply technical limitations to this software and they will not carry any legal protection.
6>    Human rights
       1>   This software may not be used to or to support human trafficking.
       2>   This software may not be used to discriminate or to support discrimination on the basis of age, sex, racial origin, nationality, religion, sexuality or relationship.
7>    Legal measures
       1>   You are not permitted to use any legal measures, including patents or trademarks, to override this license.[/spoiler]

AGPL v3
This license is a very strong copyleft and if you are using this library, you will be forced to release your source code to whoever joins your server.

CC0 1.0
This is the most permissive license because it dedicates your work into the public domain with a fallback license if your law does not recognize the public domain.

I'd probably go for CC0 1.0, but I want to hear your thoughts on it.
#13
I've managed to successfully reimplement Vietnam sliding in VCMP.
Sit back and enjoy:
https://www.youtube.com/watch?v=lx8CgfarhXk#
#14
Since VCMP developers removed a very useful feature called the 'Vietnam Slide', I decided to reimplement it.
https://pastebin.com/nXhSx2Xn
Add this to scripts/slide.nut and add this line to sqmod.ini:
Execute=scripts/slide.nut

You can edit the constants at the top to fine-tune the slide.

It's initiated the same way it was before the latest bug which broke the native slide but it has an extra plus point that the slider can see themselves sliding.
#15
Servers / Elite Killerz: Estate City
Jul 09, 2017, 12:39 PM


Host: 213.32.8.56:8192
Script: ITX v1.0 by @EK.IceFlake and @Anik
IRC Channel: #estatecity@LUnet
Forum: https://estatecity.elitekillerz.net/

Features:
  • Custom scoreboard: Includes statistics of online players. You can access it by pressing ` or ~.
  • Duel system: Lets you duel with your opponent in a specific arena.
  • Clan system: Gives the ability to manage your clan.
  • In-game user control panel: You can transfer, merge and view your stats using the UCP which you can access with /ucp.
  • Weapon stats: You can check your weapon-specific statistics with /wstats.

Videos:
https://www.youtube.com/watch?v=b4l_uVpa71I
https://www.youtube.com/watch?v=DCHpRLBhfpI
#16
I get this:
[ERR] Squirrel exception caught (OnPlayerGameKeysChange) event
[INF] Message:

even with an empty callback on PlayerGameKeys.
#17
I was reimplementing slide but a problem occurred. The iscrouching parameter is always false.

SqCore.On().PlayerCrouching.Connect(function (player, iscrouching)
{
    print(iscrouching);
});

[USR] false

Luckily I can use player.Crouched for now.
#18
Would be nice if we could enable slide again
#19
Servers / Estate city public beta release
Jun 30, 2017, 12:09 PM
Hello, folks!

This is the server you never even knew anything about. I'll present it anyways.

Join it on 213.32.8.56:8192. The password is esserver.
#20
I have an event:
            player.On.Spawn.ConnectOnce(function ()
            {
                /*if (authenciated == true) return;
                else authenciated = true;*/ // << currently using this workaround

                player.LoggingIn    = true;
                player.Health       = 0;

                player.On.RequestClass.ConnectOnce(function (classid)
                {
                    player.World        = CWorlds.Default;
                    player.LoggingIn    = false;

                    player.Login();

                    player.StartStream();
                    player.StreamInt(CPacketsOutgoing.AuthenciateResult);
                    player.StreamByte(CEncodedBoolean.True);
                    player.FlushStream(true);
                });
            });
It gets called whenever I spawn despite the fact that it says ConnectOnce. I've verified that that event is getting connected only once.