MySQL Data Layer
I'm not really sure if Scripting Help is the best place for this, but here goes.
This thread will be more like a discussion than actual scripting help. As the mod I'm working on (the one in my sig, CSRP) will have MANY sub-modules and will communicate with the database A LOT, I decided it's stupid to let each subplugin/submodule handle the database in their own way. I'm trying to create a complex class system to handle the data of the database easily, while the core plugin takes care of all the hard work. An example of some natives it should have: PHP Code:
PHP Code:
Code:
key SMALLINT(5) UNSIGNED - since it's a player class, this will hold the unique player indexSo far I know how to do that, no worries. However the problem happens when we talk about loading the actual data. How would I want to do that technically? First, I thought about loading the entire table into memory. Trie for each row. Then I realized that's a terribad idea. I'm now deciding on this: If the class is a player class (i.e. it holds data for each player), the player's data should be loaded on connect and saved and destroyed on disconnect. That seems reasonable and I think I'll stick with that, but what about non-player classes? For example a class that holds the list of all the items available for players to buy. These data need to be accessible all the time; should I just load them all on the class initialization and save/destroy them on mapchange, like I first wanted to? Or do you have a better idea? Also, HOW would you store data from a table? The player index doesn't necessarily have to be unique. For example, if the class would be a player inventory class with the following columns: Code:
key SMALLINT(5) UNSIGNEDCode:
+-----+------------------+--------+Code:
ArrayLet me know what you think about my whole design, I need to get this done ASAP. |
Re: MySQL Data Layer
well here's the deal, I have far from enough knowledge to actually talk about subjects like these, but you could "inspire" yourself from sa-mp rpg gamemodes. They are also written in PAWN and there's basically no difference except event handling and functions, and those scripts are designed to handle big amounts of player info, most of the newer ones using sql.
|
Re: MySQL Data Layer
Eh. The ones I looked at had around 50 thousand lines of terrible code. I don't think I can find anything useful there anyway.
An example using my method: Players - 30 Opened classes - for example 10 Each class has 4 columns Each column has a name consisting of 16 characters Each player has let's say 30 rows in each of the classes (probably won't ever happen, but still) Maxlen of each string from the trie hashtable would be 128 characters All in all, that's 30 * 10 * 4 * 16 * 30 * 128 = 73,728,000 cells A single cell is 4 or 8 bytes, let's go with 4, that's 294,912,000 bytes = 295MB of memory. There must be a better way :( |
Re: MySQL Data Layer
Quote:
but you can't call it terrible if it can handle 1000 players at once |
Re: MySQL Data Layer
I'm so stupid. Why do I event want to use Tries? I have direct access to the column index, so I can simply use a sub-array.
Code:
ArrayAny better ideas? Does anyone know if it matters that I'm going to create up to a thousand or more dynamic array handles? |
| All times are GMT -4. The time now is 09:48. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.