These are chat archives for ikkentim/SampSharp

14th
May 2016
Tim Potze
@ikkentim
May 14 2016 11:14
Working on some better native wrapping :D This is awesome
This message was deleted
    public class NativeObject
    {
        [NativeProperty]
        public virtual float Gravity { get; set; }

        [NativeMethod]
        public virtual int SetGameModeText(string text)
        {
            throw new NativeNotImplementedException();
        }

        [NativeMethod]
        public virtual int SendRconCommand(string cmd)
        {
            throw new NativeNotImplementedException();
        }
    }

    public class Test
    {
        public void DoWork()
        {
            var inst = NativeObjWrap.Work<NativeObject>();
            inst.SetGameModeText("wrapped");
            inst.SendRconCommand("mapname somemap");

            Console.WriteLine($"Current gravity = {inst.Gravity}");

            inst.Gravity = 0.004f;
        }
    }
Works like a charm
    [NativeObject("Id")]
    public class NativePlayer
    {
        public int Id {get;set;}

        [NativeProperty]
        public virtual string Name { get; set; }
    }
and this works too! :D
Xalphox
@Xalphox
May 14 2016 13:23
That definitely is awesome! How do you actually bind the properties? Does it assume there's a SetName and a GetName?
Xalphox
@Xalphox
May 14 2016 13:30
Also - a request, or perhaps you have a better idea - could you make it so that you can override the actual Native engine? Use case being that you can (easily) write a mock callout engine so that you can totally unit test your gamemodes
I tried making a GtaPlayer facade where it'd present a GtaPlayer if it wasn't in testing mode but would return a MockGtaPlayer where it was, but it turned out too unwieldy
:)
Xalphox
@Xalphox
May 14 2016 14:04

Thought I'd compile a list of things I've added/changed in my gamemode framework - specifically the ones that augment/fill in what I felt were gaps in Samp#.

Not sure if you want any of these Tim? (the ones with * are ones I've already scripted):

Vector3:

Exceptions:

  • Statically store the player that it affects somewhere, or automatically pass it as part of the exception. *

Command Parameter Types:

  • Improve the text type attribute so that it can work with sentences embedded in quotes (ie. in other games, the command cmd "abc 123" 456 would read "abc 123" as arg 1, and 456 as arg 2. *

Textdraws:

  • Store whether or not a text/playertext is visible. *
  • Fix alignment: TD's that are aligned centrally 1. use Y rather than X for their X position and 2. it's set to X + width/2 rather than X. There are occasionally times where it's useful, but my answer would be just to set a size on it! *
  • Letter widths and heights, and calculating the size of a textdraw based on its content (the characters inside of it), proportional or otherwise. *

GtaPlayer:

  • Variable to store location of SetCameraLookAt and InterpolateCameraLookAt *
  • Ability to save and restore states - particularly useful when using SpectatePlayer *
  • Variable to store whether a player is selecting a textdraw. *
  • A GetAttachedObject(int index) method and/or class. *
  • Weapon property that binds to SetArmedWeapon *
  • Weapons dictionary that returns the result of GetWeaponData, or sets the player weapons when set. *
  • HasWeapon method *
  • RemoveWeapon method *
  • WeaponChanged event *
  • Helper methods for: IsPlayerInWater, IsAiming, or the camera distance to a point *
  • Static events for construction and disposal *

GtaVehicle:

  • Static events for construction and disposal *
  • Variable to store Color1, Color2 and whether the vehicle has a siren/alarm. *
  • List of objects/DynamicObjects where they are attached to said vehicle. *

GtaObject/DynamicObject:

  • Static events for construction and disposal *
  • Store vehicle, offset and rotation when using AttachTo *
Tim Potze
@ikkentim
May 14 2016 15:59
Somehow my gitter app doesn't give notifications... I'll write a response after dinner
Tim Potze
@ikkentim
May 14 2016 16:45
@Xalphox are you running the version on master? With this, yo ucan already override the native laoder
Edit: Whoops there are some small issues with that still. Will try to fix taht
That gif looks AWESOME by the way,
hope you'll opensource the forms system :D
Tim Potze
@ikkentim
May 14 2016 16:50
Feel free to create a pull request wit hyour changes, if possible in separate PRs with similar changes (eg. bundle the Color stuff, attach stuff, animation helper method, etc)
When it all works (which it doesn't yet current) you can set Native.NativeLoader to your custom INativeLoader implementation to mock natives
Florian van Dillen
@fvandillen
May 14 2016 16:52
Imagine what we guys could do when making a server together :D
Tim Potze
@ikkentim
May 14 2016 16:52
:P
Tim Potze
@ikkentim
May 14 2016 17:05
@Xalphox about how that native wrapper works, I compile Proxy classes at runtime which implement the virtual properties/methods with NativeProperty/NativeMethod attributes
Florian van Dillen
@fvandillen
May 14 2016 21:57
@Xalphox The textdraws and functioning looks EPIC. How do you design them?
Tim Potze
@ikkentim
May 14 2016 22:24
Ugh… tried to install sampsharp on my ubuntu vbox… Can’t compile the plugin… unsupported arhitecture according to sampgdk
@fvandillen are you running the server on osx? and how?
Florian van Dillen
@fvandillen
May 14 2016 22:32
Nope, I am running the server off a Windows 2012 VPS
I continuously upload my .dll's to it and reload.
Tim Potze
@ikkentim
May 14 2016 22:33
I got it working on a ubuntu 32 bit linux vps but I don’t get it running on my virtual box
Florian van Dillen
@fvandillen
May 14 2016 22:33
I am in the process of setting up my Surface Pro 3 to become my dedicated dev environment
Oh, and unrelated: the cash register in the shop I work at had a blue screen today :-1:
Damn windows :smile:
Tim Potze
@ikkentim
May 14 2016 22:34
Hahah
Florian van Dillen
@fvandillen
May 14 2016 22:56
Whoops, is this you or is this me?
Attempting to gather dependency information for package 'SampSharp.Streamer.0.6.2' with respect to project 'RockStars6', targeting '.NETFramework,Version=v4.5'
Package 'SampSharp.Streamer,0.6.2.0' is not found in the following primary source(s): 'http://nuget.timpotze.nl/api/v2/'. Please verify all your online package sources are available (OR) package id, version are specified correctly.
========== Finished ==========