Author Topic: [Request] Infinite items  (Read 3335 times)

I'm in need of a script for private use that allows you to use items infinite times. For example the HE grenade, pill, etc. So when you use the pill, it wont be removed from your inventory. If this something that can be changed/added to the item's script, I can do it myself if someone provides me with the script. I can't script for stuff.

Firing code of the HE grenade:
Code: [Select]
function hegrenadeImage::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);
}
With an external script you can overwrite that function:
Code: [Select]
package HEGrenadeOverwritePackage
{
function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
Parent::OnFire(%this, %obj, %slot);
}
}
activatePackage(HEGrenadePackage);
As far as i know, that should do the trick.

Code: [Select]
Loading Add-On: Weapon_HEGrenadeInf
Add-Ons/Weapon_HEGrenadeInf/Weapon_HEGrenadeInf.cs Line: 522 - Syntax error.
>>> Some error context, with ## on sides of error halt:
   textureName = "Add-Ons/Weapon_HEGrenade/icon_hegrenade";

};



package heGrenadeOverwritePackage

{

^function hegrenadeImage::onFire(%this, %obj, %slot)

^{

^^%obj.playthread(2, spearThrow);

^^Parent::OnFire(%this, %obj, %slot);

^}

}

activatePackage(##h##eGrenadeOverwritePackage);
>>> Error report complete.

ADD-ON "Weapon_HEGrenadeInf" CONTAINS SYNTAX ERRORS

Oh dear, i forgot to check it fully it seems. D:

Add a ; at the last }

So that will be:
Code: [Select]
package HEGrenadeOverwritePackage
{
function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
Parent::OnFire(%this, %obj, %slot);
}
};
activatePackage(HEGrenadeOverwritePackage);

Again my apologies for this.
If you run into more trouble, just post.

WAIT FOR IT, rechecking, i believe i posted it wrong.
You fixed it allready in your first run.

I checked it, but it seems i have overseen something in the script...
Because i keep getting the HEgrenade after i throwed it.
My inventory gets spammed all of sudden.

I will look again, sorry.
« Last Edit: February 26, 2010, 10:23:39 AM by lordician »

Well, the script executes and the item works. But I still can use it only once. I want infinite HE Grenades. =(

Well, the script executes and the item works. But I still can use it only once. I want infinite HE Grenades. =(
Yes i noticed sadly.
And the 'fun' part is, i even removed everything that unmounts images or something similiar to that...
Odd.

Oh dear, i seem to have found something.
I will post when i have found the RIGHT answer.
« Last Edit: February 26, 2010, 11:30:24 AM by lordician »

Remove this line and replace is with lord's
Code: [Select]
function hegrenadeImage::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);
}
Lord, yours is still calling back the Parent::OnFire(%this, %obj, %slot); causing it to still use the other stuff.

Remove this line and replace is with lord's
Code: [Select]
function hegrenadeImage::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);
}
Lord, yours is still calling back the Parent::OnFire(%this, %obj, %slot); causing it to still use the other stuff.
That's what i found last. :P
Silly me...

Can't you just remove the function that causes it to be used once?

Code: [Select]
package HEGrenadeOverwritePackage
{
function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
WeaponImage::OnFire(%this, %obj, %slot);
}
};
activatePackage(HEGrenadeOverwritePackage);

Code: [Select]
package HEGrenadeOverwritePackage
{
function hegrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
WeaponImage::OnFire(%this, %obj, %slot);
}
};
activatePackage(HEGrenadeOverwritePackage);
So close, yet so far. D:

I tried lordician's and Space Guy's code and followed heedicalking's instructions. Both did the same thing. I charge the grenade, throw it, after 1 second the grenade disappears from my hand, but not from the inventory. As such, I cannot throw the grenade again. I move one inventory slot down for another grenade, still no grenade in my hand. I move down one more and then I have a functional grenade in my hand.

How are you running the code?

Enabling the HE Grenade as a normal add-on?

So where in the file are you putting the changes? Attach the cs file or something.