Jump to content

Home

"check if has item" help ..


Darth Essence

Recommended Posts

If you're looking to determine whether the creature has an item equipped, you can you use the GetItemInSlot function. If you just want to check if the creature has an item in its inventory you can use the GetItemPossessedBy or GetItemPossessor functions.

 

Example:

 

 

// a dialog conditional script to determine
// if player has an item equipped as their 
// right or left handed weapon
// where the Tag of the item is a string parameter


int StartingConditional() {
string sItem=GetScriptStringParameter();
object oPC=GetFirstPC();
object oRight = GetItemInSlot(INVENTORY_SLOT_RIGHTWEAPON, oPC);
if (GetIsObjectValid(oRight)) {
	if (GetTag(oRight)==sItem) {
		return TRUE;
	}
}
object oLeft = GetItemInSlot(INVENTORY_SLOT_LEFTWEAPON, oPC);
if (GetIsObjectValid(oLeft)) {
	if (GetTag(oLeft)==sItem) {
		return TRUE;
	}
}
return FALSE;
}

// a dialog conditional script to determine
// if the player has a particular item in their inventory
// where the Tag of the item is a string parameter

int StartingConditional() {
string sItem=GetScriptStringParameter();
object oPC=GetFirstPC();
object oItemPossessed = GetItemPossessedBy(oPC,sItem);
return GetIsObjectValid(oItemPossessed);
}

Link to comment
Share on other sites

yes ... i saw this in many original scripts .. but i kinda cannot figure out the "GetScriptStringParameter();" thingy ... how does the script know which item i want if i don't even write its tag anywhere in the script ?

 

That function is used in action/conditional scripts fired from nodes in a DLG (conversation) file. There are a series of fields on each dialog node where you can set values the scripts can check for. The String Param field (in tk102's DLG editor) can be set to a value that GetScriptStringParameter() will be able to fetch into the script.

 

If your scripts are not for use in a DLG file it would be easier to help if you described how/where they would be used.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...