After spending all night, (literally), trying to get all of the aspects of what I'm trying to do into one script, something still seems off. I've been working on learning C++ script more & more, & have the gist of reading it fairly well, (i.e. I can understand how scripts function by looking at other ppl's work), but cannot, for the life of me, remember what some of the functions or "symbols" (i.e. &&, etc.) do.
With that being said, here's what I've got so far......
// ****************************************************************************
// ** CONFIGURATION
// ****************************************************************************
// Prevent a PC from storing too many items, etc.
int MBS_Inv_Limit(object oPC, int iCount, object oItem)
{
{
// Limit this bag to 8 Inventory Slots.
if(iCount > 8)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 12 Inventory Slots.
if(iCount > 12)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 16 Inventory Slots.
// This bag type is used as a small Profession bag:
// Use "Force Into Preferred Container" for item type.
if(iCount > 16)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 20 Inventory Slots.
if(iCount > 20)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 24 Inventory Slots.
if(iCount > 24)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 32 Inventory Slots.
// This bag type is also used as a large Profession bag:
// Use "Force Into Preferred Container" for item type.
if(iCount > 32)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 36 Inventory Slots.
if(iCount > 36)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 40 Inventory Slots.
if(iCount > 40)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 48 Inventory Slots.
if(iCount > 48)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 56 Inventory Slots.
if(iCount > 56)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
{
// Limit this bag to 64 Inventory Slots.
if(iCount > 64)
{
SendMessageToPC(oPC, "You have reached your storage limit.");
return FALSE;
}
}
return TRUE;
}
// ****************************************************************************
// ** CONSTANTS (do not modify)
// ****************************************************************************
// Track of the number of items stored.
const string MBS_COUNT = "MBSCount";
// ****************************************************************************
// ** MAIN (do not modify)
// ****************************************************************************
void main()
{
// Declare Variables
string sBag;
object oPC = GetLastUsedBy();
string sPC = GetName(oPC);
object oBag = GetObjectByTag("mbs_bag");
object oItem = GetInventoryDisturbItem();
int iType = GetInventoryDisturbType();
int iCount = GetLocalInt(oBag, MBS_COUNT);
sBag = GetLocalString(oBag,"mbs_slot");
if (iType == INVENTORY_DISTURB_TYPE_ADDED)
{
// We don't care if the stack size isn't at 50,000 (or the default gold
// stack size), because a custom coin system is being used.
// Instead, the max. item stack in our world is used.
// This may be changed to suit one's own needs.
if (GetItemStackSize(oItem) > 250)
{
DelayCommand(0.3, AssignCommand(OBJECT_SELF, ActionGiveItem(oItem, oPC)));
SendMessageToPC(oPC, "Items must be broken into separate, 250 count stacks.");
}
// We will NOT accept ANY item with an inventory, to prevent exploits.
if (GetHasInventory(oItem))
{
DelayCommand(0.3, AssignCommand(OBJECT_SELF, ActionGiveItem(oItem, oPC)));
// Warn the player that containers cannot be stored in these bags.
SendMessageToPC(oPC, "You cannot store containers within bags.");
// Warn all DMs that a player has tried to exploit the bag system.
SendMessageToAllDMs("Warning:" +sPC+ "tried to put a container into a bag.");
return;
}
if(!MBS_Inv_Limit(oPC, iCount, oItem))
{
// Delay to check for a valid item before transferring to the PC.
DelayCommand(0.3, AssignCommand(OBJECT_SELF, ActionGiveItem(oItem, oPC)));
return;
}
// The inventory items are added to:
iCount++;
SetLocalInt(OBJECT_SELF, MBS_COUNT, iCount);
}
else if (iType == INVENTORY_DISTURB_TYPE_REMOVED)
{
// The inventory items are removed from:
iCount--;
SetLocalInt(OBJECT_SELF, MBS_COUNT, iCount);
}
}
If you haven't guessed from my sh!tty-ass work, I'm trying to associate a with an specific item's "property variable".
i.e. (in the variable properties of an item)
StrName = mbs_bag
int = 8 // or whatever limit I want to put on that bag's inventory space / slots
It compiles just fine, but (of-course) doesn't work like I thought it would.
Any suggestions would be great, but I'd REALLY appreciate a rewrite with comments beside each line / function, explaining how / why it works the way it does, (if someone is willing to go that far).
MUCH Appreciated,
-DotA
P.S. Sorry this post is so long, but the BBCodes (for posting script) I knew in the previous forum don't seem to work here, & I can't seem to find any information as to what codes DO work.
Modifié par Deus of the Apocalypse, 30 août 2010 - 01:00 .





Retour en haut






