Module commit
Module commit.
This commit is contained in:
47
_module/nss/pv_get_backpacks.nss
Normal file
47
_module/nss/pv_get_backpacks.nss
Normal file
@@ -0,0 +1,47 @@
|
||||
//::///////////////////////////////////////////////
|
||||
//:: Name: pv_get_backpacks
|
||||
//:://////////////////////////////////////////////
|
||||
/*
|
||||
Checks the player's inventory for merchant
|
||||
backpacks and stores them as local objects
|
||||
*/
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
#include "pv_utils"
|
||||
|
||||
int StartingConditional()
|
||||
{
|
||||
object oNPCMerchant = OBJECT_SELF;
|
||||
object oPC = GetLocalObject(oNPCMerchant, "PV_MERCHANT_OWNER");
|
||||
object oItem = GetFirstItemInInventory(oPC);
|
||||
|
||||
int nBackpackCount = 0;
|
||||
|
||||
// Delete possible backpack info so that there isn't any conflict if one was removed
|
||||
// from the previous set.
|
||||
for (nBackpackCount = 0; nBackpackCount < MAX_BACKPACKS_PER_INVENTORY; nBackpackCount++)
|
||||
{
|
||||
DeleteLocalObject(oNPCMerchant, "PV_BACKPACK_NUM_"+IntToString(nBackpackCount));
|
||||
}
|
||||
|
||||
nBackpackCount = 0;
|
||||
while (GetIsObjectValid(oItem) && nBackpackCount < MAX_BACKPACKS_PER_INVENTORY)
|
||||
{
|
||||
if ( ( GetTag(oItem) == "merc_backpack" )
|
||||
&& ( GetIsObjectValid(GetFirstItemInInventory(oItem) ) ) /* Only include backpacks that have at least one item*/
|
||||
)
|
||||
{
|
||||
SetLocalObject(oNPCMerchant, "PV_BACKPACK_NUM_"+IntToString(nBackpackCount), oItem);
|
||||
nBackpackCount++;
|
||||
}
|
||||
|
||||
oItem = GetNextItemInInventory(oPC);
|
||||
}
|
||||
|
||||
if (nBackpackCount > 0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
Reference in New Issue
Block a user