Finaltwist

Member
So...


C#:
        public virtual void NewZombie( Mobile from, Zombiex zomb )
        {

                BaseCreature mob = (BaseCreature)from;

works perfect, but

C#:
        public virtual void NewZombie( Mobile from, Zombiex zomb )
        {

            if ( from is BaseCreature )
                BaseCreature mob = (BaseCreature)from;
            
            else if ( from is PlayerMobile )
                PlayerMobile mob = (PlayerMobile)from;
            else return;

throws a "embedded statement cannot be a declaration" error from the
BaseCreature mob = (BaseCreature)from;
PlayerMobile mob = (PlayerMobile)from;
lines...

i tried with { } after the if/else statements but then it just ignored what was in the {}... ?
 
Hi PyrO. We are here:

Most of this is fixed by using Mobile but some other issues are coming out of the woodwork.
 

I would also need to look at the full method to know why you even want to cast it to basecreature or playermobile

Basecreature has an onbeforedeath that links to newzomb
playermobile has an onbeforedeath that link to newzomb.

newzomb uses the from (from either of those) to create a new zombie based on the from.

there was a crash because it used to be
BaseCreature mob = (BaseCreature)from;

so when a player died and was sent from playermobile ,the script crashed because the from was a playermobile, not a basecreature.
so now we just need to add an if check. if its a playermobile, cast it as a playermobile, if its a basecreature, cast it as a basecreature... but then im not doing the if correctly it seems ?
 
updated the package in your main thread ;)

and well every time you go into an if? It basically has a scope of an higher level, it can access the one thats lower. So you made an if that defines a variable that is only valid for said if. That was the issue.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back