AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [INC] SQLVault (https://forums.alliedmods.net/showthread.php?t=146849)

Exolent[jNr] 07-02-2012 16:54

Re: [INC] SQLVault
 
Quote:

Originally Posted by funfel (Post 1741480)
If I write "`key2` = 'level'" in sqlv_read_set_ex, sqlv_read_set_ex returns a value for key2 (level) in variable eVaultData[ i ][ SQLVEx_Data ]?

Yes.

funfel 07-02-2012 18:37

Re: [INC] SQLVault
 
Ok, thanks, and It returns in string? Or If key2 is num, I receive num? If key2 is float, I receive float? Sorry for dumbish question but I am newbie :(

Exolent[jNr] 07-02-2012 18:37

Re: [INC] SQLVault
 
It will always return as a string, regardless if you set as num, float, etc.

funfel 07-03-2012 09:54

Re: [INC] SQLVault
 
Problems never die :/ sqlv_read_set_ex works only in last problem (with this "level"), but here it doesnt works (1st place with 600$, second with 1500$, thrid place with 1000$, etc.), so I tried to do Top by sqlv_read_ex, here is the code:

Code:

case _motd_MONEY:
        {
            iLen += formatex( sText[ iLen ], sizeof( sText ) - iLen - 1, "<tr style=^"color:white;background:#0e0e0e;^"><td>#</td><td class=^"l^">Nick</td><td>Cala kasa</td></tr>" );
           
            new iMoney;
           
            for( new i = 0; i < 10; i++ )
            {
                sqlv_read_ex( g_hVault, i, sKey1, sizeof( sKey1 ) - 1, "", 0, sData, sizeof( sData ) - 1, iTimeStamp, "`key2` = 'totalmoney'", "`data` DESC" );
               
                sqlv_get_data_ex( g_hVault, sKey1, "name", sData, sizeof( sData ) - 1 );
                iMoney = sqlv_get_num_ex( g_hVault, sKey1, "totalmoney" );
               
                iLen += formatex( sText[ iLen ], sizeof( sText ) - iLen - 1, "<tr><td>%d</td><td class=^"l^">%s</td><td>%d</td></tr>", i + 1, sData, iMoney );
            }
           
            iLen += formatex( sText[ iLen ], sizeof( sText ) - iLen - 1, "</table></center></body>" );
           
            show_motd( id, sText, "Top10 graczy w calej kasie" );
        }

I cleaned table with "totalmoney", and I with my friend added money for us (500 for me, 1500 for him - for sure we changed map a few times, did much reconnects, and problem is still the same - srsly I dont know what is wrong...

SCREEN:[IMG]http://img855.**************/img855/2286/76823298.png[/IMG] [IMG]http://img854.**************/img854/846/91574257.png[/IMG]

(If I am onerous, I can create a new thread)

Exolent[jNr] 07-03-2012 10:17

Re: [INC] SQLVault
 
Change your sort clause to this (might not work for local databases since SQLite has quirks):

CONVERT(`data`, DECIMAL) DESC

EDIT:

CAST(`data` AS DECIMAL) DESC

That works for both MySQL and SQLite, so you should just use that one.

funfel 07-03-2012 11:57

Re: [INC] SQLVault
 
Now is:
Code:

sqlv_read_set_ex( g_hVault, eVaultMoney, sizeof( eVaultMoney ), _, "`key2` = 'totalmoney'", "CAST(`data` AS DECIMAL) DESC" );
And sometimes all are okey, but sometimes for all places name is empty and money are 0, and sometimes top looks like this old (with didnt sort data)



EDIT: These empty names and money are rare, wrong sorted places too, so I am happy, I am satisfacted (I dont know if this word exists >.<).

Aooka 07-03-2012 17:13

Re: [INC] SQLVault
 
It's like nVault but i try it's better. More easier ! Thx

funfel 07-04-2012 20:04

Re: [INC] SQLVault
 
Next easy question to you Exolent - If i wanna delete all values (inserts) for key2 "XXX" I should do:
Code:

sqlv_remove_ex( hVault, "*", "XXX" )
? I am not sure, I read .inc much times and still I am not sure :D And this remove_ex will clear only table XXX from values?

Exolent[jNr] 07-05-2012 09:32

Re: [INC] SQLVault
 
Quote:

Originally Posted by funfel (Post 1742306)
Now is:
Code:

sqlv_read_set_ex( g_hVault, eVaultMoney, sizeof( eVaultMoney ), _, "`key2` = 'totalmoney'", "CAST(`data` AS DECIMAL) DESC" );
And sometimes all are okey, but sometimes for all places name is empty and money are 0, and sometimes top looks like this old (with didnt sort data)

EDIT: These empty names and money are rare, wrong sorted places too, so I am happy, I am satisfacted (I dont know if this word exists >.<).

Really interesting. If you could post your code so I could see how you are saving data, it might help debug it.

The word you were looking for is "satisfied"

Quote:

Originally Posted by funfel (Post 1743522)
Next easy question to you Exolent - If i wanna delete all values (inserts) for key2 "XXX" I should do:
Code:

sqlv_remove_ex( hVault, "*", "XXX" )
? I am not sure, I read .inc much times and still I am not sure :D And this remove_ex will clear only table XXX from values?

Yes.

EpicMonkey 07-24-2012 10:00

Re: [INC] SQLVault
 
Quote:

Originally Posted by Exolent[jNr] (Post 1683800)
Use the sqlv_read_set() and sort by value.

PHP Code:

sqlv_read_set(g_hVaulteVaultDatasizeof(eVaultData) - 1,_,_"desc"); 

you mean like this?


All times are GMT -4. The time now is 00:46.

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