zerodowned

Moderator
I added a new property to Guild.cs and am trying to read the property with another script

PlayerMobile pm = (PlayerMobile)m;
pm.Guild.NewProperty;

but i get this error
Line 113: 'Server.Guilds.BaseGuild' does not contain a definition fo
r 'NewProperty' and no extension method 'NewProperty' accepting a first argument o
f type 'Server.Guilds.BaseGuild' could be found (are you missing a using directi
ve or an assembly reference?)

Why is it trying to read from BaseGuild when i'm referencing the player's guild?
 
I added a new property to Guild.cs and am trying to read the property with another script

PlayerMobile pm = (PlayerMobile)m;
pm.Guild.NewProperty;

but i get this error


Why is it trying to read from BaseGuild when i'm referencing the player's guild?

hmm after looking at Guild.cs sure it wouldnt be....
pm.Guilds.NewProperty;

might be why it doesnt see it
Code:
namespace Server.Guilds
{
 
that's the namespace, not the class but thank you for helping

i ended up adding support for the new property to baseguild
 
Try

Code:
var g = pm.Guild as Guild;
if(g!=null)
{
   Console.WriteLine(g.NewProperty);
}

The reason being that the property "Guild" in Mobile is a reference to a BaseGuild and not a guild. You have to first cast it to a guild to access properties inside the guild class.

If the code you are writing is in the core, then yes you must add it to BaseGuild.
 
Works perfectly - the code seems redundant but I understand the reason for writing it that way.

Thank you Jack
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back