Author Topic: More Inventory Slots  (Read 2135 times)

So I made a new player datablock that has 12 inventory slots instead of the default 5, but the inventory slots aren't showing up on the screen. I think that the slots are there, because I can pick up an item when my inventory is full, the only problem is the item doesn't show up.

This is RPGPlayer.cs
Code: [Select]
datablock PlayerData(PlayerRPG : PlayerStandardArmor)
{
miniJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;

uiName = "RPG Player";
showEnergyBar = false;
maxTools = 12;
maxWeapons = 12;
};

Then this is server.cs
Code: [Select]
exec("./RPGPlayer.cs");

So I made a new player datablock that has 12 inventory slots instead of the default 5, but the inventory slots aren't showing up on the screen. I think that the slots are there, because I can pick up an item when my inventory is full, the only problem is the item doesn't show up.

This is RPGPlayer.cs
Code: [Select]
datablock PlayerData(PlayerRPG : PlayerStandardArmor)
{
miniJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;

uiName = "RPG Player";
showEnergyBar = false;
maxTools = 12;
maxWeapons = 12;
};

Then this is server.cs
Code: [Select]
exec("./RPGPlayer.cs");
Code should work. Kill your player and set your player datablock to "PlayerRPG". If that doesn't work, restart your Blockland.

I also believe you have to send a command to the client when their datablock is set to that to fix their inventory slot count.

I believe the command is something like commandToClient(%client,'PlayGui_CreateToolHud',%datablock.maxTools);

I also believe you have to send a command to the client when their datablock is set to that to fix their inventory slot count.

I believe the command is something like commandToClient(%client,'PlayGui_CreateToolHud',%datablock.maxTools);

Would that command go inside the server.cs file or inside the datablock itself?

Since it's a commandToClient to update the player's max tools, it should go in a packaged OnClientEnterGame().

You can use this really old support add-on, which will apply the change in cases where it should happen: http://www.mediafire.com/download/bno6np3njbmaezp/Support_InventorySlots.zip
Blockland was pretty dumb about that functionality back when it was released, dunno if it's gotten better since then. I think you can also just use the playertype in a minigame and it will update your slots properly when you spawn with it.
« Last Edit: March 28, 2015, 07:16:57 PM by -Jetz- »

isn't the actual tool HUD limited to a certain number of slots though

i might be wrong but i'm pretty sure that's a thing

Since it's a commandToClient to update the player's max tools, it should go in a packaged OnClientEnterGame().

Alright, here's the updated server.cs
Code: [Select]
package updateRPGPlayer
{
function GameConnection::onClientEnterGame(%client)
{
commandToClient(%client, 'PlayGui_CreateToolHud', %datablock.maxTools);
Parent::onClientEnterGame(%client);
}
};

exec("./RPGPlayer.cs");
activatePackage(updateRPGPlayer);

The problem I was having before is still there, it doesn't seem to have changed anything.

Givnig it a second thought, that would only take effect the first time the client spawns. Try packaging a player spawn command.

Givnig it a second thought, that would only take effect the first time the client spawns. Try packaging a player spawn command.

Thanks! That seems to have worked. However, it only works if I respawn; if I use the changeDatablock event (hence, I don't respawn), it doesn't work. Is there any way to fix this?

Package changeDatablock() to add it. Remember to call the commandToClient AFTER the Parent::.

Remember to call the commandToClient AFTER the Parent::.

Why is it important to call the parent function first? Wouldn't the end result be the same?

Well, I think that it would cause an error if you try to update the client's tool GUI without having the datablock with 12 tool slots. I could be wrong though.

Package Armor::onNewDatablock instead.  Just to clarify you don't need to use this add-on that has existed for years to help do exactly what you're doing right now, but you might at least look at it for reference...
You can use this really old support add-on, which will apply the change in cases where it should happen: http://www.mediafire.com/download/bno6np3njbmaezp/Support_InventorySlots.zip