Jump to content

Home

Scripting a Base Item Check


Silveredge9

Recommended Posts

I've been trying to create a conditional script that would perform an action when the right type of item has been added by the player to the inventory of the item the script is attached to. Like in one of the Korriban Tombs where you have to put a grenade into the Pillar.

 

Through my own research I've come up with the script below. It doesn't compile, but I feel it's at least close to what I'm wanting to acheive.

 

void main(){

int iBaseItem = "BASE_ITEM_FRAGMENTATION_GRENADES";
object oTran=GetObjectByTag("msp_tran1");
object oGrenade = GetFirstItemInInventory(oTran);


if (GetBaseItemType(oGrenade) == iBaseItem);
{


}
}

 

Thanks in advance for any help. :)

Link to comment
Share on other sites

I've been trying to create a conditional script that would perform an action when the right type of item has been added by the player to the inventory of the item the script is attached to. Like in one of the Korriban Tombs where you have to put a grenade into the Pillar.

 

Through my own research I've come up with the script below. It doesn't compile, but I feel it's at least close to what I'm wanting to acheive.

 

There are a few problems with your script. You try to assign a string constant to an integer variable, you only check the first item (which is usually enough but to be safe it's best to check all of them until a match is found), and you terminate the if statement check before the following block is executed. Try this variant of your script:

void main(){
   if (GetLocalBoolean(OBJECT_SELF, 40)) 
       return;

   object oTran=GetObjectByTag("msp_tran1");
   object oGrenade = GetFirstItemInInventory(oTran);

   while (GetIsObjectValid(oGrenade)) {
       if (GetBaseItemType(oGrenade) == BASE_ITEM_FRAGMENTATION_GRENADES) {

           [color=PaleGreen]// ST: GRENADE! Do what is supposed to be done here.[/color]

           SetLocalBoolean(OBJECT_SELF, 40, TRUE);
           break;
       }
       oGrenade = GetNextItemInInventory(oTran);
   }
}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...