Author Topic: Locking the inventory  (Read 1562 times)

I am trying to create an RPG server with different mini-games in it. You will be able to purchase weapons and other items and carry them to use in the mini-games. For this I need the players' inventories to be locked so they won't update at respawn/leave minigame/etc.

Could anyone help me out?

Are you asking for a script or asking for help with a script?

I figured it was as simple as overwriting/disabling certain pieces of code. Then again I'm not much of a coder so I might be wrong.

Isn't there an add-on for this on RTB? This may be what you're looking for>> http://forum.returntoblockland.com/dlm/viewFile.php?id=56

Ok, thanks, this might work.

You have two ways to do this:

-Rewrite all the item related functions to be set to the client insead of the player.
-Set client's tools when they die and set player's tools when they spawn.

I think I'll go for the first method, seeing as how it is most fail-safe way.
However, I'm not completely sure what you mean by "set to the client". Could you be more specific, perhaps provide a simple example? Also, where can I locate the original code in order to examine it?

I recommend the second method actually. Download Destiny's save item events, then create a simple script using the included functions. Overwrite serverCmdJoinMinigame or whatever the joining function is and call .saveItems() before parenting then .loadItems() after the parent.

You could also save before onDeath and load after createPlayer.

Ok, that would be a lot easier. I thought method 2 relied on events, but this should be just as failsafe.

So I guess I would overwrite:
- Death
- Join Mini-game
- Leave Mini-game
« Last Edit: March 19, 2010, 11:20:33 AM by Jorgur »

They're both failsafe, and the second method would be a lot easier, however I would personally go with the first one. I recommend using the second one.

I will start out with method #2, and later move on to #1 to get rid of these annoying sounds when items are loaded.

First I'm adding to the death and spawn scripts. The saving script works, but I can't get the items to load after spawning.

Code: [Select]
package LockInventory
{
function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %unknownA)
{
%player = %client.player;
%client.player.saveItems(%player);
Parent::onDeath(%client, %player, %killer, %damageType, %unknownA);
}

function GameConnection::createPlayer(%this, %spawnPoint)
{
Parent::createPlayer(%this, %spawnPoint);
%client.player.loadItems(%player);
}
};
activatePackage(LockInventory);

It's just %client.player.saveItems() without any args, although it wouldn't change anything in this case.
You'll also want to check if it's their first time spawning, otherwise it will set their players items to nothing, since they have none saved.

That is not a problem. Infact, I want them to spawn without any tools the first time.
What is a problem, is that the call to loadItems in createPlayer does nothing.

You'll need the events installed and enabled.

You may want to schedule the loading part. It's probably being overwritten by the TDM item settings. (Spawn, Sets minigame items, sets your saved items, sets team items to nothing)

Does that take effect even outside of mini-games?

EDIT: OK, success! I just slipped the code into Space Guy's stuff. Hope it's not against any norms or anything.
« Last Edit: March 20, 2010, 10:15:28 AM by Jorgur »