Author Topic: One-use items  (Read 641 times)

Say I wanted the gun to have a one time use, so that when you fire the gun is no longer in your inventory. Wouldn't I use something like this? I found this in another script so I tried it out.
Code: [Select]
function gunImage::onFire(%this,%obj,%slot)
{
if(%obj.getDamagePercent() < 1.0)
%obj.playThread(2, shiftAway);
Parent::onFire(%this,%obj,%slot);

%currSlot = %obj.lastHESlot;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
}
The only problem is that when I fire, it dissapeares from my hand but remains in my inventory.

Also, how do you check if a player is in a minigame?

Also again, why won't this work?
Code: [Select]
function GunProjectile::damage(%this,%obj,%col,%fade,%pos,%normal)
{
%client = %obj.client;

if(%client.minigame)
{
%client.kill();
}
}
« Last Edit: May 14, 2010, 02:56:57 AM by Deriboy »


%currSlot = %obj.lastHESlot is your problem.
Change that to
%currSlot = %obj.curTool
I think.

As for the second part, %client doesn't have a kill(); command. %client is also the person who shot the bullet and I'm absolutely sure you don't want the person to die when they're the one who shot the bullet.

%col is what is being hit, not %obj.

So %client would be %col.client
As for the if part
if(minigameCanDamage(%obj,%col))
is the better way to do that.
Lastly, change %client.kill(); to %col.kill();

%currSlot = %obj.lastHESlot is your problem.
Change that to
%currSlot = %obj.curTool
I think.

As for the second part, %client doesn't have a kill(); command. %client is also the person who shot the bullet and I'm absolutely sure you don't want the person to die when they're the one who shot the bullet.

%col is what is being hit, not %obj.

So %client would be %col.client
As for the if part
if(minigameCanDamage(%obj,%col))
is the better way to do that.
Lastly, change %client.kill(); to %col.kill();
I fixed the one hit kill problem, but I'm still having my original problem with the gun not leaving my inventory.

The first part of my post explains how to fix that.

The first part of my post explains how to fix that.
I tried that and it still does the same thing.

Then I typed a value wrong.

Try .currTool

Thanks. That worked.