Code: Select all
version "4.6.1"
class FirstAidKit : Inventory
{
default
{
+INVENTORY.UNDROPPABLE;
+INVENTORY.INVBAR;
Inventory.Amount 100;
Inventory.MaxAmount 100;
Inventory.InterHubAmount 100;
Inventory.PickUpMessage "Picked up First Aid Kit";
Inventory.Icon "TNT1A0";
}
override bool Use (bool pickup)
{
bool result = Super.Use(pickup);
int firstAidAmount;
firstAidAmount = owner.CountInv ("FirstAidKit");
if (!owner || !owner.player || owner.player.Health > 100 || !owner.FindInventory("FirstAidKit"))
return false;
if (owner.player.Health < 100 && firstAidAmount != 0)
{
owner.A_StartSound ("Inventory/PKUP_Potion", CHAN_ITEM);
}
while (owner.player.Health < 100 && firstAidAmount != 0)
{
owner.GiveBody (1);
owner.A_TakeInventory ("FirstAidKit", 1);
}
return result;
}
States
{
Spawn:
TNT1 A -1;
Stop;
}
}
VM execution aborted: tried to read from address zero.
And the line occurs this error is:
Code: Select all
while (owner.player.Health < 100 && firstAidAmount != 0)
I like this script personally because it doesn't require long states codes and easy to read though, I have no idea how to solve this issue. Any help appreciated.