Raised This Month: $ Target: $400
 0% 

Bank System Nvault/SQL Support


Post New Thread Reply   
 
Thread Tools Display Modes
sigerman
Senior Member
Join Date: Aug 2013
Location: Argentina, Bs.As.
Old 05-07-2022 , 19:46   Re: Bank System Nvault/SQL Support
Reply With Quote #61

Quote:
Originally Posted by Supremache View Post
I made small changes, also tested Mysql, Sqlite, Nvault and donation system and it works perfect
https://forums.alliedmods.net/showpo...6&postcount=56
Am I doing something wrong? I've been testing all this days, and with the first currency works fine, but with the second (crxranks_get_user_xp, crxranks_set_user_xp) It does not, I works as If It was the first currency , look at the code, I surely messed up something, sorry. BTW, the databases are saving fine now.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <nvault>
#include <sqlx>
#include <cromchat>

#define get_cash2(%1) crxranks_get_user_xp(%1)
#define set_cash2(%1,%2) crxranks_set_user_xp(%1, %2, CS_ARMOR_VESTHELM) 
#define get_cash(%1) cs_get_user_money(%1)
#define set_cash(%1,%2) cs_set_user_money(%1, %2) 
        
#if !defined client_disconnected
    #define client_disconnected client_disconnect
#endif

#if !defined MAX_PLAYERS
    
const MAX_PLAYERS 32
#endif

#if !defined MAX_MENU_LENGTH
    
const MAX_MENU_LENGTH 512
#endif

#if !defined MAX_NAME_LENGTH
    
const MAX_NAME_LENGTH 32
#endif

#if !defined MAX_AUTHID_LENGTH
    
const MAX_AUTHID_LENGTH 64
#endif

#if !defined MAX_IP_LENGTH
    
const MAX_IP_LENGTH 16
#endif
  
const MAX_QUERY_LENGTH 256;
const 
MAX_CASH_LENGTH 16;

new const 
g_iFile[ ] = "BankSystem.ini";
new const 
Version[ ] = "2.0";

enum _:SaveTypes
{
    
NICKNAME,
    
IP,
    
STEAMID
}

enum _:SaveMethods
{
    
Nvault,
    
MySQL,
    
SQLite
}

enum eSettings
{
    
PREFIX_CHATMAX_NAME_LENGTH ],
    
SQL_HOSTMAX_NAME_LENGTH ],
    
SQL_USERMAX_NAME_LENGTH ],
    
SQL_PASSMAX_NAME_LENGTH ],
    
SQL_DATABASEMAX_NAME_LENGTH ],
    
SQL_TABLEMAX_NAME_LENGTH ],
    
NVAULT_DATABASEMAX_NAME_LENGTH ],
    
USE_SQL,
    
SAVE_TYPE,
    
MAX_CASH,
    
MAX_CASH_SAVE,
    
MENU_DONATE_ACCESS,
    
MENU_RESET_ACCESS,
}

enum PlayerData
{
    
SaveInfoMAX_AUTHID_LENGTH ],
    
Bank,
    
Bank2,
    
Donate,
    
bool:BotOrHLTV
}

new 
g_iPlayerMAX_PLAYERS ][ PlayerData ],
    
g_iSettingseSettings ],
    
bool:g_bBankOptionMAX_PLAYERS ],
    
g_iFUserNameChanged,
    
Handle:g_SQLTuple,
    
g_szSQLErrorMAX_QUERY_LENGTH ],
    
g_iVault;

public 
plugin_init( ) 
{
    
register_plugin"Bank System"Version"Supremache" );
    
register_cvar"BankSystem"VersionFCVAR_SERVER FCVAR_SPONLY FCVAR_UNLOGGED );
    
    
register_clcmd"EnterAmount""@OnPlayerDonations" );
    
register_clcmd"DepositCash""@OnDepositCash" );
    
register_clcmd"TakeCash""@OnWithdrawCash" );
    
    
register_event"SayText""OnSayText""a""2=#Cstrike_Name_Change" )

    
ReadFile( );
    
    switch( 
g_iSettingsUSE_SQL ] )
    {
        case 
Nvault:
        {
            if ( ( 
g_iVault nvault_openg_iSettingsNVAULT_DATABASE ] ) ) == INVALID_HANDLE )
                
set_fail_state("BANK: Failed to open the vault.");
        }
        case 
MySQLSQLite
        {
            if( 
g_iSettingsUSE_SQL ] == SQLite )
                
SQL_SetAffinity"sqlite" );
                
            
g_SQLTuple SQL_MakeDbTupleg_iSettingsSQL_HOST ], g_iSettingsSQL_USER ], g_iSettingsSQL_PASS ], g_iSettingsSQL_DATABASE ] );
                
            new 
szQueryMAX_QUERY_LENGTH ], Handle:SQLConnectioniErrorCode;
            
SQLConnection SQL_Connectg_SQLTupleiErrorCodeg_szSQLErrorcharsmaxg_szSQLError ) );
                
            if( 
SQLConnection == Empty_Handle )
                
set_fail_stateg_szSQLError );
    
            
formatexszQuerycharsmaxszQuery ), "CREATE TABLE IF NOT EXISTS `%s` (`Player` VARCHAR(%i) NOT NULL,\
            `Cash` INT(%i) NOT NULL, `Cash2` INT(%i) NOT NULL, PRIMARY KEY(Player));"
g_iSettingsSQL_TABLE ], MAX_AUTHID_LENGTHMAX_CASH_LENGTHMAX_CASH_LENGTH );
            
            
RunQuerySQLConnectionszQueryg_szSQLErrorcharsmaxg_szSQLError ) );
        }
    }
}

public 
OnSayTextiMsgiDestinationiEntity )
{
    
g_iFUserNameChanged register_forward(FM_ClientUserInfoChanged"OnNameChange")
}

public 
OnNameChangeid )
{
    if( !
is_user_connectedid ) )
    {
        return;
    }

    new 
szNameMAX_NAME_LENGTH ]
    
get_user_nameidszNamecharsmaxszName ) )

    if( 
g_iSettingsSAVE_TYPE ] == NICKNAME )
    {
        
ReadDataid );
        
copyg_iPlayerid ][ SaveInfo ], charsmaxg_iPlayer[ ][ SaveInfo ] ), szName )

        if( 
g_iSettingsUSE_SQL ] != Nvault )
        {
            
ResetDataid )
        }

        
ReadDataidfalse );
    }

    
unregister_forwardFM_ClientUserInfoChangedg_iFUserNameChanged )
}

public 
client_connectid )
{
    if ( !( 
g_iPlayerid ][ BotOrHLTV ] = bool:( is_user_botid ) || is_user_hltvid ) ) ) )
    {
        
ResetDataid )
        
        switch( 
g_iSettingsSAVE_TYPE ] )
        {
            case 
NICKNAMEget_user_nameidg_iPlayerid ][ SaveInfo ], charsmaxg_iPlayer[ ][ SaveInfo ] ) )
            case 
IP:       get_user_ipidg_iPlayerid ][ SaveInfo ], charsmaxg_iPlayer[ ][ SaveInfo ]), )
            case 
STEAMID:  get_user_authididg_iPlayerid ][ SaveInfo ], charsmaxg_iPlayer[ ][ SaveInfo ] ) )
        }
        
        
ReadDataidfalse );
    }
}

public 
client_disconnectedid )
{
    if ( !
g_iPlayerid ][ BotOrHLTV ] )
    {
        
ReadDataid );
    }
}

@
BankMenuid )
{
    static 
szCommand16 ];
    
read_argv1szCommandcharsmaxszCommand ) )
    
    if( 
szCommand] )
        
g_bBankOptionid ] = true;
    else
        
g_bBankOptionid ] = false;

    new 
iMenu menu_create"\yBank System: \r[Protected]""@BankHandler" );
    
    
menu_additemiMenu"Deposit" );
    
menu_additemiMenu"Deposit All^n" );
    
menu_additemiMenu"Withdraw" );
    
menu_additemiMenu"Withdraw All^n" );
    
menu_additemiMenu"Bank balance" );
    
menu_additemiMenu"Donate" );
    
menu_additemiMenu"Reset Bank" );
    
    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED;
}

@
BankHandleridiMenuiItem 
{
    if( 
iItem != MENU_EXIT 
    {
        switch(
iItem
        {
            case 
0
            {
                
client_cmdid"messagemode DepositCash" );
                
set_hudmessage255255850.010.1820.56.00.050.05, -);
                
show_hudmessage(id" Type how much you want to deposit." );
            }
            case 
1: @OnDepositAllCashid );
            case 
2
            {
                
client_cmdid"messagemode TakeCash" );
                
set_hudmessage255255850.010.1820.56.00.050.05, -);
                
show_hudmessageid"Type how much you want to withdraw." );
            }
            case 
3: @OnWithdrawAllCashid );
            case 
4CC_SendMessageid"Your Cash is:^4 %d"g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] );
            case 
5: @DonateMenuid );
            case 
6: @ResetMenuid );
        }
    }
    
menu_destroyiMenu );
    return 
PLUGIN_HANDLED;
}

@
DonateMenuid )
{        
    if( ~
get_user_flagsid ) & g_iSettingsMENU_DONATE_ACCESS ] )
    {
        
CC_SendMessage(id"You don't have access to this command.");
        return 
PLUGIN_HANDLED;
    }
        
    new 
szPlayersMAX_PLAYERS ], iNumszIDMAX_PLAYERS ], szNameMAX_NAME_LENGTH ];
            
    new 
iMenu menu_create"Players List:""@DonateHandler" );
    
get_playersszPlayersiNum"ch" );
    
    for( new 
iPlayeriiNumi++ )
    {
        if( ( 
iPlayer szPlayers] ) != id )
        {
            
num_to_striPlayerszIDcharsmaxszID ) );
            
get_user_nameiPlayerszNamecharsmaxszName ) );
            
menu_additemiMenuszNameszID )
        }
    }
    
menu_displayidiMenu );
    return 
PLUGIN_HANDLED;
}

@
DonateHandleridiMenuiItem 
{
    if(
iItem != MENU_EXIT
    {
        new 
szData10 ], iUnused;
        
menu_item_getinfoiMenuiItemiUnusedszDatacharsmaxszData ), .callback iUnused )
        
        
g_iPlayerid ][ Donate ] = find_player"k"str_to_numszData ) ); 

        if ( ! 
g_iPlayerid ][ Donate ] )
        {
            
CC_SendMessageid,"This player does not exist." );
            return 
PLUGIN_HANDLED;
        }
        
        
client_cmd(id"messagemode EnterAmount");
        
        
set_hudmessage255255850.010.1820.56.00.050.05, -);
        
show_hudmessageid"Type how much you want to give." );
    }
    
menu_destroy(iMenu);
    return 
PLUGIN_HANDLED;
}

@
OnPlayerDonationsid )
{
    new 
szValueMAX_CASH_LENGTH ], szPlayerNameMAX_NAME_LENGTH ], szTargetNameMAX_NAME_LENGTH ];
    
read_argv1szValuecharsmaxszValue ) );
    
    new 
iValue str_to_numszValue ), iCash g_bBankOptionid ] ? get_cash2id ) : get_cashid ), iPlayer g_iPlayerid ][ Donate ]; 

    if( 
iCash iValue || iValue <= )
    {
        
CC_SendMessageid,"You do not have enough cash or invalid value." );
        return 
PLUGIN_CONTINUE;
    }
        
    
get_user_nameidszPlayerNamecharsmaxszPlayerName ) );
    
get_user_nameiPlayerszTargetNamecharsmaxszTargetName ) );
    
    if( 
g_bBankOptionid ] )
    {
        
set_cash2idiCash iValue )
        
set_cash2iPlayerg_bBankOptionid ] ? get_cash2iPlayer ) : get_cashiPlayer ) + iValue )
    }
    else
    {
        
set_cashidiCash iValue )
        
set_cashiPlayerg_bBankOptionid ] ? get_cash2iPlayer ) : get_cashiPlayer ) + iValue )
    }

    
CC_SendMessage(0,"Player^4 %s^1 donated^4 $%d^1 for^4 %s."szPlayerNameiValueszTargetName );
    
client_cmd(iPlayer"spk ^"items/9mmclip1.wav^"")
    
ReadDataid );
    
    return 
PLUGIN_HANDLED;


@
ResetMenuid )
{        
    if( ~
get_user_flagsid ) & g_iSettingsMENU_RESET_ACCESS ] )
    {
        
CC_SendMessage(id"You don't have access to this command.");
        return 
PLUGIN_HANDLED;
    }
        
    new 
szPlayersMAX_PLAYERS ], iNumszIDMAX_PLAYERS ], szNameMAX_NAME_LENGTH ];
            
    new 
iMenu menu_create"Players List:""@ResetHandler" );
    
get_playersszPlayersiNum"ch" );
    
    for( new 
iPlayeriiNumi++ )
    {
        if( ( 
iPlayer szPlayers] ) != id )
        {
            
num_to_striPlayerszIDcharsmaxszID ) );
            
get_user_nameiPlayerszNamecharsmaxszName ) );
            
menu_additemiMenuszNameszID )
        }
    }
    
menu_displayidiMenu );
    return 
PLUGIN_HANDLED;
}

@
ResetHandleridiMenuiItem 
{
    if(
iItem != MENU_EXIT
    {
        new 
szData10 ], iUnusedszPlayerNameMAX_NAME_LENGTH ], szTargetNameMAX_NAME_LENGTH ];
        
menu_item_getinfoiMenuiItemiUnusedszDatacharsmaxszData ), .callback iUnused )
        
        new 
iPlayer find_player"k"str_to_numszData ) ); 
        
        if( !
iPlayer )
        {
            
CC_SendMessageid,"This player does not exist." );
            return 
PLUGIN_HANDLED;
        }
        
        
get_user_nameidszPlayerNamecharsmaxszPlayerName ) );
        
get_user_nameiPlayerszTargetNamecharsmaxszTargetName ) );
    
        
g_iPlayeriPlayer ][ g_bBankOptionid ] ? Bank2 Bank ] = 0;
        
CC_SendMessage0,"[ADMIN]^4 %s:^1 reset bank of^4 %s."szPlayerNameszTargetName );
        
ReadDataid );
    }
    
menu_destroy(iMenu);
    return 
PLUGIN_HANDLED;
}

@
OnDepositAllCashid 
{
    new 
iCash clampg_bBankOptionid ] ? get_cash2id ) : get_cashid ), 0g_iSettingsMAX_CASH_SAVE ] );
    
    if( 
iCash <= 0)
    {
        
CC_SendMessage(id,"You do not have enough cash or invalid value.");
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] > g_iSettingsMAX_CASH_SAVE ] )
    {
        
CC_SendMessageid,"Your bank is full." );
        return 
PLUGIN_CONTINUE;
    }

    
g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] += iCash;
    if( 
g_bBankOptionid ] )
        
set_cash2(idiCash get_cash2id ) );
    else
        
set_cash(idiCash get_cashid ) );
            
    
CC_SendMessageid,"You have deposit^4 %i"iCash );
    
ReadDataid );
    return 
PLUGIN_HANDLED;
}

@
OnWithdrawAllCashid )
{
    new 
iCash g_bBankOptionid ] ? get_cash2id ) : get_cashid );
    
    if( 
g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] <= )
    {
        
CC_SendMessage(id,"You do not have enough cash or invalid value.");
        return 
PLUGIN_CONTINUE;
    }
    
    new 
iMax maxiCashg_iSettingsMAX_CASH ] );
    
    if( 
g_iSettingsMAX_CASH ] && g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] > iMax )
    {
        if( 
g_bBankOptionid ] )
            
set_cash2(idiCash iMax );
        else
            
set_cash(idiCash iMax );
            
        
g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] -= iMax;
        
CC_SendMessageid,"You have withdraw^4 %i"iMax );
    }
    else
    {
        
CC_SendMessageid,"You have withdraw^4 %i"g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] );
        if( 
g_bBankOptionid ] )
            
set_cash2idiCash g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] );
        else
            
set_cashidiCash g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] );
            
        
g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] = 0;
    }
    
    
ReadDataid );

    return 
PLUGIN_HANDLED;
}

@
OnDepositCashid 
{
    new 
szValueMAX_CASH_LENGTH ];
    
read_argv1szValuecharsmaxszValue ) );
    new 
iValue clampstr_to_numszValue ), 0g_iSettingsMAX_CASH_SAVE ] ), iCash =  g_bBankOptionid ] ? get_cash2id ) : get_cashid );
    
    if( 
iCash iValue || iValue <= 0)
    {
        
CC_SendMessage(id,"You do not have enough cash or invalid value.");
        return 
PLUGIN_CONTINUE;
    }

    if( 
g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] > g_iSettingsMAX_CASH_SAVE ] )
    {
        
CC_SendMessageid,"Your bank is full." );
        return 
PLUGIN_CONTINUE;
    }
    
    
g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] += iValue;
    if( 
g_bBankOptionid ] )
        
set_cash2idiCash iValue );
    else
        
set_cashidiCash iValue );

    
CC_SendMessage(id,"You have deposit^4 %i"iValue );
    
ReadDataid );
    
    return 
PLUGIN_HANDLED;
}

@
OnWithdrawCashid )
{
    new 
szValueMAX_CASH_LENGTH ];
    
read_argv1szValuecharsmaxszValue ) );
    new 
iValue g_iSettingsMAX_CASH ] ? clampstr_to_numszValue ), 0g_iSettingsMAX_CASH ] ) : str_to_numszValue )
    new 
iCash g_bBankOptionid ] ? get_cash2id ) : get_cashid );
    
    if( 
g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] < iValue || iValue <= )
    {
        
CC_SendMessage(id,"You do not have enough cash or invalid value.");
        return 
PLUGIN_CONTINUE;
    }
    
    
g_iPlayerid ][ g_bBankOptionid ] ? Bank2 Bank ] -= iValue;
    if( 
g_bBankOptionid ] )
        
set_cash2idiCash iValue );
    else
        
set_cashidiCash iValue );

    
CC_SendMessageid,"You have withdraw^4 %i"iValue );
    
ReadDataid );
    
    return 
PLUGIN_HANDLED;
}

ReadFile( )
{
    new 
szConfings128 ], szFile128 ];
    
get_configsdirszConfingscharsmaxszConfings ) )
    
formatexszFilecharsmaxszFile ), "%s/%s"szConfingsg_iFile );
    
    new 
iFile fopenszFile"rt" );
    
    if( 
iFile )
    {
        new 
szData256 ], szKey32 ], szValue128 ];
            
        while( 
fgetsiFileszDatacharsmaxszData ) ) )
        {
            
trimszData );
            
            switch( 
szData] )
            {
                case 
EOS'#'';''/''[': continue;
                default:
                {
                    
strtokszDataszKeycharsmaxszKey ), szValuecharsmaxszValue ), '=' );
                    
trimszKey ); trimszValue );
                            
                    if( !
szValue] || !szKey] )
                        continue;
                        
                    if( 
equalszKey"BANK_MENU" ) )
                    {
                        while( 
szValue] != && strtokszValueszKeycharsmaxszKey ), szValuecharsmaxszValue ), ',' ) )
                        {
                            
trimszKey ); trimszValue );
                            
register_clcmdszKey"@BankMenu" );
                        }
                    }
                    else if( 
equalszKey"PREFIX_CHAT" ) )
                    {
                        
copyg_iSettingsPREFIX_CHAT ], charsmaxg_iSettingsPREFIX_CHAT ] ), szValue );
                    }
                    else if(
equal(szKey"SQL_HOST"))
                    {
                        
copyg_iSettings[SQL_HOST], charsmaxg_iSettings[SQL_HOST] ), szValue );
                    }
                    else if(
equal(szKey"SQL_USER"))
                    {
                        
copyg_iSettingsSQL_USER ], charsmaxg_iSettingsSQL_USER ] ), szValue );
                    }
                    else if(
equal(szKey"SQL_PASS"))
                    {
                        
copyg_iSettingsSQL_PASS ], charsmaxg_iSettingsSQL_PASS ] ), szValue );
                    }
                    else if(
equal(szKey"SQL_DATABASE"))
                    {
                        
copyg_iSettingsSQL_DATABASE ], charsmaxg_iSettingsSQL_DATABASE ] ), szValue );
                    }
                    else if(
equal(szKey"SQL_TABLE"))
                    {
                        
copyg_iSettingsSQL_TABLE ], charsmaxg_iSettingsSQL_TABLE ] ), szValue );
                    }
                    else if(
equal(szKey"NVAULT_DATABASE"))
                    {
                        
copyg_iSettingsNVAULT_DATABASE ], charsmaxg_iSettingsNVAULT_DATABASE ] ), szValue );
                    }
                    else if( 
equal(szKey"SAVE_METHOD") )
                    {
                        
g_iSettingsUSE_SQL ] = clampstr_to_numszValue ), NvaultSQLite );
                    }
                    else if( 
equalszKey"SAVE_TYPE" ) )
                    {
                        
g_iSettingsSAVE_TYPE ] = clampstr_to_numszValue ), NICKNAMESTEAMID );
                    }
                    else if( 
equalszKey"MAX_CASH" ) )
                    {
                        
g_iSettingsMAX_CASH ] = str_to_numszValue );
                    }
                    else if( 
equalszKey"MAX_CASH_SAVE" ) )
                    {
                        
g_iSettingsMAX_CASH_SAVE ] = str_to_numszValue );
                    }
                    else if( 
equalszKey"MENU_RESET_ACCESS" ) )
                    {
                        
g_iSettingsMENU_RESET_ACCESS ] = szValue] == '0' ADMIN_ALL read_flagsszValue );
                    }
                    else if( 
equalszKey"MENU_DONATE_ACCESS" ) )
                    {
                        
g_iSettingsMENU_DONATE_ACCESS ] = szValue] == '0' ADMIN_ALL read_flagsszValue );
                    }
                }
            }
        }
        
fcloseiFile )
    }
    else 
log_amx"File %s does not exists"szFile )
    
    
CC_SetPrefixg_iSettingsPREFIX_CHAT ] );
}

ReadDataidbool:bSave true )
{
    new 
szQueryMAX_QUERY_LENGTH ], szValueMAX_CASH_LENGTH ];

    if( 
bSave )
    {
        switch( 
g_iSettingsUSE_SQL ] )
        {
            case 
Nvault:
            {
                
formatexszValuecharsmaxszValue ), "%i %i"g_iPlayerid ][ Bank ], g_iPlayerid ][ Bank2 ] )
                
nvault_setg_iVaultg_iPlayerid ][ SaveInfo ], szValue );
            }
            case 
MySQLSQLite:
            {
                
formatexszQuery charsmaxszQuery ), "REPLACE INTO `%s` (`Player`,`Cash`,`Cash2`) VALUES ('%s','%i','%i');",\
                
g_iSettingsSQL_TABLE ], g_iPlayerid ][ SaveInfo ], g_iPlayerid ][ Bank ], g_iPlayerid ][ Bank2 ] );
                
SQL_ThreadQueryg_SQLTuple"QueryHandle"szQuery );
            }
        }
    }
    else
    {
        switch( 
g_iSettingsUSE_SQL ] )
        {
            case 
Nvault:
            {
                new 
szBankMAX_CASH_LENGTH ], szBank2MAX_CASH_LENGTH ];
                
nvault_getg_iVaultg_iPlayerid ][ SaveInfo ], szValuecharsmaxszValue ) );
                
parseszValueszBankcharsmaxszBank ), szBank2charsmaxszBank2 ) )
                
g_iPlayerid ][ Bank ] = str_to_numszBank )
                
g_iPlayerid ][ Bank2 ] = str_to_numszBank2 )
            }
            case 
MySQLSQLite:
            {
                
formatexszQuery charsmaxszQuery ), "SELECT * FROM `%s` WHERE Player = '%s';",\
                
g_iSettingsSQL_TABLE ], g_iPlayerid ][ SaveInfo ] );
                new 
szData]; szData] = id
                SQL_ThreadQuery
g_SQLTuple"QueryHandle"szQueryszDatasizeofszData ) );
            }
        }
    }
}

RunQueryHandle:SQLConnection, const szQuery[ ], szSQLError[ ], iErrLen )
{
    new 
Handle:iQuery SQL_PrepareQuerySQLConnection szQuery );
    
    if( !
SQL_ExecuteiQuery ) )
    {
        
SQL_QueryErroriQueryszSQLErroriErrLen );
        
set_fail_stateszSQLError );
    }
    
    
SQL_FreeHandleiQuery );
}

public 
QueryHandleiFailStateHandle:iQuery, const szError[ ], iErrCode, const szData[ ], iDataSize )
{
    switch( 
iFailState )
    {
        case 
TQUERY_CONNECT_FAILED: { log_amx"[SQL Error] Connection failed (%i): %s"iErrCodeszError ); return; }
        case 
TQUERY_QUERY_FAILED: { log_amx"[SQL Error] Query failed (%i): %s"iErrCodeszError ); return; }
    }
    
    static 
idid szData];
    if( 
SQL_NumResultsiQuery ) )
    {
        
g_iPlayerid ][ Bank ] = SQL_ReadResultiQuery SQL_FieldNameToNumiQuery"Cash" ) );
        
g_iPlayerid ][ Bank2 ] = SQL_ReadResultiQuery SQL_FieldNameToNumiQuery"Cash2" ) );
    }


ResetData( const id )
{
    
g_iPlayerid ][ Bank ] = 0;
    
g_iPlayerid ][ Bank2 ] = 0;
    
g_iPlayerid ][ Donate ] = 0;
    
g_iPlayerid ][ BotOrHLTV ] = false;
}

public 
plugin_natives( )
{
    
register_library("Bank");
    
register_native("get_user_bank""_get_user_bank")
    
register_native("set_user_bank""_set_user_bank")
    
register_native("get_user_bank2""_get_user_bank2")
    
register_native("set_user_bank2""_set_user_bank2")
}

public 
_get_user_bank2iPlugin iParams )
{
    return 
g_iPlayerget_param) ][ Bank2 ]
}

public 
_set_user_bank2iPlugin iParams )
{
    new 
id get_param)
    
g_iPlayerid ][ Bank2 ] = get_param);
    
ReadDataid );
}

public 
_get_user_bankiPlugin iParams )
{
    return 
g_iPlayerget_param) ][ Bank ]
}

public 
_set_user_bankiPlugin iParams )
{
    new 
id get_param)
    
g_iPlayerid ][ Bank ] = get_param);
    
ReadDataid );
}


public 
plugin_end( )
{
    if( 
g_iSettingsUSE_SQL ] )
    {
        
SQL_FreeHandleg_SQLTuple );
    }
    else
    {
        
nvault_closeg_iVault );
    }

sigerman is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-07-2022 , 20:35   Re: Bank System Nvault/SQL Support
Reply With Quote #62

Replace this:

PHP Code:
#define get_cash2(%1) crxranks_get_user_xp(%1)
#define set_cash2(%1,%2) crxranks_set_user_xp(%1, %2, CS_ARMOR_VESTHELM) 

PHP Code:
#define get_cash2(%1) crxranks_get_user_xp(%1)
#define set_cash2(%1,%2) crxranks_set_user_xp(%1, %2) // It should be set as default for "CRXRANKS_XPS_PLUGIN" 
Also be sure you have added the command of second bank menu, also you can change it to "/bankxp" so you must write the word "bank" and then you can write whatever you want like "/bankmoney", "/banklevel", "bankpoint" etc..
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Old 05-10-2022, 17:59
sigerman
This message has been deleted by sigerman. Reason: Still testing, sorry
sigerman
Senior Member
Join Date: Aug 2013
Location: Argentina, Bs.As.
Old 05-12-2022 , 12:58   Re: Bank System Nvault/SQL Support
Reply With Quote #63

Everything works fine except a thing with the table in mysql, the data is saved into the database, but when you change the map or server restart, It seems that one of the currencies cannot retreive the data of the database, so the server says $0 but the database has money saved. The other currency seems to work fine I believe.

Sorry for the delay I was testing as much as I can before posting.

Last edited by sigerman; 05-12-2022 at 13:00. Reason: Clarifying
sigerman is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-13-2022 , 07:16   Re: Bank System Nvault/SQL Support
Reply With Quote #64

Quote:
Originally Posted by sigerman View Post
Everything works fine except a thing with the table in mysql, the data is saved into the database, but when you change the map or server restart, It seems that one of the currencies cannot retreive the data of the database, so the server says $0 but the database has money saved. The other currency seems to work fine I believe.

Sorry for the delay I was testing as much as I can before posting.
I tested it and it works fine.
I changed the map and tried restarting the server and also tried shutting down and reopening the server and the data was loaded.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
sigerman
Senior Member
Join Date: Aug 2013
Location: Argentina, Bs.As.
Old 05-26-2022 , 01:24   Re: Bank System Nvault/SQL Support
Reply With Quote #65

Sorry that I did not answer yet, I did not have much time, It seems that I have something installed that is interfering with your plugin, I will try to find out. Your work is impressive, i'll be grateful to donate you some dollars, It is not much, argentina has low money value, but It is worth for a beer. Thank you.
sigerman is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-29-2022 , 11:26   Re: Bank System Nvault/SQL Support
Reply With Quote #66

You're welcome and save your money.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Theme made by Freecode