These are chat archives for ikkentim/SampSharp

10th
May 2016
Florian van Dillen
@fvandillen
May 10 2016 11:15

Hey Tim, I'm trying to do the following:

I have a function where I create a group. One of the arguments of that function is the account object of the founder. Every player has an account field that is populated once they join via NHibernate. When creating the group, I want to check if the founder is currently online (in that case the group needs to be added to his GroupList IList).

The following code indicates it cannot find the account property:

if (Player.All.Any(f => f.account == founder))
            {

            }

Any ideas?

The error indicates it is trying to find the account property in Sampsharp.GtaPlayer, while I defined it in my own player class.
fixed it :D
Tim Potze
@ikkentim
May 10 2016 11:18
The All property is of type IENumerable<GtaPlayer>. If I’m not mistaken, I’ve added a GetAll<T>()
nice
Florian van Dillen
@fvandillen
May 10 2016 11:19
if (Player.GetAll<Player>().Any(f => f.Account == founder))
That indeed did the trick
Tim Potze
@ikkentim
May 10 2016 11:19
@Seprum Just create a wrapper method, so replace the return Native.CallNative … with a call to the delegate
Florian van Dillen
@fvandillen
May 10 2016 11:19
Linq is a blessing, by the way :D
Tim Potze
@ikkentim
May 10 2016 11:20
Yea
protip: add public static new IEnumerable<Player> All => GetAll<Player>(); to your Player class
Florian van Dillen
@fvandillen
May 10 2016 11:22
Your protip doesn't seem to work, makes the account property invisible again.
Tim Potze
@ikkentim
May 10 2016 11:23
:O
It should work.. Hmm. Hard to write code without a compiler
Florian van Dillen
@fvandillen
May 10 2016 11:23
My editor says error, however the build works..
Tim Potze
@ikkentim
May 10 2016 11:23
=> is c# 7
what editor you’re using?
Florian van Dillen
@fvandillen
May 10 2016 11:23
Xamarin on OSX
It's nice but the intellisense can be buggy at times
Tim Potze
@ikkentim
May 10 2016 11:24
Yea xamarin studio is a bummer
I don’t like it
try project rider: D
i love that thing
Florian van Dillen
@fvandillen
May 10 2016 11:24
Will verify that it works when back home on visual studio
That tool works on OSX?
Tim Potze
@ikkentim
May 10 2016 11:24
Yea
Florian van Dillen
@fvandillen
May 10 2016 11:24
Oh nice, let me try :)
Tim Potze
@ikkentim
May 10 2016 11:24
its from jetbrains
you probably need to apply first though
its in development
Florian van Dillen
@fvandillen
May 10 2016 11:25
I have a jetbrains license so I might be able to get it from the members section
Tim Potze
@ikkentim
May 10 2016 11:25
in furure it is possible not free either, but the eap is free
oh nice
btw, i’ve ported sa and samp with wineskin
Florian van Dillen
@fvandillen
May 10 2016 11:25
Which is?
Tim Potze
@ikkentim
May 10 2016 11:26
and run an ubuntu server x64 in virtualbox
Florian van Dillen
@fvandillen
May 10 2016 11:26
(I run GTA SA:MP on OSX with Wine)
This message was deleted
Tim Potze
@ikkentim
May 10 2016 11:26
wine is an ass sometimes and personally i dont want it running and getting mess trough my files
with wineskin, you can install windows software into an .app
so I now have a GTA San Andreas.app
which starts SA-MP
And my server runs on a linux box
So I can work on sampsharp on my mac now :D (only need time -.- )
Florian van Dillen
@fvandillen
May 10 2016 11:27
Oh nice
I did manage to compile pawncc on OSX so I can support the older (pawn based) version of the script from my school machine.
Tim Potze
@ikkentim
May 10 2016 11:28
Compiled zeex’ version?
Florian van Dillen
@fvandillen
May 10 2016 11:29
Ye
Tim Potze
@ikkentim
May 10 2016 11:29
:)
Florian van Dillen
@fvandillen
May 10 2016 11:29
Linked it up with Atom (and atom-build) to call the compiler.
Tim Potze
@ikkentim
May 10 2016 11:30
Yea atom has some good build script options, and luckily some people have written autocomplete and build scripts for it
Florian van Dillen
@fvandillen
May 10 2016 11:30
Yeah, even pawn syntax highlighting
Tim Potze
@ikkentim
May 10 2016 11:30
Back when I was working with pawn i also used atom.
Florian van Dillen
@fvandillen
May 10 2016 11:30
And my co-developers made some snippets/autocompletion as well.
Tim Potze
@ikkentim
May 10 2016 11:31
I need like 6 months off so i can work on all this stuff.. Ugh.. We’ll im getting back to my work
Florian van Dillen
@fvandillen
May 10 2016 11:33
Lol, sounds good
I hope to have a more mature C# mode by then
One more question
Once I have the Player.GetAll thing, I don't seem to be able to actually access the object instance of the player.
Player.GetAll<Player>().Select(f => f.Account == founder);
Any () is a bool, and Select just returns a new collection.
Tim Potze
@ikkentim
May 10 2016 11:34
What are you trying to get?
the online Player of founder?
Florian van Dillen
@fvandillen
May 10 2016 11:35
I am trying to get a reference to a player with that account, yes
Tim Potze
@ikkentim
May 10 2016 11:35
Player.GetAll<Player>().Where(f => f.Account == founder).FirstOrDefault();
Florian van Dillen
@fvandillen
May 10 2016 11:36
Done, ty
Is there a way to prevent me doing the same thing twice?
I'm doing a linq query in the if-statement and another one to actually get the reference to the online player.
if (Player.GetAll<Player>().Any(f => f.Account == founder))
            {
                // Player is online, now add the group to the player.
                var player = Player.GetAll<Player>().Where(f => f.Account == founder).FirstOrDefault();
                player.Groups.Add(newGroup);
            }
Tim Potze
@ikkentim
May 10 2016 11:38
var player == …; if(player != null) ?
variables, man!
just move the player variable to above the if
Florian van Dillen
@fvandillen
May 10 2016 11:39
Lol, I should get some extra sleep and three cups of coffee
Tim Potze
@ikkentim
May 10 2016 11:39
var player = Player.GetAll<Player>().Where(f => f.Account == founder).FirstOrDefault();
if (player != null)
            {
                // Player is online, now add the group to the player.
                player.Groups.Add(newGroup);
            }
Dang it, i give up on formatting
Florian van Dillen
@fvandillen
May 10 2016 11:41
Well that brings me one step closer to the perfect group system
Group creation code so far for those that are interested:
Tim Potze
@ikkentim
May 10 2016 11:43
I want to get back to SampSharp :cry:
I’m busy with my final 5 weeks of my hbo study...
Florian van Dillen
@fvandillen
May 10 2016 11:44
I am right in the middle of it
Information Security Management
Tim Potze
@ikkentim
May 10 2016 11:45
im doing software engineering
Florian van Dillen
@fvandillen
May 10 2016 11:46
What a surprise xD
Tim Potze
@ikkentim
May 10 2016 11:46
Yea right
If I’d said something healthcare related, that would have been a shocker
Florian van Dillen
@fvandillen
May 10 2016 11:46
Yup lol
Once my gamemode gets to a more complete stage i'll let you in the repo, if you're interested :)
Gotta run now, bus almost here
Cya