This is the code for them equipping it, I don't think anything is wrong with that
- Code: Select all
if(pe.equipped == item) {
Player.SendMessage(p, "That block is already equipped.");
return;
} else {
pe.equipped = item;
Player.SendMessage(p, Block.Name(item) + " equipped.");
p.Blockchange += new Player.BlockchangeEventHandler(this.Blockchange1);
}
And this is where I think the error is, the Blockchange1() void.
- Code: Select all
public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
{
p.ClearBlockchange();
byte tile = type;
PlayerExtra pe = PlayerExtra.Find(p);
if(pe == null) {
pe = new PlayerExtra(p);
}
if(pe.equipped != (byte)255) {
if(tile==Block.Byte("air")) {
p.level.Blockchange(p, x, y, z, tile);
return;
}
int value;
if(pe.inventory.TryGetValue(pe.equipped, out value) == false) {
pe.inventory.Remove(pe.equipped);
pe.equipped = (byte)255;
p.Blockchange -= new Player.BlockchangeEventHandler(this.Blockchange1);
return;
} else if (value == 0) {
pe.inventory.Remove(pe.equipped);
pe.equipped = (byte)255;
p.Blockchange -= new Player.BlockchangeEventHandler(this.Blockchange1);
return;
}
p.level.Blockchange(p, x, y, z, pe.equipped);
pe.inventory.Remove(pe.equipped);
pe.inventory.Add(pe.equipped, value - 1);
Player.SendMessage(p, "Placed 1 block of " + Block.Name(pe.equipped) + ".");
}
}
I wouldn't be surprised if I'm having a derp moment. I would appreciate any feedback you can give me.