Jump to content

Home

Take item script not working


Vox Kalam

Recommended Posts

Won't compile.

void main() {

 

int nQuantity = GetScriptParameter( 1 );

int i;

string sItem = GetScriptStringParameter();

 

if(nQuantity == 0) nQuantity = 1;

 

object "hkarmor" = GetItemPossessedBy (GetPartyLeader(),"hkarmor");

if (GetIsObjectValid("hkarmor"))

{

int nStackSize = GetItemStackSize("hkarmor");

if(nQuantity < nStackSize)

{

nQuantity = nStackSize - nQuantity;

SetItemStackSize("hkarmor", nQuantity);

}

else if(nQuantity > nStackSize || nQuantity == nStackSize)

{

DestroyObject("hkarmor");

}

}

}

Something about string constant in line 9

Link to comment
Share on other sites

Won't compile.

 

Something about string constant in line 9

 

That's because you are using a string constant where you should be using an object variable name throughout the script:

 

 

void main() {

   int nQuantity = GetScriptParameter( 1 );
   int i;
   string sItem = GetScriptStringParameter();

   if(nQuantity == 0) nQuantity = 1;

   object hkarmor = GetItemPossessedBy(GetFirstPC(), "hkarmor");
   if (GetIsObjectValid(hkarmor)) {
       int nStackSize = GetItemStackSize(hkarmor);
       if(nQuantity < nStackSize) {
           nQuantity = nStackSize - nQuantity;
           SetItemStackSize(hkarmor, nQuantity);
       }
       else if(nQuantity > nStackSize || nQuantity == nStackSize) {
           DestroyObject(hkarmor);
       }
   }
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...