These are chat archives for ikkentim/SampSharp

20th
Feb 2017
Michael Kilpatrick
@NewbProgramming
Feb 20 2017 04:23
If I have two classes that inherit BaseMode, will all the overriden functions be called for both?
Florian van Dillen
@fvandillen
Feb 20 2017 09:31
What would be the best way to define a custom color in addition to the already defined colors in S#?
Tim Potze
@ikkentim
Feb 20 2017 09:35
create a Colors class add some definitions in there?
@NewbProgramming depends of what inherrits what, and if all call base
Michael Kilpatrick
@NewbProgramming
Feb 20 2017 09:36
GameMode : BaseMode
MissionManager : BaseMode
Like that.
and yeah all call base.<name>
Tim Potze
@ikkentim
Feb 20 2017 09:37
Nope not working, it only calls the GameMode
Michael Kilpatrick
@NewbProgramming
Feb 20 2017 09:37
Alright thanks.
I will continue to use Controllers
haha
Tim Potze
@ikkentim
Feb 20 2017 09:37
Was just about to say
Florian van Dillen
@fvandillen
Feb 20 2017 09:38
Also @ikkentim , I have some init code in my gamemode class
But I want it to be called before the OnInit event is fired
Michael Kilpatrick
@NewbProgramming
Feb 20 2017 09:38
What I can do, make a interface, use reflection to call methods from classes that inherit the interface.
Tim Potze
@ikkentim
Feb 20 2017 09:39
@fvandillen override OnInitialize(...) { /CODE/ base.OnInitialize(...) }
Florian van Dillen
@fvandillen
Feb 20 2017 09:39
ohh before base.
thx :)
Florian van Dillen
@fvandillen
Feb 20 2017 13:00
Tim, whenever you are available, have a question about nhibernate
Tim Potze
@ikkentim
Feb 20 2017 13:01
fire away
Florian van Dillen
@fvandillen
Feb 20 2017 13:01
By default, I usually make related stuff to .Not.LazyLoad()
Tim Potze
@ikkentim
Feb 20 2017 13:01
(not that im a nhibernate expert buy we'll see!)
Florian van Dillen
@fvandillen
Feb 20 2017 13:02
Example:
public class GroupMapping : ClassMap<trinity.Models.Group>
        {
            public GroupMapping()
            {
                Table("Groups");
                Id(x => x.GroupID);
                Map(x => x.Name);
                Map(x => x.DisplayName);
                Map(x => x.GroupType);
                References(x => x.Founder)
                    .Column("Founder");
                References<GroupRank>(x => x.DefaultRank)
                    .Column("DefaultRank");
                HasMany<GroupRank>(x => x.GroupRanks)
                    .KeyColumn("Group_id")
                    .Not.LazyLoad()
                    .Cascade.All();
                HasMany<Account>(x => x.OpenInvitations)
                    .KeyColumn("Group_invites")
                    .Not.LazyLoad()
                    .Cascade.All();
            }
        }
I do that to make sure the members and ranks are loaded at runtime
Because otherwise, the members are not available (nullreference)
Tim Potze
@ikkentim
Feb 20 2017 13:03
shouldn't be a null reference, but loaded lazily
Florian van Dillen
@fvandillen
Feb 20 2017 13:03
Hmm, i'll try to expiriment with that then
Not that it matters, because it only does the queries at server startup and runs the groups from memory
Tim Potze
@ikkentim
Feb 20 2017 13:04
That's why everything should be virtual in an nhibernate model, nhibernate creates a proxy type which inherrits from this type, when accessing a lazy property, the value is loaded on the fly
Florian van Dillen
@fvandillen
Feb 20 2017 13:04
Oh nice
Tim Potze
@ikkentim
Feb 20 2017 13:04
that's how lazy loading works
Florian van Dillen
@fvandillen
Feb 20 2017 13:04
I'll try to remove the .Not.LazyLoad() then and see if it works
Tim Potze
@ikkentim
Feb 20 2017 13:05
if you're still getting a null ref when trying to lazy laod, try setting the default value to = new List<X>() of each lazy property
Florian van Dillen
@fvandillen
Feb 20 2017 13:05
Default value in the class itself?
Florian van Dillen
@fvandillen
Feb 20 2017 15:56
Made a mission framework for my roleplay server :) https://puu.sh/ubMl8/b23b7c69df.png
Tim Potze
@ikkentim
Feb 20 2017 15:57
:o :)
Florian van Dillen
@fvandillen
Feb 20 2017 15:58
Going to make all my individual missions such as a fire mission, meth production extend this class
Michael Kilpatrick
@NewbProgramming
Feb 20 2017 16:01
Succeed and receive money or fail and die. Nice nice.
Florian van Dillen
@fvandillen
Feb 20 2017 16:01
Get rich or die tryin', bitch
:D