This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

nVault Tutorial


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2022 , 19:28   Re: nVault Tutorial
Reply With Quote #1

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 - 35 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 , 20:34   Re: nVault Tutorial
Reply With Quote #2

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 20:35.
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-01-2022 , 22:14   Re: nVault Tutorial
Reply With Quote #3

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 22:16.
Supremache is offline
Ant1Lamer
Senior Member
Join Date: Jul 2009
Old 05-17-2022 , 13:02   Re: nVault Tutorial
Reply With Quote #4

How to make after player make 1000 kills and player receive flags after 15 days this flag remove or 10 days im choose in ini fail how many days this flag to be remove ? Now not work and flag not remove... This the sma and ini fail
Attached Files
File Type: sma Get Plugin or Get Source (crx_becomevip.sma - 229 views - 11.7 KB)
File Type: ini BecomeVIP.ini (1.4 KB, 149 views)
Ant1Lamer is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-20-2022 , 22:32   Re: nVault Tutorial
Reply With Quote #5

This thread is not really for help with fixing plugins. Please post your question in Scripting Help or Suggestions/Requests if you want someone to do it for you.

If you have a question specific to nVault natives, feel free to ask here.
__________________
Bugsy is offline
Ant1Lamer
Senior Member
Join Date: Jul 2009
Old 05-21-2022 , 02:47   Re: nVault Tutorial
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
This thread is not really for help with fixing plugins. Please post your question in Scripting Help or Suggestions/Requests if you want someone to do it for you.

If you have a question specific to nVault natives, feel free to ask here.
Thank you https://forums.alliedmods.net/showth...48#post2779848
Ant1Lamer is offline
Reply



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 23:52.


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