Author Topic: Trying to make the Glowstick one time usable.  (Read 802 times)

I tried to make the Glowstick (Made by Extrude)   only usable once, so i added the following line of code:
Code: [Select]
package glowstickPackage
{
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.dataBlock $= "SmokeGrenadeItem" && %col.canPickup)
{
for(%i=0;%i<%this.maxTools;%i++)
{
%item = %obj.tool[%i];
if(%item $= 0 || %item $= "")
{
%freeSlot = 1;
break;
}
}

if(%freeSlot)
{
%obj.pickup(%col);
return;
}
}
Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
}
};
activatePackage(glowstickPackage);

function glowstickImage::onCharge(%this, %obj, %slot)
{
%obj.playthread(2, spearReady);
%obj.lastHESlot = %obj.currTool;
}

function glowstickImage::onAbortCharge(%this, %obj, %slot)
{
%obj.playthread(2, root);
}

function glowstickProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
serverPlay3D(glowstickBounceSound,%obj.getTransform());
}

function glowstickImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
Parent::OnFire(%this, %obj, %slot);

%currSlot = %obj.lastHESlot;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
}

function glowstickImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);

But it failed, it made it worse.
The glowstick didn´t appear in the item list.
What should i do to fix it?

Check console, it's obviously an error and it might help.

I believe you're going to want to put your code to remove the tool in ::onDone, not ::onFire.

Either that, or take out the serverCmdUnUseTool line from ::onFire. If it doesn't show up in the item list, either you forgeted up the script and you should try again with a brand new copy or there's an error in console.