Raised This Month: $ Target: $400
 0% 

nVault Tutorial


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-01-2022 , 00:57   Re: nVault Tutorial
Reply With Quote #121

Ok, then do not call nvault_prune(), just check if the timestamp is expired how you did above.

if iTS >= get_systime() - Item still valid/not expired
if iTS < get_systime() - Item expired
__________________
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2022 , 01:04   Re: nVault Tutorial
Reply With Quote #122

Well, i will test it.
Thanks
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2022 , 01:28   Re: nVault Tutorial
Reply With Quote #123

If I want to add more time, is this right

PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"say /buymoretime""MoreTime" )
}

public 
MoreTimeid // Buy Time for models menu
{
    if( 
cs_get_user_moneyid ) < g_szSkinsData][ Price ] || !( g_PlayerItemsid ] & ITEMS/* First Item */ ) ) )
    {
        return;
    }
    
    
cs_set_user_moneyidcs_get_user_moneyid ) - 10000 )
    
    
formatexszPlayerItemscharsmaxszPlayerItems ), "%i %i"g_PlayerItemsid ], g_WeaponItemsid ] )
    
nvault_setg_iVaultg_szSteamIDid ], szPlayerItems );
    
nvault_lookupg_iVaultg_szSteamIDid ], szVal charsmaxszVal ) , iTS )    
    
nvault_touchg_iVault g_szSteamIDid ] ,  iTS 1800 ); // 30 minutes
    
client_printidprint_chat"You have bought more time 30 minutes for first Item" )

__________________
Youtube.com/Supremache

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

Last edited by Supremache; 05-01-2022 at 02:06.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-01-2022 , 12:55   Re: nVault Tutorial
Reply With Quote #124

If the item is remaining the same, there's no need to call formatex()/nvault_set(), since all you need to do is update the timestamp on an existing record.
PHP Code:
public MoreTimeid // Buy Time for models menu
{
    if( 
cs_get_user_moneyid ) < g_szSkinsData][ Price ] || !( g_PlayerItemsid ] & ITEMS/* First Item */ ) ) )
    {
        return;
    }
    
    
cs_set_user_moneyidcs_get_user_moneyid ) - 10000 )
    
    
//formatex( szPlayerItems, charsmax( szPlayerItems ), "%i %i", g_PlayerItems[ id ], g_WeaponItems[ id ] )
    //nvault_set( g_iVault, g_szSteamID[ id ], szPlayerItems );
    
nvault_lookupg_iVaultg_szSteamIDid ], szVal charsmaxszVal ) , iTS )    
    
nvault_touchg_iVault g_szSteamIDid ] ,  iTS 1800 ); // 30 minutes
    
client_printidprint_chat"You have bought more time 30 minutes for first Item" )

__________________
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2022 , 16:33   Re: nVault Tutorial
Reply With Quote #125

alright , Thank you
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2022 , 19:52   Re: nVault Tutorial
Reply With Quote #126

Did not work, Time works for all items not for each item also when you disconnect from the server time does not stop.

__________________
Youtube.com/Supremache

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

Last edited by Supremache; 05-01-2022 at 19:54.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-01-2022 , 20:01   Re: nVault Tutorial
Reply With Quote #127

The logic I gave you will work, but the way you designed your plugin may need some adjustment to allow it to work.
__________________
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2022 , 20:28   Re: nVault Tutorial
Reply With Quote #128

Quote:
Originally Posted by Bugsy View Post
The logic I gave you will work, but the way you designed your plugin may need some adjustment to allow it to work.
Here is the plugin, can you do that
Attached Files
File Type: sma Get Plugin or Get Source (SkinShop.sma - 10 views - 8.2 KB)
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-01-2022 , 21:34   Re: nVault Tutorial
Reply With Quote #129

May be unrelated to your current issue but may cause other unexpected behavior.

In a few areas you are assuming a record will be found and that you'll have an iTS value to check. If a record is not found with nvault_lookup(), iTS will be 0. I recommend you add a check for iTS to ensure it's non-zero before comparing to systime (as 0 will always be < get_systime() and return true), or add an if-condition with nvault_lookup() as this returns true if a record was found, false if not -- if ( nvault_lookup(..) ) { }
Code:
        new iItemID = str_to_num( szData );        
        nvault_lookup( g_iVault, g_szSteamID[ id ], szVal , charsmax( szVal ) , iTS )
       
        if( !( g_PlayerItems[ id ] & ITEMS( iItemID ) ) && iTS < get_systime( ) )
        {             if( cs_get_user_money( id ) < g_szSkinsData[ iItemID  ][ Price ] )             {

This is the simpler approach that I would use anywhere you are checking if the timestamp is less than get_systime() after calling nvault_lookup(): ( 0 < iTS < get_systime( ) )
PHP Code:
        if( !( g_PlayerItemsid ] & ITEMSiItemID ) ) && ( iTS get_systime( ) ) ) 
Do you expect the vault to be cleared on every map change, if not, remove the plugin_cfg() code.

Being you wrote this plugin I think you can figure out the adjustments faster than I can. Think about it.. every nvault record has an associated timestamp value based on when the last nvault_set() was called for the key, or based on the last nvault_touch() for the key. Start with what I mentioned above and see if it helps.
__________________

Last edited by Bugsy; 05-01-2022 at 21:35.
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2022 , 23:14   Re: nVault Tutorial
Reply With Quote #130

I tried but I don't know how to check each item and stop the time which disconnect or when change to another purchased item.

I used this complicated method for doing this:

PHP Code:
public client_connectid )
{
    
g_CurrentWeaponIDid ] = 0;
    
    new 
szPlayerItems64 ], szVaultData][ 32 ];
    
    
nvault_getg_iVaultg_szSteamIDid ], szPlayerItemscharsmaxszPlayerItems ) );
    
parseszPlayerItemsszVaultData], charsmaxszVaultData[ ] ), szVaultData], charsmaxszVaultData[ ] ), szVaultData], charsmaxszVaultData[ ] ) )
    
    if( 
str_to_numszVaultData] ) )
    {
        
formatexszPlayerItemscharsmaxszPlayerItems ), "%i %i %i"g_PlayerItemsid ], g_WeaponItemsid ], get_systime( ) + ( str_to_numszVaultData] ) * 60 )  )
        
nvault_setg_iVaultg_szSteamIDid ], szPlayerItems );
    }
}


public 
client_disconnectedid )
{
    new 
szPlayerItems64 ], szVaultData][ 32 ];
    
    
nvault_getg_iVaultg_szSteamIDid ], szPlayerItemscharsmaxszPlayerItems ) );
    
parseszPlayerItemsszVaultData], charsmaxszVaultData[ ] ), szVaultData], charsmaxszVaultData[ ] ), szVaultData], charsmaxszVaultData[ ] ) )
    
    if( 
str_to_numszVaultData] ) )
    {
        
formatexszPlayerItemscharsmaxszPlayerItems ), "%i %i %i"g_PlayerItemsid ], g_WeaponItemsid ], str_to_numszVaultData] ) / 60  )
        
nvault_setg_iVaultg_szSteamIDid ], szPlayerItems );
    }    
}

@
SkinsHandleridiMenuiItem )
{
    if( 
iItem != MENU_EXIT 
    {
        if( !
is_user_aliveid ) )
        {
            
client_printid print_chat "You should be alive to buy this item" );
            goto @
Destroy;
        }
        
        if( 
get_user_teamid ) != )
        {
            
client_printid print_chat "You should be human to buy this item" );
            goto @
Destroy;
        }
        
        static 
szData10 ], iUnusedszPlayerItems64 ], szVal12 ], iTS;
        
menu_item_getinfoiMenuiItemiUnusedszDatacharsmax(szData), .callback iUnused )
        new 
iItemID str_to_numszData );
        
        
//nvault_lookup( g_iVault, g_szSteamID[ id ], szVal , charsmax( szVal ) , iTS )
        
new szVaultData][ 32 ]
        
nvault_getg_iVaultg_szSteamIDid ], szPlayerItemscharsmaxszPlayerItems ) );
        
parseszPlayerItemsszVaultData], charsmaxszVaultData[ ] ), szVaultData], charsmaxszVaultData[ ] ), szVaultData], charsmaxszVaultData[ ] ) )
        
        if( 
iItemID != str_to_numszVaultData] ) )
        {
            
formatexszPlayerItemscharsmaxszPlayerItems ), "%i %i %i"g_PlayerItemsid ], g_WeaponItemsid ], str_to_numszVaultData] ) > get_systime( ) ? str_to_numszVaultData] ) - get_systime( ) : 0  )
            
nvault_setg_iVaultg_szSteamIDid ], szPlayerItems );
        }
        else
        {
            if( 
str_to_numszVaultData] ) )
            {
                
formatexszPlayerItemscharsmaxszPlayerItems ), "%i %i %i"g_PlayerItemsid ], g_WeaponItemsid ], get_systime( ) + ( str_to_numszVaultData] ) * 60 )  )
                
nvault_setg_iVaultg_szSteamIDid ], szPlayerItems );
            }
        }
        
        if( !( 
g_PlayerItemsid ] & ITEMSiItemID ) ) && ( iTS get_systime( ) ) )
        {
            if( 
cs_get_user_moneyid ) < g_szSkinsDataiItemID  ][ Price ] )
            {
                goto @
Destroy;
            }
            else
            {
                
cs_set_user_moneyidcs_get_user_moneyid ) - g_szSkinsDataiItemID  ][ Price ] )
            }
        }
        
        if( 
g_szSkinsDataiItemID ][ Skin ][ ] != EOS )
        {
            
cs_set_user_modelidg_szSkinsDataiItemID ][ Skin ] )
        }
        
        
client_printid print_chat "You were given skin ID %d"iItemID );
        
g_PlayerItemsid ] |= ITEMSiItemID );
        
formatexszPlayerItemscharsmaxszPlayerItems ), "%i %i %i"g_PlayerItemsid ], g_WeaponItemsid ], get_systime( ) + 3600 )
        
nvault_setg_iVaultg_szSteamIDid ], szPlayerItems );
        
        
//nvault_touch( g_iVault , g_szSteamID[ id ] , get_systime() + 3600 ); // 1 hour
    
}
    @
Destroy:
    
menu_destroyiMenu );
    return 
PLUGIN_HANDLED;
    

__________________
Youtube.com/Supremache

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

Last edited by Supremache; 05-01-2022 at 23:16.
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 13:54.


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