Hi all,
Im needing a script that will be able to clear a merchant inventory after a set amount of time and be able to warn players server wide before it clears the merchant.
Thx
Merchant clean script
Débuté par
Madasahatter
, oct. 29 2010 07:54
#1
Posté 29 octobre 2010 - 07:54
#2
Posté 29 octobre 2010 - 08:27
Off the top of my head...could do a hearbeat script to keep track of how much time has passed. Came up with this:
//Heartbeat script
void main()
{
int iBeats = GetLocalInt(OBJECT_SELF, "BEATS");
SetLocalInt(OBJECT_SELF, "BEATS", iBeats + 1);
iBeats = GetLocalInt(OBJECT_SELF, "BEATS");
//@ approx 10 seconds per heartbeat, 360 HBs is approx 1 hour real time.
if (iBeats == 348)//2 minutes until inventory is deleted.
{
object oPC = GetFirstPC();
while (GetIsObjectValid(oPC))
{
SendMessageToPC(oPC, "The store inventory will be deleted in approx. two minutes.");
oPC = GetNextPC();
}
}
if (iBeats == 360)
{
object oStore = GetObjectByTag("Tag of your store");
object oItem = GetFirstItemInInventory(oStore);
while (GetIsObjectValid(oItem))
{
DestroyObject(oItem);
oItem = GetNextItemInInventory(oStore);
}
//Set beats back to 0 and start the proccess over again.
SetLocalInt(OBJECT_SELF, "BEATS", 0);
}
}
This destroys the inventory of the store after about 1 hour of real time. And gives a 2 minute warning to players before the inventory is deleted. You can playe around with the amount of beats if you want different timing.
You can add this to the HB of the module, the area the merchant is in, the merchant himself, or anything else with a heartbeat that can't be destroyed.
This is untested and there are other ways of doing this. This was just my first thought.
Good luck.
//Heartbeat script
void main()
{
int iBeats = GetLocalInt(OBJECT_SELF, "BEATS");
SetLocalInt(OBJECT_SELF, "BEATS", iBeats + 1);
iBeats = GetLocalInt(OBJECT_SELF, "BEATS");
//@ approx 10 seconds per heartbeat, 360 HBs is approx 1 hour real time.
if (iBeats == 348)//2 minutes until inventory is deleted.
{
object oPC = GetFirstPC();
while (GetIsObjectValid(oPC))
{
SendMessageToPC(oPC, "The store inventory will be deleted in approx. two minutes.");
oPC = GetNextPC();
}
}
if (iBeats == 360)
{
object oStore = GetObjectByTag("Tag of your store");
object oItem = GetFirstItemInInventory(oStore);
while (GetIsObjectValid(oItem))
{
DestroyObject(oItem);
oItem = GetNextItemInInventory(oStore);
}
//Set beats back to 0 and start the proccess over again.
SetLocalInt(OBJECT_SELF, "BEATS", 0);
}
}
This destroys the inventory of the store after about 1 hour of real time. And gives a 2 minute warning to players before the inventory is deleted. You can playe around with the amount of beats if you want different timing.
You can add this to the HB of the module, the area the merchant is in, the merchant himself, or anything else with a heartbeat that can't be destroyed.
This is untested and there are other ways of doing this. This was just my first thought.
Good luck.
Modifié par GhostOfGod, 29 octobre 2010 - 08:31 .
#3
Posté 29 octobre 2010 - 09:27
Hey Ghost
Thanks for the quick reply, I have just tested this and seems to do exactly what i need, will see how it goes with a live test.
Thanks
Thanks for the quick reply, I have just tested this and seems to do exactly what i need, will see how it goes with a live test.
Thanks
#4
Posté 14 novembre 2010 - 09:06
Hi all, ok i need to add the ability for the above script to clear the store of items below a certain value ie - clear all below 25000gp
thanks
thanks
#5
Posté 14 novembre 2010 - 10:32
//Heartbeat script
void main()
{
int iBeats = GetLocalInt(OBJECT_SELF, "BEATS");
SetLocalInt(OBJECT_SELF, "BEATS", iBeats + 1);
iBeats = GetLocalInt(OBJECT_SELF, "BEATS");
//@ approx 10 seconds per heartbeat, 360 HBs is approx 1 hour real time.
if (iBeats == 348)//2 minutes until inventory is deleted.
{
object oPC = GetFirstPC();
while (GetIsObjectValid(oPC))
{
SendMessageToPC(oPC, "The store inventory will be deleted in approx. two minutes.");
oPC = GetNextPC();
}
}
if (iBeats == 360)
{
object oStore = GetObjectByTag("Tag of your store");
object oItem = GetFirstItemInInventory(oStore);
while (GetIsObjectValid(oItem))
{
// change the 25000 below to the value you want to use.
if(GetGoldPieceValue(oItem) > 25000) DestroyObject(oItem);
oItem = GetNextItemInInventory(oStore);
}
//Set beats back to 0 and start the proccess over again.
SetLocalInt(OBJECT_SELF, "BEATS", 0);
}
}
void main()
{
int iBeats = GetLocalInt(OBJECT_SELF, "BEATS");
SetLocalInt(OBJECT_SELF, "BEATS", iBeats + 1);
iBeats = GetLocalInt(OBJECT_SELF, "BEATS");
//@ approx 10 seconds per heartbeat, 360 HBs is approx 1 hour real time.
if (iBeats == 348)//2 minutes until inventory is deleted.
{
object oPC = GetFirstPC();
while (GetIsObjectValid(oPC))
{
SendMessageToPC(oPC, "The store inventory will be deleted in approx. two minutes.");
oPC = GetNextPC();
}
}
if (iBeats == 360)
{
object oStore = GetObjectByTag("Tag of your store");
object oItem = GetFirstItemInInventory(oStore);
while (GetIsObjectValid(oItem))
{
// change the 25000 below to the value you want to use.
if(GetGoldPieceValue(oItem) > 25000) DestroyObject(oItem);
oItem = GetNextItemInInventory(oStore);
}
//Set beats back to 0 and start the proccess over again.
SetLocalInt(OBJECT_SELF, "BEATS", 0);
}
}
#6
Posté 18 novembre 2010 - 03:10
on close of merchant
//Refreshes merchant list
void main()
{
object oItem = GetModuleItemLost();
object oOwner = GetItemPossessor(oItem);
if (GetObjectType(oOwner) == OBJECT_TYPE_STORE)
{
if (GetGoldPieceValue(oItem) < 7500) DestroyObject(oItem, 0.1f);
}
}
Doesnt shout to players about clearing items
//Refreshes merchant list
void main()
{
object oItem = GetModuleItemLost();
object oOwner = GetItemPossessor(oItem);
if (GetObjectType(oOwner) == OBJECT_TYPE_STORE)
{
if (GetGoldPieceValue(oItem) < 7500) DestroyObject(oItem, 0.1f);
}
}
Doesnt shout to players about clearing items
#7
Posté 18 novembre 2010 - 10:50
Thanks
#8
Posté 19 novembre 2010 - 01:06
Builder_Anthony wrote...
on close of merchant
//Refreshes merchant list
void main()
{
object oItem = GetModuleItemLost();
object oOwner = GetItemPossessor(oItem);
if (GetObjectType(oOwner) == OBJECT_TYPE_STORE)
{
if (GetGoldPieceValue(oItem) < 7500) DestroyObject(oItem, 0.1f);
}
}
Doesnt shout to players about clearing items
Im having trouble following this. It looks to me like you are saying to place the script above into the OnClosed Event of the store. Then you are useing a module Event function (GetModuleItemLost) in a non module event.
This script being placed in the closing event of a store will have some strange effects. When the store closes it will look at the last item that was unaquired from any where in the module. then destroy it if it is in a store. It may be the store that was just closed. Or the item just sold to a different store by another PC. It also may not get ride of any items when it runs. A monster could loot a barral in a different area just befor you close the store to cause it to do nothing.
Either add it to your module UnAqure event (Effects all stores). Or rewrite it to not use module event functions.
#9
Posté 20 novembre 2010 - 02:21
Hmm...well i had this script wriiten in these forums sometime back ago from what i remember it checks the gold peice vaule of items sold or in the shop and as listed above 7500....well anything less then 7500 would be sold and high priced items would stay in the shop.Like high value magic items that are hard to find in my server.The script would then delete them after the time amount in the script of 0.1.I think the time amount is editable so you could delay the delete.As for it being in the module events tab.Ill try to see if i have anything in the mod for that but i have to check.





Retour en haut






