logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Auto expire records

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
fgetce



Joined: 04 Jun 2006
Posts: 23

PostPosted: Mon Dec 18, 2006 20:15    Post subject: Auto expire records Reply with quote

I am using Gryphons wonderful vendor system which I love and the players really love.

However they are beginning to clog up the stock of the vendors with their loot and I am looking for a way to auto purge items that are older than a specific time frame.

My approach was to add a column called "expires" and make it a time stamp. At certain intervals I will execute a scrip that will "delete from vendor_Stock where expires < UNIX_TIMESTAMP(now)"

Has anyone tackled this problem of over stocked vendors?

By the way thanks for all the help guys,my world lacks most of the planned content but already the players are very happy. I am about to do a massive update to complete the crafting stations and resources and the first of several quests are going into the game.

If Gryphon still lurks could you assist and devising a good approach to removing out of date items from vendors, BUT not remove the basic gear they get?

Thanks everyone. NWN FOREVER! BIOWARE RULES!
Back to top
View user's profile Send private message
fgetce



Joined: 04 Jun 2006
Posts: 23

PostPosted: Mon Dec 18, 2006 21:58    Post subject: Reply with quote

I had looked around a bit before posting and never did find this post about iExpiration explained. So I can use the columns "expire" and "last" from the PWData table with the following altered statement for cleanup.


sql='delete from vendor_stock where expire <> 0 AND
UNIX_TIMESTAMP(last)+(expire*24*60*60) < UNIX_TIMESTAMP(now())';

Question now is what exactly does (expire*24*60*60) equal to?

I would like for vendors to remove items form their stock that are more than a week to 10 days old, to keep them relatively clean of junk loot.

Also I want them to restock the vendors with their base gear which would be only those items that have expire=0. So at some time they must first remove items with expire=0 than reinsert the same items (to make sure they have correct amount).

Should that be a script run from within the game or should I set it as a auto job from outside the game, like a cron job?
Back to top
View user's profile Send private message
Grinning Fool



Joined: 12 Feb 2005
Posts: 264

PostPosted: Mon Dec 18, 2006 22:39    Post subject: Reply with quote

The timestamp datatype stores time in seconds -- so 24*60*60 = 1 day (24 hours * 60 minutes * 60 seconds)
_________________
Khalidine, a NWN2 persistent world

Looking for volunteers.
Back to top
View user's profile Send private message
Gryphyn



Joined: 20 Jan 2005
Posts: 431

PostPosted: Mon Dec 18, 2006 22:56    Post subject: Re: Auto expire records Reply with quote

fgetce wrote:
I am using Gryphons wonderful vendor system which I love and the players really love.

However they are beginning to clog up the stock of the vendors with their loot and I am looking for a way to auto purge items that are older than a specific time frame.

My approach was to add a column called "expires" and make it a time stamp. At certain intervals I will execute a scrip that will "delete from vendor_Stock where expires < UNIX_TIMESTAMP(now)"

Has anyone tackled this problem of over stocked vendors?

By the way thanks for all the help guys,my world lacks most of the planned content but already the players are very happy. I am about to do a massive update to complete the crafting stations and resources and the first of several quests are going into the game.

If Gryphon still lurks could you assist and devising a good approach to removing out of date items from vendors, BUT not remove the basic gear they get?

Thanks everyone. NWN FOREVER! BIOWARE RULES!


fgetce,

Sorry, I've been around but must have missed this post.

I'll be looking into this over the Xmas break. (for NWN2)

My Initial thoughts were to add a DM conversation branch (DM's get special options) that would buy-out a vendors inventory - and pay the appropriate players. To aid this I was also going to provide a cap on the number of any given item a player could 'dump' on a vendor at a time.

The basic gear stuff could be another DM conversation. This one running a script that creates the items on the vendor. (DM's don't need the gold but then the players don't need to know who sold the items)

*not a big fan of time-based disposal, it breaks the data relationships and you can end up with missing records that should be there or orphaned records that you can't get rid of. Never what you were intending.

Cheers
Gryphyn
Back to top
View user's profile Send private message
Grumalg



Joined: 04 Nov 2005
Posts: 70

PostPosted: Mon Dec 18, 2006 23:30    Post subject: Reply with quote

I've never looked at Gryphon's system to be sure this would apply, but you might want to look at what triggers can do. You can set them up to fire before or after such events as INSERT, UPDATE, etc. Triggers can do conditional execution of SQL statements. Since they exist and run in the database they wouldn't represent any load on NWN as they did their action(s).

--- Grumalg ---
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group