Author Topic: Getting last used tool  (Read 963 times)

How do I get the slot of the last wielded tool when the player does not have a tool raised? The player raises this tool when you press Q again, so it should be possible.

%Player.currTool is -1 regardless of what was last held.

Code: [Select]
function serverCmdUnUseTool(%client)
{
%player = %client.player;
%player.lastUsedTool = %player.currTool;
Parent::serverCmdUnUseTool(%client);
}
There you go, when the player presses Q to hide their inventory, a variable is assigned to their player with the last tool used.

I was hoping there was an easier way...

I was hoping there was an easier way...
I believe that's as easy as it gets.

More simplified:
Code: [Select]
function serverCmdUnUseTool(%client)
{
%client.player.lastUsedTool = %client.player.currTool;
Parent::serverCmdUnUseTool(%client);
}
5 lines of code is pretty easy. =/

It needs to be in a package.

It needs to be in a package.
Oh yeah...

Code: [Select]
package LastUsedTool
{
function serverCmdUnUseTool(%client)
{
%client.player.lastUsedTool = %client.player.currTool;
Parent::serverCmdUnUseTool(%client);
}
};
activatePackage(LastUsedTool);
Just stick this in any script that needs to know the client's player's last tool.  The variable is assigned to the client's player as '.lastUsedTool'.


EDIT: I said something here but it turns out I was wrong.
« Last Edit: July 15, 2011, 05:36:18 PM by Jorgur »