AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Saving data (https://forums.alliedmods.net/showthread.php?t=194801)

OvidiuS 08-31-2012 11:03

Saving data
 
Hi everyone ;)

I trying to avoid problems with data saving.

Plugin which i'm creating/rewriting will have around 20 classess + level system.
For each class i have to save:
Code:

Player exeprience | Point 1 | Point 2 | Point 3 | Point 4 | Player name
Data will be saved on steam id. Current nvault key is steam-classid

Server will have around 4000 players ( based on statsx top15 counter ).
4000 players, and let's say every player uses every possible class, that is around 80000 lines of data.

Main problem is that i don't have ability to use web sites/my sql bases, etc.
Everything must be stored on server.

Furthermore in future i'm planning to add top15 (probbably use this snippet if i decide for nvault - https://forums.alliedmods.net/showthread.php?t=184654 )

Currently i'm using nvault for data (without player name), and ini file for top15 rank which is loaded into array on every mapchange and sorted on every /top15 call (arraysort);
In ini file i save only the player class with highest level. One player, one line in file.

I searched a lot, and found out that war3 plugins use nvault for every class.
Is that better, instead of one vault?

Does anyone have any suggestions?

btw plugin which i'm rewriting is badly coded, and it crashes the server
http://forums.alliedmods.net/showthread.php?p=1406163

Infernuz 08-31-2012 16:18

Re: Saving data
 
Quote:

Main problem is that i don't have ability to use web sites/my sql bases, etc.
Everything must be stored on server.
Why can't you use MySQL bases? Your database will be stored localy and you can block outgoing traffic from MySQL completly, so it will only be avaliable on local machine.

If you don't have web(phpmyadmin) and can't modify SQL tables, you can use Navicat lite. Very easy and handy program. Free to use aswell.

Quote:

btw plugin which i'm rewriting is badly coded, and it crashes the server
Sorry, can't help you with that. I takes a lot of time and effort to create/modify huge projects.

=============================================
In my opinion it's best to use MySQL if you want to save a huge amount of data. It has a very wide ability to work with data. The main problem is that you'll have to learn commands and syntaxes. That's the hard part.

Nvault is basicly a prototype of MySQL and is quite tiny comparing to MySQL I think, but still, it's very effective. It's main purpose is to only save a get the data. It's very easy to use. Get, Store. Tnx bye.

Which is best to use, is up to you.

Im used to MySQL, so I can't tell you much about nVault since I only used it once.

OvidiuS 08-31-2012 16:44

Re: Saving data
 
Quote:

Originally Posted by Infernuz (Post 1788049)
Why can't you use MySQL bases? Your database will be stored localy and you can block outgoing traffic from MySQL completly, so it will only be avaliable on local machine.

If you don't have web(phpmyadmin) and can't modify SQL tables, you can use Navicat lite. Very easy and handy program. Free to use aswell.

I'm not hosting the server, it's hosted by hosting company. I don't have any web hosting, or web data storage which can be used for sql base.

Quote:

Originally Posted by Infernuz (Post 1788049)
Sorry, can't help you with that. I takes a lot of time and effort to create/modify huge projects.

I didn't asked for rewriting/writing plugin :crab:

Quote:

Originally Posted by Infernuz (Post 1788049)
In my opinion it's best to use MySQL if you want to save a huge amount of data. It has a very wide ability to work with data. The main problem is that you'll have to learn commands and syntaxes. That's the hard part.

Nvault is basicly a prototype of MySQL and is quite tiny comparing to MySQL I think, but still, it's very effective. It's main purpose is to only save a get the data. It's very easy to use. Get, Store. Tnx bye.

As i already said, data must be stored on game server.

Quote:

Originally Posted by Infernuz (Post 1788049)
Which is best to use, is up to you.
Im used to MySQL, so I can't tell you much about nVault since I only used it once.

I appreciate your help :)

Infernuz 08-31-2012 17:32

Re: Saving data
 
Well, if the hosting company don't provide MySQL database, then I dunno.

Btw, if I'm right, amxmodx have an inbuild SQL lite in their system. Thought I never used it, you might check it out aswell.

OvidiuS 08-31-2012 17:43

Re: Saving data
 
Quote:

Originally Posted by Infernuz (Post 1788091)
Well, if the hosting company don't provide MySQL database, then I dunno.

Btw, if I'm right, amxmodx have an inbuild SQL lite in their system. Thought I never used it, you might check it out aswell.

It's game hosting :)

Anyone willing to post simple sqllite load/save data with "double" key ( steamid-classid )??
I have never used SQL Lite, searched and found this http://forums.alliedmods.net/showthread.php?t=46779, but it's basic
and no data loading :S

Infernuz 08-31-2012 17:56

Re: Saving data
 
That's enought for you to start.

Gets data from table zomg where column you equals 1 or 4. As result you'll get whole row which you will have to handle
PHP Code:

SELECT FROM zomg WHERE you='1' OR you='4' 

This saves data to table zomg with values.. 1,2,3,4 where column_name is your name of columns.
PHP Code:

INSERT INTO zomg (column_name_1,column_name_2column_name_3column_name_4VALUES('1','2','3','4'

Not so hard.

claudiuhks 08-31-2012 17:57

Re: Saving data
 
PHP Code:

// modules.ini should contain the next line:
// sqlite
// and not the next one:
// mysql
 
#include < sqlx >
 
public plugin_precache( )
  
SQL_SetAffinity"sqlite" );
 
new 
Handlecg_iPoints33 ];
 
public 
plugin_init( ) {
  
SQL_MakeDbTuple"""""""FileName" ); // addons/amxmodx/data/FileName.sq3
 
  
SQL_ThreadQueryc"SQLEmpty""CREATE TABLE IF NOT EXISTS players ( steam VARCHAR ( 128 ), points INT ( 24 ) )" );
}
 
public 
client_putinserver) {
  static 
cLine512 ], cSteam32 ], cData32 ]; get_user_authidicSteam31 ); num_to_stricData31 );
  
formatexcLine511"SELECT points FROM players WHERE steam = '%s'"cSteam );
  
SQL_ThreadQueryc"SQLGetRank"cLinecData31 );
}
 
public 
SQLEmptyiFailStateHandleqcError[ ], iErrorCodecData[ ], iDataSize ) {
}
 
public 
SQLGetRankiFailStateHandleqcError[ ], iErrorCodecData[ ], iDataSize ) {
  if( 
SQL_NumResults) ) {
    
g_iPointsstr_to_numcData ) ] = SQL_ReadResultq);
  } else {
    static 
cLine512 ], cSteam32 ]; get_user_authidstr_to_numcData ), cSteam31 );
    
formatexcLine511"INSERT INTO players VALUES ( '%s', 0 )"cSteam );
    
SQL_ThreadQueryc"SQLEmpty"cLine ); g_iPointsstr_to_numcData ) ] = 0;
  }


Be carefull!

PHP Code:

// for numeric, use like:       SELECT * FROM players WHERE something = 1337
// for text, use like:       SELECT * FROM players WHERE something = 'ud92323d'
// for containi, use like:       SELECT * FROM players WHERE something LIKE '%included_part%'
// for systime, use like:       UPDATE players SET last_seen = unix_timestamp( now( ) ) WHERE steam = 'STEAM_0:0:36120359' 



All times are GMT -4. The time now is 08:20.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.