![]() |
item database query
so, I have made an item database, however I don't know how to do it now. Here's how it works so far
It creates an arc file, and adds the contents of that arc file to a database. HTML Code:
1003.AmmoLimit=9999However, would this cause any lag? I can simply do from another NPC HTML Code:
[Control].id.AmmoLimitHowever, I could also make each item have it's own line, to control that data. However, each time I would want to check something, I'd need to look inside the array Here's what I mean HTML Code:
1003 = { {"AmmoLimit", 9999}, {"AmmoName", "Uzi"}, {"ClipAmount", 32}};HTML Code:
getData(id, name) { |
I always find txt files (or whatever you want to call them) to be safer and thus better. The lag from loadlines and such would just be HD lag which Graal usually never experiances on the NPCServer so I really wouldn't worry about it. If you were to store all your data in a DB npc, not only do you have to worry about some idiot reseting the npc, but if the npcserver ever goes down, your data in those npcs might rollback.
|
Ew @ variable-names as pure numbers. It's not compatible in most languages... It might work on Graal though. VERY bad habit to pick up... Better leave it where you found it. On the other hand... mud_[id] would be a better variable name. Otherwise, it's alright.
I would advise you to make a function to obtain the variables through a function ( So some wise-person doesn't just go and change them ). By pretending they are protected information, you would define a function such as this: public function "getMudProp( mudID, prop ) return this.(@ mudID ).(@ propName ); This would prevent people from knowing where the data is... It would also provide an interface to work with. The benefits of this method is that when you change the internal workings of the item, the integrity of the server remains safe ( you modify the code in one place ). It also gives you some assurance you won't mistakenly change the data. It also permits you to debug it much more effectively later on... Or do some testing on it ( efficiency-wise ). It also gives you a concise abstract 'contract' with the DB-NPC: You know, just by the function name, what are you getting exactly. EDIT: I don't know the difference in speed between the both methods, but as stated above, do use a function. |
If you really want to know, test both methods by using a timeout. Have a script start a timeout, do some stuff (probably quite a bit of stuff) using the first method, and then save the value of the timeout to a variable/echo it/whatever. Then do the same with the second method (of course, make sure that the stuff done with the second method is the same as for the first).
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
Got ya, thanks. I just thought that doing a loop serverside for each prop would cause some some problems |
| All times are GMT +2. The time now is 12:46 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.