These are chat archives for ikkentim/SampSharp

21st
Feb 2017
Tim Potze
@ikkentim
Feb 21 2017 12:56
What's the Unity package?
If I had to guess I say this is @fvandillen
oh I see, it's IoC
Oleg
@5LICK
Feb 21 2017 13:12
what is it? :smile:
its mine)
Oleg
@5LICK
Feb 21 2017 13:20
oh, this is package repository requests
Tim Potze
@ikkentim
Feb 21 2017 13:20
yep
Oleg
@5LICK
Feb 21 2017 13:21
this is my zombie gamemode:)
about zombie
Florian van Dillen
@fvandillen
Feb 21 2017 13:25
Doesn't look like my gamemode :P
I use log4net and fluent nhibernate
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:29
@fvandillen Any tutorials on nhibernate? I may wanna dip my toes into it.
Florian van Dillen
@fvandillen
Feb 21 2017 13:30
@ikkentim Found out most stuff from your example with nhibernate and a lot of googling
Especially on building the session factory, and choosing if I want it to execute schema updates or not
Right now, it automatically updates all the table structures when the server starts up
Most essential to my gamemode is getting the cascade options and lazy loading settings right
I eagerly load my group system for example, because it has way better performance to run it from memory
Aka. loads more data at server startup, but doesn't fetch data when looking up group members and ranks
Those queries slow down the commands if it has to fetch it every time
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:35
Yeah I got that like my .json system, .json is loaded on start-up and fetched at run-time using JObject references, and saved periodically during run-time, and saved at shut-down.
Florian van Dillen
@fvandillen
Feb 21 2017 13:35
Yeah, and cascading controls if it will fetch all the related data hierarchically
Most of the group system is set to cascade everything
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:37
I feared, if there's 1,000,000 accounts loaded into memory it may slow performance of the look-up loop, so I tested by creating 1,000,000 JObject with obscene amounts of data... sure it was a bit hard on RAM but as far as fetching the reference for a certain account name, nope, really fast... I love C# and Newtonsoft :D
I can have every account loaded into memory, that's just amazing to me.
Florian van Dillen
@fvandillen
Feb 21 2017 13:38
Yup, and the group system for an average roleplay server will not have more than 500 groups anyway
The memory usage so far has been very acceptable and fast
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:39
Exactly, I tested account system because that will be the biggest
Florian van Dillen
@fvandillen
Feb 21 2017 13:39
I simply favour the performance from RAM over the efficiency
I don't load all accounts tho
Those are queried when needed
But indeed, could be loaded at runtime too
public void LoadAccount()
        {
            Log.Info("Loading account data for " + this.Name + "(" + this.Id + ").");

            using (ISession database = db.OpenSession())
            {
                var Account = database.QueryOver<Account>().Where(x => x.Username == Name).SingleOrDefault<Account>();
                if (Account != null)
                {
                    Registered = true;
                    this.Account = Account;
                }

            }
        }
this function is in my Player-class
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:41
RAM is faster than SSD, so I feel if you don't care about how much you put into RAM, you should load everything on start-up to fetch information faster :P Cause a sa-mp server doesn't consume any RAM at all, like 500mb of ram with 1000 players.
Florian van Dillen
@fvandillen
Feb 21 2017 13:41
SampSharp is very RAM efficient too
Doesn't use a lot of ram
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:42
Exactly you can make calls to the garbage collection system when the server isn't doing anything intensive.
Florian van Dillen
@fvandillen
Feb 21 2017 13:42
44MB with my gamemode loaded
Can I?
Tim Potze
@ikkentim
Feb 21 2017 13:42
GC.Collect(), but you better don't
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:43
:) If you had a DM mode that switched between maps
You can call it during the transition phase.
Without any problem.
Florian van Dillen
@fvandillen
Feb 21 2017 13:43
Oh, I could attempt to call it during night hours when the server has a low playercount
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:43
Exactly
When the server isn't needed to perform intense tasks.
Tim Potze
@ikkentim
Feb 21 2017 13:44
sgen is smart enough to find moments of nearly nothing to do and use it for collecting, it collects when your memory usage is getting high etc etc
Florian van Dillen
@fvandillen
Feb 21 2017 13:44
Most of the time it wouldn't need to do anything intensive
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:46
C# .NET is truly amazing, full control over everything, I'mma control freak when it comes to controlling my PC and my Host haha.
Florian van Dillen
@fvandillen
Feb 21 2017 13:46
Well I absolutely love the way C# is suitable for SAMP
Collections, lists, NuGet packages
Especially when the Lists are combined with NHibernate as ORM
And Linq lol, which is the most insane query mechanism ever
I made the following group system:
Group
  • Members
  • Ranks
    -- Permissions
    -- Special permissions
  • Invitations
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:49
You sent us a photo of it earlier in the year
Florian van Dillen
@fvandillen
Feb 21 2017 13:49
Then I can do this:
/// <summary>
        /// Determines whether this player is a member of the specified group.
        /// </summary>
        /// <param name="group">Group.</param>
        /// <returns><c>true</c> if this player is a member of the group; otherwise, <c>false</c>.</returns>
        public bool IsGroupMember(Group group)
        {
            return Groups.GetAll().Any(g => g.Id == group.Id && g.Members.Any(m => m.Account.DatabaseID == Account.DatabaseID));
        }

        /// <summary>
        /// Gets the groups this player is a member of.
        /// </summary>
        /// <returns>A list of groups.</returns>
        public IList<Group> GetGroups()
        {
            return Groups.GetAll().Where(g => g.Members.Any(m => m.Account.DatabaseID == Account.DatabaseID)).ToList();
        }

        /// <summary>
        /// Gets the rank a player holds in a certain group.
        /// </summary>
        /// <param name="group">Group.</param>
        /// <returns>The name of the rank if the player is a member; otherwise, <c>null</c>.</returns>
        public string GetGroupRank(Group group)
        {
            return IsGroupMember(@group) ? @group.Members.Where(m => m.Account.DatabaseID == Account.DatabaseID).Select(m => m.Rank.Name.ToString()).FirstOrDefault() : null;
        }

        /// <summary>
        /// Determines whether this player has the specified permission in the specified group.
        /// </summary>
        /// <returns><c>true</c> if this player has the permission in the group; otherwise, <c>false</c>.</returns>
        /// <param name="permission">Permission.</param>
        /// <param name="group">Group.</param>
        public bool HasPermission(Groups.Permission permission, Group group)
        {
            return Groups.GetAll().Where(g => g == @group && g.Members.Any(member => member.Account.DatabaseID == Account.DatabaseID)).Any(g => g.Members.Any(member => member.Rank.Permissions.Any(p => p.Permission == permission)));
        }

        /// <summary>
        /// Determines whether this player has the specified special permission in the specified group.
        /// </summary>
        /// <returns><c>true</c> if this player has the special permission in the group; otherwise, <c>false</c>.</returns>
        /// <param name="permission">Special permission.</param>
        /// <param name="group">Group.</param>
        public bool HasPermission(Groups.SpecialPermission permission, Group group)
        {
            return Groups.GetAll().Where(g => g == @group && g.Members.Any(member => member.Account.DatabaseID == Account.DatabaseID)).Any(g => g.Members.Any(member => member.Rank.SpecialPermissions.Any(p => p.SpecialPermission == permission)));
        }
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:53
What kind of server were you making :D
Florian van Dillen
@fvandillen
Feb 21 2017 13:58
Roleplay / RPG
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:58
It open for the testing? :P
Florian van Dillen
@fvandillen
Feb 21 2017 13:58
I am a former developer for ArgonathRPG, but the community sucks a lot because the owner stopped caring
Got spring break next week, planning to release a beta on a 24/7 server then
Michael Kilpatrick
@NewbProgramming
Feb 21 2017 13:59
Sweet send me beta link :D
Florian van Dillen
@fvandillen
Feb 21 2017 13:59
Will do
Florian van Dillen
@fvandillen
Feb 21 2017 20:28
Yo @ikkentim , i'm using a character system and after login, character selection takes place. I am trying to change the player's name according to their currently active character.
player.Name = player.CurrentCharacter.Name; Doesn't change the player name ingame
Any suggestions on how to call the function?
This is the SA:MP function equivalent of what I want: http://wiki.sa-mp.com/wiki/SetPlayerName
Tim Potze
@ikkentim
Feb 21 2017 20:36
Afaik im setting That When you set .Name . I'm not handling return values though
Florian van Dillen
@fvandillen
Feb 21 2017 20:45
Name doesn't really change IG
Function doesn't cause any error either
[NativeMethod]
            public virtual int SetPlayerName(int playerid, string name)
            {
                throw new NativeNotImplementedException();
            }