Raised This Month: $ Target: $400
 0% 

Remember more values with nVault?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-16-2020 , 20:00   Re: Remember more values with nVault?
Reply With Quote #1

Code:
#include <amxmodx> #include <nvault> new g_vault public plugin_init() {     register_plugin("NVault Example", "Version", "Author")     g_vault = nvault_open("ExampleVault") } public client_disconnected(id) {     if (!is_user_bot(id) && !is_user_hltv(id))         save_player_data(id) } public client_authorized(id, const authid[]) {     if (!is_user_bot(id) && !is_user_hltv(id))         load_player_data(id, authid) } public save_player_data(id) {     new authid[MAX_AUTHID_LEN]     get_user_authid(id, authid, charsmax(authid))     new data[256]     new value1 = 100     new value2 = 200     new value3 = 300     formatex(data, charsmax(data), "%d %d %d", value1, value2, value3)     nvault_set(g_vault, authid, data) } public load_player_data(id, authid[] = "") {     if (!authid[0])         get_user_authid(id, authid, charsmax(authid))     new data[256]     nvault_get(g_vault, authid, data, charsmax(data))     new values[3][85]     parse(data, values[0], charsmax(values[]), values[1], charsmax(values[]), values[2], charsmax(values[]))     new value1 = str_to_num(values[0])     new value2 = str_to_num(values[1])     new value3 = str_to_num(values[2]) }

If you need to store multiple strings consider using nVault Array instead. It's just an include with utility functions, easy, really.
__________________









Last edited by CrazY.; 06-16-2020 at 20:05.
CrazY. is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-16-2020 , 20:03   Re: Remember more values with nVault?
Reply With Quote #2

Quote:
Originally Posted by CrazY. View Post
Code:
#include <amxmodx> #include <nvault> new g_vault public plugin_init() {     register_plugin("NVault Example", "Version", "Author")     g_vault = nvault_open("ExampleVault") } public client_disconnected(id) {     if (!is_user_bot(id) && !is_user_hltv(id))         save_player_data(id) } public client_authorized(id, const authid[]) {     if (!is_user_bot(id) && !is_user_hltv(id))         load_player_data(id, authid) } public save_player_data(id) {     new authid[MAX_AUTHID_LEN]     get_user_authid(id, authid, charsmax(authid))     new data[256]     new value1 = 100     new value2 = 200     new value3 = 300     formatex(data, charsmax(data), "%d %d %d", value1, value2, value3)     nvault_set(g_vault, authid, data) } public load_player_data(id, authid[] = "") {     if (!authid[0])         get_user_authid(id, authid, charsmax(authid))     new data[256]     nvault_get(g_vault, authid, data, charsmax(data))     new values[3][85]     parse(data, values[0], charsmax(values[]), values[1], charsmax(values[]), values[2], charsmax(values[]))     new value1 = str_to_num(values[0])     new value2 = str_to_num(values[1])     new value3 = str_to_num(values[2]) }
I'll try this and see if it works, thanks for replying
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 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 16:58.


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