![]() |
NPC Restock - Printable Version +- SphereCommunity (https://forum.spherecommunity.net) +-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d) +--- Forum: General Help (/Forum-General-Help) +--- Thread: NPC Restock (/Thread-NPC-Restock) Pages: 1 2 |
NPC Restock - escribano - 07-19-2015 12:51 PM Dudes, me again... Now i am re-scripting the buy/sell packet to improve some features and help players to sell training itens. I've finished the script and it works very well, but i noticed a strange behavior happening in the layers of all vendors. This is what my script does: 1) Override the sphere base packets (0x9e and 0x9f) to give me full control of the buy/sell system. 2) When you sell a item to the npc, this item appears to sell (stored on layer 27, vendor extra) 3) If the NPC have no money, he cant buy your itens 4) When you buy a item on the npc, the gold is set on npc's layer 29 (bankbox) increasing the money of the npc so he can buy more itens next time 5) When a player try to sell a item that is not "groupable", for exemple any weapon, it shows to sell in group. So ok.. all this works very well, but if i leave the NPC in a area with no players, this NPC simply remove all the itens in layers: 26 (stock), layer 27 (vendor extra) and the money from layer 29 (bankbox)... WHY??? And there is nothing that i could made to make it work. I've opened all this layers and put itens inside to try to force the buy/sell list but immediatly when i close the box, it was erased and all itens is gone.... I've copied the uid from the itens and saved the world to try to find in the save file but no one uid was saved there... Someone pass through this before? Thanks! RE: NPC Restock - azmanomer - 07-19-2015 04:19 PM maybe sector sleep could make that.i dont know how to disable it but check it if you know ![]() RE: NPC Restock - Paulo_BR - 07-20-2015 03:59 AM Someone can help us? RE: NPC Restock - XuN - 07-20-2015 05:46 PM When restocking all vendor containers are emptied, default ones will be generated again by the system but custom ones will be lost. // Restock occurs every 10 minutes of inactivity (unless region tag specifies different time) So, to avoid this you can set region.tag.NoRestock=1. However this will make npcs to no restock their items and they will eventually lose them ... so you'll have to manually 'regenerate' these items. Best idea I can give you is to store the amount of each item in a tag after NPCRestock, something like this: Code: [function f_stock_tags_set] So you will be able to periodically call in that region a custom restock at the time you want. Code: [function f_stock_regenerate] So now you have a region not restocking the vendors inside and a function to store how much items of each one the vendor will have and another setting it back, you only need something timing from time to time calling region.allchars.f_stock_regenerate and you should have your problem solved. RE: NPC Restock - escribano - 07-21-2015 08:01 AM Thanks so much XuN!!! seriously, you are a genious! I'll make this and post the results as soon as possible! Thanks again! RE: NPC Restock - escribano - 07-21-2015 09:29 AM XuN, i didn't work... The itens are deleted on the "sphere default restock"... see this images: http://s23.postimg.org/vfzs01zqi/Captura_de_tela_2015_07_20_23_10_39.jpg http://s23.postimg.org/z25lcp63u/Captura_de_tela_2015_07_20_23_14_32.jpg At 23:10 the itens was inside the vendor on layer 26 (buy) and 28 (sell) At 23:14 all the itens is gone.... no error on console, no save, no resync, no nothing... With no itens, i can't change the amount.. i even tryied to make this funcion: Code: [FUNCTION f_restock_tag_set] On the restock stone i've made, when i set "restock 1" on the NPC this funcion run, (cuz if i use only "restocl" all itens was deleted too... i don't know why). When the player goes on the NPC to buy or sell and there is no layer on some layer, i checked the tags, to re-create the missing itens.. but it makes the shard REALLY slow. I don't know but i guess there is something wrong with restock in sphere... if the base function could run with the "1" argument the restock would be fixed ![]() OBS: I'm using the spehre nightly build 2387 and i notice this behavior abount 1 month ago... buy just declared as "error" this days.. Thanks for helping XuN! NOTE: With region.tag0.NoRestock=1 items do not disappear.. At least until now! XuN, yeah...so far, so goo! But to restock all NPCs the server is overloaded... so thinking better this may be a bad idea. There is a way to change the restock time? There is a way to set the "1" argument on default restock sphere code? There is a way to run "background" functions to sphere? Sorry for bothering! Thanks RE: NPC Restock - XuN - 07-22-2015 06:14 PM I never told you to use default restock, just that 'restock' custom function, and only region by region ... doing it world-wide is insane for a full spawned shard! You don't have to restock all npcs in the server, just region by region, create a memory item (or a repeating timerf) forcing ONE REGION to restock its npcs, so you'll end with like 10 timers at max depending on the amount of cities with vendors you have, that will decrease the impact a lot. Another idea is to do it for each vendor individually, intercept the 'buy' and 'sell' speechs on the vendors and create a memory on them which force restock when timing out and remove it, so it will not regenerate anything until the next time a shop command is being heard by them. RE: NPC Restock - escribano - 07-23-2015 12:55 AM Hummmm nice ideas XuN! Ill try this ones at night and o post the results later! And this other questions: There is a way to change the default restock time? There is a way to set the "1" argument on default restock sphere code? There is a way to run "background" functions to sphere? Thanks RE: NPC Restock - XuN - 07-24-2015 06:47 PM There's no way to change default restock time (actually). What does that '1' mean for restock? For background functions I always have the uid of my character in a def (a character that will NEVER be deleted), then in f_onserv_start I call some functions on that UID, that themselves again with a timerf, another way should be using the ini option for that (although is a little more static): // Amount of minutes to call f_onserver_timer (0 disables this, default) TimerCall=0 RE: NPC Restock - escribano - 07-25-2015 04:27 PM Thank again XuN! I mean when i use: ".xrestock" the npc wont restock, and all layers was deleted if i use "restock 1" the npc was restocked with no errors. |