Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Dynamic NPC Shop Script (v83)

Joined
Jan 3, 2009
Messages
17
Reaction score
4
Introduction
Hey guys. So I've been working on an NPC script that acts as a shop in lieu of the usual SQL-based shop...I didn't want to have to update that god forsaken table and restart the server every time I wanted to make a shop, so with a little tweaking of the server files I've created a shop that's completely based within an NPC script.

Features
So far, this shop only deals with equippable items. All you have to do is fill an array with the item IDs (and another one with the respective prices) and the shop will be created for you, replete with buttons, sounds, and the like.

The script gets the item information from the equip ID such as reqLevel, reqStr, reqDex, weapon attack, and whatever else.

You can buy items, mesos is taken from you, you get the item, all of that stuff.

In addition to the array of items to be sold in the shop, all the UI elements, sound elements, and messages are stored in variables at the top of the script for easy editing while keeping the main framework of the shop.

To Do
So far, you can only buy equipped items. Can't sell your own items yet.
This NPC only sells equips, will have to let it sell other things as well! Will need to make an NPC command to get an equipment's type.


Demonstration


Enjoy! Thanks for taking a look :).
 
Last edited:
Joined
Jan 18, 2010
Messages
3,109
Reaction score
1,139
Nice I guess.. but 200 lines vs query? You could just improve the way it loads the shops and reload it properly along with adding an easy way to insert an item if necessary. I like the design and effects of the shop though, especially when you buy the item 'cha-ching!' lmao

Oh, and totally off-topic.. But holy crap I loved watching your Cham World series yeaaars ago LOL. Oh, and I remember you specifically laughing at my grammar back on EricMS When I Typed Like This xD.
 
Joined
Jan 3, 2009
Messages
17
Reaction score
4
Nice I guess.. but 200 lines vs query? You could just improve the way it loads the shops and reload it properly along with adding an easy way to insert an item if necessary. I like the design and effects of the shop though, especially when you buy the item 'cha-ching!' lmao

Oh, and totally off-topic.. But holy crap I loved watching your Cham World series yeaaars ago LOL. Oh, and I remember you specifically laughing at my grammar back on EricMS When I Typed Like This xD.

Eric yeah you're right. Not the most structurally efficient way (200 lines of code to theoretically process vs a query, although practically it might not make a noticeable difference) but I love to customize and this lets you do that! :)

Also ahh dude thank you so much! Yeah life sort of caught up to me so I've had to put Maple animation aside xD. And hahaha you typed like that?! I don't remember that exactly but oh god I would've totally laughed at that. How brash of me to laugh at the creator of a server ON HIS SERVER like that , jeez. xD My bad!

I like the "UI" design, looks alot better than your standard ps npc shop.

Thanks!
 
Joined
Jul 12, 2011
Messages
1,229
Reaction score
475
Nice I guess.. but 200 lines vs query? You could just improve the way it loads the shops and reload it properly along with adding an easy way to insert an item if necessary. I like the design and effects of the shop though, especially when you buy the item 'cha-ching!' lmao

Oh, and totally off-topic.. But holy crap I loved watching your Cham World series yeaaars ago LOL. Oh, and I remember you specifically laughing at my grammar back on EricMS When I Typed Like This xD.

Huh? Querying will take much longer than reading 200 lines of code. You shouldn't measure efficiency like that
 
Joined
Jan 18, 2010
Messages
3,109
Reaction score
1,139
Huh? Querying will take much longer than reading 200 lines of code. You shouldn't measure efficiency like that

What do you mean, why will it take much longer? With only 3 lines of code you can call openShop and have it execute a SELECT statement to view the specific rows within 0.0003s and have it loaded, how long will it take to parse 200lines of code and maybe more depending on increased size of arrays or statements? Shouldn't it be faster to do query? Plus, it caches it into the shops so the next time you open it, it won't even execute a query, that's why you'd have to have commands to add/reset the shop info..
 
Joined
Jul 12, 2011
Messages
1,229
Reaction score
475
What do you mean, why will it take much longer? With only 3 lines of code you can call openShop and have it execute a SELECT statement to view the specific rows within 0.0003s and have it loaded, how long will it take to parse 200lines of code and maybe more depending on increased size of arrays or statements? Shouldn't it be faster to do query? Plus, it caches it into the shops so the next time you open it, it won't even execute a query, that's why you'd have to have commands to add/reset the shop info..

Hm yeah, I didn't think about cache. I guess it depends how the shop data is stored if it's done in the code (eg json, loaded in ram, etc.). Not sure which would be faster then, but either way, I think this is a premature optimization :p
 
Back
Top