Dan(Tasanar)

Moderator
I am trying to script it so the True Britannians faction will not let you stay in it if you are a murderer.
In Faction.cs I started this by testing this code and it works fine (also plan on adding it to OnDeath ect). What I can not seem to figure out is how to make it refer to a specific faction. Any help would be great!!
Code:
private static void EventSink_Login(LoginEventArgs e)
        {
            Mobile mob = e.Mobile;
    // Remove murderers   
            PlayerState pl = PlayerState.Find((Mobile)mob);
            if ( mob.Kills >= 5)
            pl.Faction.RemoveMember(mob);
    // Remove murderers
            CheckLeaveTimer(mob);
        }


would like to add it into

if ( mob.kills >=5 && ?? )
 
I would do it like this:

Code:
        private static void EventSink_Login(LoginEventArgs e)
        {
            Mobile mob = e.Mobile;
            // Remove murderers 
            PlayerState pl = PlayerState.Find((Mobile)mob);
            if (pl != null && pl.Faction != null && pl.Faction == TrueBritannians.Instance && mob.Kills >= 5)
                pl.Faction.RemoveMember(mob);
            // Remove murderers
            CheckLeaveTimer(mob);
        }

You might also want to send them a message letting them know they were expelled from the Faction, unless that happens already.
 
Yeah I really just wanted one faction where you sort of had to be a decent person. I applied the same code in Faciton.cs to their on DeathMethod and EventLogin. Basically someone can become red for a little while but will get the boot. Not the cleanest way I am sure but after a few hours tinkering was the best. I am only just starting to get familiar with coding and could not figure out the reference though I was going to start checking out the joinstones ect and see how they inherit specific factions. Thanks for the help!
 
If you don't have it, I would suggest getting Visual Studio setup for your Server. Its very helpful when scripting and finding references to code you can use.
 
I did download it but was having a hard time with it.

I also user the advanced notepad++ that has been a god send.
Thank you very much Lokai that worked great I can even use it for my bad guys faction and set it so you have the be a murderer!

To prevent one or the other from joining each faction I had already scripted the stones. I just spent hours looking in all the wrong places on how to apply what I wanted to players already in.
 
Back