Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-11-2009, 09:57 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Tigairius View Post
There is, but scheduled events are cancelled when the npcserver restarts, so it would be better to use a sleep or a timeout which is not interrupted by the npcserver.
Timeouts are reset each time the weapon is updated, right? Is there any way to prevent this, or would I have to create a separate weapon for the timeout?
Quote:
Originally Posted by Loriel View Post
This is retarded, just do nothing until a player actually enters the shop and then calculate how much restocking you have to do.
That would defeat the purpose. I don't want the shops to have an endless stock of items at all times. I want a static amount of items each 24 hours; more specific, I want to make sure that there's nothing out of stock after 24 hours. Calculating when 24 hours has passed based on players entering the level seems overly complicated, especially since no facet of the system is used in level NPCs.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan

Last edited by LoneAngelIbesu; 05-11-2009 at 10:17 PM..
Reply With Quote
  #2  
Old 05-11-2009, 10:17 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by LoneAngelIbesu View Post
Timeouts are reset each time the weapon is updated, right? Is there any way to prevent this, or would I have to create a separate weapon for the timeout?
There's not really a way to prevent that, but loriel gives a good suggestion.

Quote:
Originally Posted by LoneAngelIbesu View Post
That would defeat the purpose. I don't want the shops to have an endless stock of items at all times.
I think what Loriel means is, save a timevar2 each time the shop is restocked, then each time someone enters the shop, subtract the saved timevar2 from the current timevar2, if it's > 86400 (24 hours), then divide the result by 86400 and it will give you how many days have passed since the last restock. Then you can stock based on that data. It's probably the best way to approach it.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 05-11-2009, 10:34 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Tigairius View Post
I think what Loriel means is, save a timevar2 each time the shop is restocked, then each time someone enters the shop, subtract the saved timevar2 from the current timevar2, if it's > 86400 (24 hours), then divide the result by 86400 and it will give you how many days have passed since the last restock. Then you can stock based on that data. It's probably the best way to approach it.
Or you can just do serverr.restocktime = timevar2 + 86400 then if (timevar2 >= serverr.restocktime) restock().
__________________
Reply With Quote
  #4  
Old 05-11-2009, 11:07 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
Or you can just do serverr.restocktime = timevar2 + 86400 then if (timevar2 >= serverr.restocktime) restock().
That's what I'd do, but I'd save it in a 'server.' var; no need to send it to all the players (not a big deal here, but it's a good idea to encourage people not to use serverr when not needed).

EDIT: To be honest, I'd probably use a database NPC.
__________________
Reply With Quote
  #5  
Old 05-12-2009, 12:46 AM
DarkReaper0 DarkReaper0 is offline
No.
DarkReaper0's Avatar
Join Date: May 2005
Location: Texas,USA
Posts: 344
DarkReaper0 will become famous soon enough
Send a message via MSN to DarkReaper0
Quote:
Originally Posted by cbk1994 View Post
EDIT: To be honest, I'd probably use a database NPC.
This.

But I'd use the database NPC for a variety of different shop functions like keeping inventory or whatever.

Because if you just use it to time it's a waste of resources, and that makes Scripters want to beat you upside the head with a Pipe Wrench.
Reply With Quote
  #6  
Old 05-12-2009, 01:26 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Inverness View Post
Or you can just do serverr.restocktime = timevar2 + 86400 then if (timevar2 >= serverr.restocktime) restock().
Yeah, that's basically just a different way to do what I just said.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.