Annoying Server Side Inventory implemented. Needs extensive testing.

If enabled, all player actions are disabled until they /login which triggers a inventory check against the server. If they fail the check the login doesn't occur and they can't act. Default inventory for new accounts or characters requires a new character's inventory and health. Every inventory change that occurs is stored back into playerData memory and then onLeave it's stored back into the database, to be loaded at next /login
This commit is contained in:
Zidonuke 2011-12-20 16:21:22 -05:00
parent ed21c2e8a4
commit bc7fac9b73
6 changed files with 200 additions and 20 deletions

View file

@ -438,14 +438,10 @@ namespace TShockAPI
public NetItem[] inventory = new NetItem[NetItem.maxNetInventory];
public int maxHealth = 100;
public int maxMana = 100;
public string accountName;
public string characterName;
public bool exists = false;
public PlayerData(TSPlayer player)
{
this.accountName = player.UserAccountName;
this.characterName = player.Name;
this.inventory[0].netID = -15;
this.inventory[0].stack = 1;
if(player.TPlayer.inventory[0].netID == -15)
@ -459,6 +455,58 @@ namespace TShockAPI
if (player.TPlayer.inventory[2].netID == -16)
this.inventory[2].prefix = player.TPlayer.inventory[2].prefix;
}
public void StoreSlot(int slot, int netID, int prefix, int stack)
{
this.inventory[slot].netID = netID;
if (this.inventory[slot].netID != 0)
{
this.inventory[slot].stack = stack;
this.inventory[slot].prefix = prefix;
}
else
{
this.inventory[slot].stack = 0;
this.inventory[slot].prefix = 0;
}
}
public void CopyInventory(TSPlayer player)
{
Item[] inventory = player.TPlayer.inventory;
Item[] armor = player.TPlayer.armor;
for (int i = 0; i < NetItem.maxNetInventory; i++)
{
if (i < 49)
{
this.inventory[i].netID = inventory[i].netID;
if (this.inventory[i].netID != 0)
{
this.inventory[i].stack = inventory[i].stack;
this.inventory[i].prefix = inventory[i].prefix;
}
else
{
this.inventory[i].stack = 0;
this.inventory[i].prefix = 0;
}
}
else
{
this.inventory[i].netID = armor[i].netID;
if (this.inventory[i].netID != 0)
{
this.inventory[i].stack = armor[i].stack;
this.inventory[i].prefix = armor[i].prefix;
}
else
{
this.inventory[i].stack = 0;
this.inventory[i].prefix = 0;
}
}
}
}
}
public class NetItem