Author Topic: Removing from inventory  (Read 660 times)

Well i'm trying to make somekind of Rocket Launcher, but it's not removing from inventory correctly.

Hmm.. Better explain:

-When I shoot, the Rocket Launcher should be discarded. Well that's not working.

Code: [Select]
function RPGLauncherImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);

%currSlot = %obj.lastRPGLauncherSlot;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
}
Is that the script for removing from your slot correct?

Get rid of the %currentSlot variable and just use %slot. You should use %obj.unmountImage(%slot); instead of serverCmdUnuseTool(%obj.client); as the latter wouldn't work for bots.

Get rid of the %currentSlot variable and just use %slot. You should use %obj.unmountImage(%slot); instead of serverCmdUnuseTool(%obj.client); as the latter wouldn't work for bots.
Ok. I'll try it.

It's not working Amade.

What I should do? :<

Code: [Select]
function RPGLauncherImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
%count = %obj.getDatablock().maxTools;
for(%i = 0; %i < %count; %i++)
{
if(%obj.tool[%i] == RPGLauncherItem.getID())
{
%currentSlot = %i;
break;
}
}
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
%obj.unmountImage(%slot);
}

Code: [Select]
function RPGLauncherImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
%count = %obj.getDatablock().maxTools;
for(%i = 0; %i < %count; %i++)
{
if(%obj.tool[%i] == RPGLauncherItem.getID())
{
%currentSlot = %i;
break;
}
}
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
%obj.unmountImage(%slot);
}
Thanks, Amade. I got it working now. =P