These are chat archives for ikkentim/SampSharp

9th
Jun 2016
BryanHitchcock
@BryanHitchcock
Jun 09 2016 00:40
I think I'm having more issues with streamer. Whenever I do a GMX after spawning anything with streamer, the server crashes and doesn't restart. No error appears or anything, it just closes.
BryanHitchcock
@BryanHitchcock
Jun 09 2016 01:02
I'm also getting this mono error, it only happens when I load 6+ tables from my MySQL server using NHibernate and FluentNHibernate. If I comment 2 of them out (doesn't matter which two), the error goes away: https://i.gyazo.com/494d7259029fb6277a819a592d05baa7.png
BryanHitchcock
@BryanHitchcock
Jun 09 2016 04:24
Do you have any idea why NHibernate forces me to save new entries in a seperate session where I update my current entries? I'm using HasMany and reference, and it's pretty inefficient imo to have to do that. Took me like 4 hours to figured this out too, broke my entire gamemode ahah
House table has a Owner variable that points to an account's Id
BryanHitchcock
@BryanHitchcock
Jun 09 2016 04:45
This message was deleted
Tim Potze
@ikkentim
Jun 09 2016 09:58
I don’t see why anything should be in a separate session, then again, I haven’t been using NHibernate too much yet since I’ve been more busy with the sampsharp framework than my actual game mode. Maybe @fvandillen knows? Anyhow the exception there is a little weird, I’ll do some googling
Ah I see it’s trying to compile a generated serializer
Do you use NHibernate’s XML mapping or fluentNHibernate?
Florian van Dillen
@fvandillen
Jun 09 2016 10:00
Hey tim
Tim Potze
@ikkentim
Jun 09 2016 10:00
:wave:
Florian van Dillen
@fvandillen
Jun 09 2016 10:01
Other unrelated question first: in regular pawn scripts, does the streamer run in a seperate process?
Tim Potze
@ikkentim
Jun 09 2016 10:01
nope
Florian van Dillen
@fvandillen
Jun 09 2016 10:01
As in: would dynamic area detection be more efficient/cause less lag than checking distances between points/players in a loop?
Tim Potze
@ikkentim
Jun 09 2016 10:02
on yea well anything done in c++ is done faster than pawn
Florian van Dillen
@fvandillen
Jun 09 2016 10:02
Thx
Also, as for the question by @BryanHitchcock
Tim Potze
@ikkentim
Jun 09 2016 10:02
streamer uses some top notch libraries for calculating these things
Florian van Dillen
@fvandillen
Jun 09 2016 10:02
My experience is that any related objects are updated/saved along with the main object you are trying to save.
In my gamemode, I have an Account-class that contains the persistent information of my players. On Disconnect it will call player.SaveAccount() if the player is logged in.
In that method, I open a session+transaction which does database.Update(Account);
Account contains stuff like public virtual Container Inventory { get; set; } which is also referenced in my mapping.
It updates that as well AFAIK.
Same goes for interacting with my group system which is basically a network of List objects
try
                    {
                        using (var tx = database.BeginTransaction())
                        {
                            database.Save(newGroup);
                            database.Save(newRank);
                            database.Save(newDefaultRank);
                            database.Save(newFounder);
                            tx.Commit();
                        }
                    }
                    catch (HibernateException ex)
                    {
                        Log.Error(ex.Message + "\n" + ex.StackTrace);
                    }
Florian van Dillen
@fvandillen
Jun 09 2016 10:08
Example of inviting a group member (basically adds an account to the OpenInvitations-List of that group (referenced in the mapping):
                                                               using (var tx = database.BeginTransaction())
                                                                {
                                                                    database.Update(group);
                                                                    database.Save(invitation);
                                                                    tx.Commit();
                                                                }
Have not had issues with it thus far
BryanHitchcock
@BryanHitchcock
Jun 09 2016 13:46
hm, I'll try it your way. I've been doing this:
Is that using statement inside a foreach/for loop or..?
BryanHitchcock
@BryanHitchcock
Jun 09 2016 13:52
or something like this?
@ikkentim I've been using FluentNHibernate's mapping, I haven't done anything with XML
Florian van Dillen
@fvandillen
Jun 09 2016 14:26
I have a static database class with only one session factory
BryanHitchcock
@BryanHitchcock
Jun 09 2016 14:27
with all of your sessions for the different tables?
Florian van Dillen
@fvandillen
Jun 09 2016 14:27
Yes
BryanHitchcock
@BryanHitchcock
Jun 09 2016 14:27
Mind sharing it with me? I've only really used EF before and I'm a bit lost =/
Florian van Dillen
@fvandillen
Jun 09 2016 14:28
Sure mate, let me hop on my laptop
BryanHitchcock
@BryanHitchcock
Jun 09 2016 14:28
Thank you!!
I really appreciate it
BryanHitchcock
@BryanHitchcock
Jun 09 2016 15:30
@fvandillen Don't want to bother you, just making sure you didn't forget :smile: . Thanks again!