Provisions Chest
Posted: Sat Jan 25, 2003 11:19 pm
I wrote these sets of scripts for a module I was working on. Players were in a village heading to "The City of the Dead" where there would be no merchants. So I created this system in which they have a chest on the docks that they put as much stuff as they want into it, and when it is shut it is "virtually" stored aboard a ship they will be taking to the new area. Once they take the ship there are 8 chests on the dock on the other side. The first chest they open has all the stuff the stored and a key. If they take the key then the chest is locked and no one can get to their stuff. If they leave the key in the chest then it does not lock and can be used by someone else. I just listed the scripts for the actually "provisions", but can post the "Locker" scripts if anyone is interested.
First script goes on the OnClose event on the First Chest:
void main()
{
object oPC=GetLastOpenedBy();
int ProvisionNumber=GetLocalInt(oPC,"ProvisionNumber");
object oItem=GetFirstItemInInventory(OBJECT_SELF);
while(GetIsObjectValid(oItem))
{
SetLocalString(oPC,"Provision"+IntToString(ProvisionNumber),GetTag(oItem));
SetLocalInt(oPC,"ProvisionQty"+IntToString(ProvisionNumber),GetNumStackedItems(oItem));
SetLocalInt(oPC,"ProvisionIdent"+IntToString(ProvisionNumber),GetIdentified(oItem));
ProvisionNumber++;
DestroyObject(oItem,0.0);
oItem=GetNextItemInInventory(OBJECT_SELF);
}
SetLocalInt(oPC,"ProvisionNumber",ProvisionNumber);
}
The next script goes on the OnOpen event of the chest in a new area (or Module I think):
void main()
{
object oPC=GetLastOpenedBy();
int ProvisionNumber=GetLocalInt(oPC,"ProvisionNumber");
if(ProvisionNumber!=0 && GetIsObjectValid(oPC))
{
int nX;
for(nX=0; nX<=(ProvisionNumber-1); nX++)
{
string sItemTemplate=GetLocalString(oPC,"Provision"+IntToString(nX));
int nStackSize=GetLocalInt(oPC,"ProvisionQty"+IntToString(nX));
object oItem=CreateItemOnObject(sItemTemplate, OBJECT_SELF, nStackSize);
SetIdentified(oItem, GetLocalInt(oPC,"ProvisionIdent"+IntToString(nX)) );
}
SetLocalInt(oPC,"ProvisionNumber",0);
}
}
First script goes on the OnClose event on the First Chest:
void main()
{
object oPC=GetLastOpenedBy();
int ProvisionNumber=GetLocalInt(oPC,"ProvisionNumber");
object oItem=GetFirstItemInInventory(OBJECT_SELF);
while(GetIsObjectValid(oItem))
{
SetLocalString(oPC,"Provision"+IntToString(ProvisionNumber),GetTag(oItem));
SetLocalInt(oPC,"ProvisionQty"+IntToString(ProvisionNumber),GetNumStackedItems(oItem));
SetLocalInt(oPC,"ProvisionIdent"+IntToString(ProvisionNumber),GetIdentified(oItem));
ProvisionNumber++;
DestroyObject(oItem,0.0);
oItem=GetNextItemInInventory(OBJECT_SELF);
}
SetLocalInt(oPC,"ProvisionNumber",ProvisionNumber);
}
The next script goes on the OnOpen event of the chest in a new area (or Module I think):
void main()
{
object oPC=GetLastOpenedBy();
int ProvisionNumber=GetLocalInt(oPC,"ProvisionNumber");
if(ProvisionNumber!=0 && GetIsObjectValid(oPC))
{
int nX;
for(nX=0; nX<=(ProvisionNumber-1); nX++)
{
string sItemTemplate=GetLocalString(oPC,"Provision"+IntToString(nX));
int nStackSize=GetLocalInt(oPC,"ProvisionQty"+IntToString(nX));
object oItem=CreateItemOnObject(sItemTemplate, OBJECT_SELF, nStackSize);
SetIdentified(oItem, GetLocalInt(oPC,"ProvisionIdent"+IntToString(nX)) );
}
SetLocalInt(oPC,"ProvisionNumber",0);
}
}