![]() |
Creating a custom item system. I need a pointer.
Okay, so i'm learning SQLite (great guide, chris. cant wait to see the rest of it!)
Thing is, I want my item system to be able to have varying stats, such as a semi-random durability value. Can SQLite support this? or would I be better off with another system? Also, if i stick with SQLite, what are these security issues, and how should i go about preventing them? edit: Lastly, if it make any difference, I'm looking to be able to incorporate a bag size limit too. |
Any form is SQL is basically a table. The way you use it is what determines its capabilities (e.g. unique item properties).
The security issues with SQL (including other SQL variants like MySQL) are generally SQL injection. For example, if you had a table which stored a player's kills and deaths: PHP Code:
PHP Code:
Quote:
Quote:
PHP Code:
PHP Code:
Quote:
Fortunately it's easy to fix. Instead of: PHP Code:
PHP Code:
Essentially, Quote:
|
While making an SQL Item System has it's advantages:
- Simple backup of server items - Easy analysis your the server's items - Transactions If you don't have any experience with SQL you can end up doing very bad things particularly making inefficient tables and queries that will cause a significant performance loss compared to making a simple clientr flag based one. If you design your item system properly you should be able to "plug-in" an SQL back-end to it with ease. |
Quote:
|
Quote:
|
So best thing in my case would be to make a well-working clientr.-based system then worry about adding SQL to it later down the road? If that's the case then that works out perfectly. especially since I'm becoming increasingly more focused on having a server that's actually playable. I was just kind of concerned that I might not be able to do that whole plugging-in thing if i made it clientr.-based. It's great to know that I probably wont have to rescript the entire system =]
|
Quote:
In other words, if you're loading the values of an item, have a player function to handle that. If you ever switch to a SQL-based storage system, you can easily change the backend. This is what was done on Era Dev when SQL was announced with about 5 lines of extra code. |
Quote:
crap, I cant think of anything xP |
Basic item system (nothing MUD-related though):
class: player_itemfunctions PHP Code:
PHP Code:
player.addItem("Amazing Sword of Doom", 1); or findplayer("Jiroxys7").addItem("Broken Sword of Fail", 100); Which would add/set a flag like this in your player flags: clientr.item.Amazing Sword of Doom=1 |
To expand on what Jerret said, you will never access the data directly.
PHP Code:
PHP Code:
PHP Code:
|
If you are using SQL like that, isn't it laggy? (With alot of players...?)
|
Quote:
A quick example: PHP Code:
Quote:
|
Well i had got the basic clientr. thing working, but i've reached a problem where i cant seem to get the vars to set an existing param to a new param. Heres pretty much exactly what i'm currently stuck on. I dont think the formatting of this is right.
PHP Code:
(so for example, the helm goes in clientr.equips[0] so any given piece doesnt end up with multiple instances of itself in clientr.equips) then once i get that done, i'm definitely going to run into the issue of figuring out how to load the extra stat bonuses without needing to set empty parameters for every equip. Then finally, I also have the problem on where to even store the equipment data since i'm using variables instead of keeping them in readable docs or something. (currently i'm storing the equip data in inventory system itself. bad idea, i know. Though I was planning on storing it in a dbnpc. though something's telling me that's not the right thing to do either.) I'm kind of stuck in a rut here. Should I keep trying to get all of this stuff working through clientr.vars? It seems like all i would need to know to use SQLite is knowledge of how to store the info in the database (arcs?) and how to access the data through scripts instead of trying to re-sort all of the data i have now, tell the script what's what, and where it goes. Any suggestions? |
Oh woah- seems pretty fast. thank you
|
Quote:
|
Quote:
http://www.w3schools.com/sql/default.asp and using a dedicated npc for SQL requests: http://forums.graalonline.com/forums...ad.php?t=85256 and that's all there is to using GS2+SQL. |
| All times are GMT +2. The time now is 02:17 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.