Raised This Month: $ Target: $400
 0% 

Nvault how to save models?


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-30-2022 , 23:24   Re: Nvault how to save models?
Reply With Quote #11

I'd recommend using nVault Array to make it easier. You can use the same key that you are now [steamid]_skin, and the nvault array can store all skin/model ID's that have been purchased.
__________________
Bugsy is offline
Arje
Senior Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 03-30-2022 , 23:45   Re: Nvault how to save models?
Reply With Quote #12

I'm sorry I'm quite a beginner, I try to understand how nvault works by looking at other codes and try to understand it, but nvault already surpassed me, now nvault array surpasses me even more

edit1: i read the post about nvault array.inc and i try to search post about nvault array but I didn't find almost any examples

Last edited by Arje; 03-31-2022 at 13:04.
Arje is offline
Arje
Senior Member
Join Date: Apr 2020
Location: Córdoba, Argentina
Old 03-31-2022 , 16:24   Re: Nvault how to save models?
Reply With Quote #13

after reading and trying to understand some codes, I can get this that works for me at the moment,

but I realized that I would have to create a variable "g_PlayerBuyItem" for each item, do I have to continue like this or is there another way to do it?

and I know you told me to use nVault Array, but I really don't understand it and I didn't find any example of it more explained or similar to understand how to apply it in this case

At the moment this is the code that works for me:
PHP Code:
new g_PlayerBuyThanosMAX_PLAYERS ];

public 
menu_handlerid menu item )
{
    if ( 
item == MENU_EXIT ) {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
szData[6], szName[64];
    new 
item_accessitem_callback;
    
menu_item_getinfomenuitemitem_accessszDatacharsmax(szData), szName,charsmax(szName), item_callback );
    
    
g_Model[id] = item;
    
    switch(
item) {
        
// This Skins is from First Page of the Menu
        //-----------    Blackwidow
        
case 0: {
            
resetModelid );
            
sh_chat_message(id, -1"Seleccionaste la Skin de Blackwidow .");
        }
        
//-----------    Broly
        
case 1: {
            
resetModelid );
            
sh_chat_message(id, -1"Seleccionaste la Skin de Broly.");
        }
        
//-----------    Neo
        
case 2: {
            
resetModelid );
            
sh_chat_message(id, -1"Seleccionaste la Skin de Neo.");
        }
        
//-----------    Obi wan
        
case 3: {
            
resetModelid );
            
sh_chat_message(id, -1"Seleccionaste la Skin de Obi Wan Kenobi.");
        }
        
//-----------    Termo
        
case 4: {
            
resetModelid );
            
sh_chat_message(id, -1"Valor of this? %d"g_PlayerBuyThanosid ]);    //That's only print for proofs
            
sh_chat_message(id, -1"Seleccionaste la Skin de Termo solo por nivel.");
        }
        
//-----------    Thanos
        
case 5: {
            
resetModelid );
            
sh_chat_message(id, -1"Valor of this? %d"g_PlayerBuyThanosid ]);    //That's only print for proofs
            
sh_chat_message(id, -1"Seleccionaste la Skin de Thanos Solo de Admin.");
        }
        
//-----------    Thanos End Game
        
case 6: {
            
resetModelid );
            
            
sh_chat_message(id, -1"Valor of this? %d"g_PlayerBuyThanosid ]);    //That's only print for proofs
            
            
if ( g_PlayerBuyThanos[id] != ) {
                new 
iXPToAdd = ( -5000 );
                
sh_set_user_xp(idiXPToAddtrue);
                
g_PlayerBuyThanos[id] = 1;
            }
            
            
sh_chat_message(id, -1"Compraste la Skin de Thanos End Game.");
        }
        case 
MENU_EXIT: {
            
sh_chat_message(id, -1"No Seleccionaste Ninguna Skin.");
        }
        
//-----------    Show Motd Info
        
default: {
            
show_motdid "Info Skins.txt" "Info Skins." );
        }
    }
    
    
SaveData(id);
    
//lets finish up this function by destroying the menu with menu_destroy, and a return
    
menu_destroy(menu);
    return 
PLUGIN_CONTINUE;
}
//------------------------------------------------------------------------------------------------
//                Save and Load Data from Nvault.                    //
//------------------------------------------------------------------------------------------------
public SaveData(id)

    new 
szKey40 ] , szData[4];
     
    
format(szDatacharsmaxszData ),"%i %d",g_Model[id], g_PlayerBuyThanos[id] );
    
    
nvault_setg_iVaultID g_szAuthID[id], szData );


public 
LoadData(id

    
    new 
DataModel[4], BuyThanos[4], szData[4] , iTS;   
    
nvault_getg_iVaultIDg_szAuthIDid ], szDatacharsmaxszData ) );
    
    
parseszDataDataModelcharsmaxDataModel ), BuyThanoscharsmaxBuyThanos ) );
    
    
g_Model[id] = str_to_numDataModel );
    
g_PlayerBuyThanos[id] = str_to_numBuyThanos );
    
    if ( 
nvault_lookupg_iVaultID g_szAuthIDid ] , szData charsmaxszData ) , iTS ) ) {
    
        
g_Modelid ] = str_to_numDataModel );
        
g_PlayerBuyThanos[id] = str_to_numBuyThanos );
        }
    else     {
        
g_Model[id] = NoModelSet;
    }

Arje is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-31-2022 , 22:26   Re: Nvault how to save models?
Reply With Quote #14

Here's a small demo plugin for how you can do this:

PHP Code:

#include <amxmodx>
#include <nvault_array>

//Max skins each player can have
const MaxPlayerSkins 5;

enum PlayerData
{
    
AuthID34 ],
    
PlayerSkinsMaxPlayerSkins ],
    
SkinCount
}

new 
g_PlayerItemsMAX_PLAYERS ][ PlayerData ];
new 
g_Vault;

public 
plugin_init() 
{
    
g_Vault nvault_open"test_skins" );
    
    
register_clcmd"say skin" "GiveSkin" );
    
register_clcmd"say show" "ShowSkins" );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
GiveSkinid )
{
    if ( 
g_PlayerItemsid ][ SkinCount ] < MaxPlayerSkins )
    {
        new 
skinID random_num100 );
    
        
g_PlayerItemsid ][ PlayerSkins ][ g_PlayerItemsid ][ SkinCount ]++ ] = skinID;
        
client_printid print_chat "You were given skin ID %d" skinID );
    }
}

public 
ShowSkinsid )
{
    
client_printid print_chat "You have these skins:" );
    
    for ( new 
g_PlayerItemsid ][ SkinCount ] ; i++ )
    {
        
client_printid print_chat "%d" g_PlayerItemsid ][ PlayerSkins ][ ] );
    }
}

public 
client_authorizedid )
{
    
get_user_authidid g_PlayerItemsid ][ AuthID ] , charsmaxg_PlayerItems[][ AuthID ] ) );
    
nvault_get_arrayg_Vault g_PlayerItemsid ][ AuthID ] , g_PlayerItemsid ][ PlayerSkins ][ ] , sizeofg_PlayerItems[][ PlayerSkins ] ) );

    for ( new 
sizeofg_PlayerItems[][ PlayerSkins ] ) ; i++ )
    {
        if ( 
g_PlayerItemsid ][ PlayerSkins ][ ] > )
            
g_PlayerItemsid ][ SkinCount ]++;
    }
    
    
server_print"Loaded %d skin(s) for %s" g_PlayerItemsid ][ SkinCount ] ,  g_PlayerItemsid ][ AuthID ] ); 
}

public 
client_disconnectedid )
{
    
nvault_set_arrayg_Vault g_PlayerItemsid ][ AuthID ] , g_PlayerItemsid ][ PlayerSkins ][ ] , sizeofg_PlayerItems[][ PlayerSkins ] ) );

__________________

Last edited by Bugsy; 04-01-2022 at 13:08.
Bugsy 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 07:37.


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