Raised This Month: $ Target: $400
 0% 

Nvault how to save models?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 03-26-2022 , 02:16   Re: Nvault how to save models?
Reply With Quote #7

Short: you have to save selected model by its index. Then if player reconnects, you just get his authid, then nvault_lookup() for saved index and set knife depending on index

look at this as at reference, adjust for yourself
PHP Code:
enum Knives 

    
NoKnifeSet 0,  // first entry should be the default knife
    
...


new const 
g_ModelData[Knives][KnifeModels] = { ... } // first entry should be the default knife

save_to_vault(player)
{
    new 
tempKey[...], tempValue[...]
    
    
get_user_authid(playertempKeycharsmax(tempKey)) // or u can use formatex() instead of this if u have authid saved somewhere else in your plugin
    
formatex(tempValuecharsmax(tempValue), "%i"g_selectedKnifeId[player])
    
    
nvault_set(g_vaulttempKeytempValue)
}

get_from_vault(player)
{
    new 
tempKey[...], tempValue[...], timestamp
    
    get_user_authid
(playertempKeycharsmax(tempKey))
    
    new 
found nvault_lookup(g_vaulttempKeytempValuecharsmax(tempValue), timestamp)
    
    if(
found)
    {
        new 
iKnife str_to_num(tempValue)
        
setKnifeById(playeriKnife// use here your function for knife change
    
}
    else
    {
        
setKnifeById(player0// if player's authid was not found then guve him defaut knife
    
}

__________________
Now working on: Side Weapons (Very lazy, tbh)
Avatar source: https://bit.ly/3BAk19g
Discord: kww#9951

Last edited by kww; 03-26-2022 at 02:21.
kww is offline
 



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