Raised This Month: $32 Target: $400
 8% 

nvault not setting or getting properly


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Venomxtinct
Member
Join Date: Nov 2005
Old 09-03-2008 , 22:38   nvault not setting or getting properly
Reply With Quote #1

For some reason, no matter what I try, I cannot get the nvault to store/recall the data properly. I dont know what it is after three code re-writes, thus I am asking for help.

I know theres a lot of room for optimization, however for now I just want to get it to work properly..

The problem occurs when I say /credits after a disconnect. When I reconnect, the credits are reset to zero, thus making it kinda obsolete. Im pretty sure its either:
Problem with the nvault_get
Problem with the nvault_set
Mis-used variable to the nvault

Help would be greatly appreciated.

Update:
I just found the nvault viewer and apparently its not writing or getting. Making me so confused.

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <engine> #include <cstrike> #include <fun> #include <nvault> #define PLUGIN "nAcHo's Special Weapon Mod" #define VERSION "0.02" #define AUTHOR "nAcHo cHeEsE" new last_playtime_check[33] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say /credits", "credits_say")     register_clcmd("say_team /credits", "credits_say")     register_clcmd("say credits", "credits_say")     register_clcmd("say creds", "credits_say") } public client_putinserver(id) {     new authid[32]     get_user_authid(id, authid, 34)     //get the time spent playing     new time_playing     time_playing = (get_user_time(id) - last_playtime_check[id])     last_playtime_check[id] = get_user_time(id)         //NVAULT     //vault_set = the previous vault value     new nvault = nvault_open("CreditsMod23")     new vault_set[32], prev_vault_set     nvault_get(nvault, authid, vault_set[id])     prev_vault_set = str_to_num(vault_set[id])     vault_set[id] = prev_vault_set + time_playing     num_to_str(vault_set[id], vault_set[id], 34)     nvault_set(nvault, authid, vault_set[id])     //END NVAULT } public credits_say(id) {         //get the authid     new authid[32]     get_user_authid(id, authid, 34)         //get the time spent playing     new time_playing     time_playing = (get_user_time(id) - last_playtime_check[id])     last_playtime_check[id] = get_user_time(id)                 new nvault = nvault_open("CreditsMod23")     new vault_set[32], prev_vault_set     nvault_get(nvault, authid, vault_set[id], 34)     prev_vault_set = str_to_num(vault_set[id])     vault_set[id] = prev_vault_set + time_playing     num_to_str(vault_set[id], vault_set[id], 34)     nvault_set(nvault, authid, vault_set[id])         nvault_get(nvault, authid, vault_set[id], 34)     new credits     credits = str_to_num(vault_set[id])     client_print(id, print_chat, "You have %i Credits", credits) } public client_disconnect(id) {                 //get the authid     new authid[32]     get_user_authid(id, authid, 34)         //get the time spent playing     last_playtime_check[id] = 0     new time_playing     time_playing = (get_user_time(id) - last_playtime_check[id])                 new nvault = nvault_open("CreditsMod23")     new vault_set[32], prev_vault_set     nvault_get(nvault, authid, vault_set[id], 34)     prev_vault_set = str_to_num(vault_set[id])     vault_set[id] = prev_vault_set + time_playing     num_to_str(vault_set[id], vault_set[id], 34)     nvault_set(nvault, authid, vault_set[id]) }

Last edited by Venomxtinct; 09-04-2008 at 17:34.
Venomxtinct is offline
Venomxtinct
Member
Join Date: Nov 2005
Old 09-05-2008 , 21:43   Re: nvault not setting or getting properly
Reply With Quote #2

Tried different coding attempts that caused an overall error, so here is another slightly modified code and a bump.

What it seems to be doing is writing it locally, but not to the nvault at all. I saw once that my steamid was STEAM_ID_PENDING and it still worked, meaning that the connection was off.

Again, any help or suggestions would be appreciated.

Code:
public client_putinserver(id) {     new authid[32]     get_user_authid(id, authid, 34)     //get the time spent playing     new time_playing     time_playing = (get_user_time(id) - last_playtime_check[id])     last_playtime_check[id] = get_user_time(id)         //NVAULT     //vault_set = the previous vault value     new nvault = nvault_open("CreditsMod24")     new vault_set[21], prev_vault_set, prev_vault_set2     nvault_get(nvault, authid[id], vault_set[id], 34)     prev_vault_set = str_to_num(vault_set)     prev_vault_set2 = prev_vault_set + time_playing     vault_set[id] = prev_vault_set2     num_to_str(prev_vault_set2, vault_set[id], 34)     nvault_set(nvault, authid, vault_set[id])     //END NVAULT } public credits_say(id) {         //get the authid     new authid[32]     get_user_authid(id, authid, 34)         //get the time spent playing     new time_playing     time_playing = get_user_time(id)     last_playtime_check[id] = get_user_time(id)                 new nvault = nvault_open("CreditsMod24")     new vault_set[21], prev_vault_set, prev_vault_set2     nvault_get(nvault, authid[id], vault_set[id], 34)     prev_vault_set = str_to_num(vault_set)     prev_vault_set2 = prev_vault_set + time_playing     vault_set[id] = prev_vault_set2     num_to_str(prev_vault_set2, vault_set[id], 34)     nvault_set(nvault, authid, vault_set[id])         nvault_get(nvault, authid, vault_set[id], 34)     new credits     credits = str_to_num(vault_set[id])     client_print(id, print_chat, "You have %i Credits", credits) } public client_disconnect(id) {     //get the authid     new authid[32]     get_user_authid(id, authid, 34)         //get the time spent playing     last_playtime_check[id] = 0     new time_playing     time_playing = (get_user_time(id) - last_playtime_check[id])                 new nvault = nvault_open("CreditsMod24")     new vault_set[21], prev_vault_set, prev_vault_set2     nvault_get(nvault, authid[id], vault_set[id], 34)     prev_vault_set = str_to_num(vault_set)     prev_vault_set2 = prev_vault_set + time_playing     vault_set[id] = prev_vault_set2     num_to_str(prev_vault_set2, vault_set[id], 34)     nvault_set(nvault, authid, vault_set[id]) }
__________________
LowgravCS. In development.
Venomxtinct is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 09-05-2008 , 22:01   Re: nvault not setting or getting properly
Reply With Quote #3

it's most likely because you're indexing the arrays in nvault_get and nvault_set

Code:
nvault_get(nvault, authid[id], vault_set[id], 34)
->
Code:
nvault_get(nvault, authid, vault_set, 34)
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Drak
Veteran Member
Join Date: Jul 2005
Old 09-05-2008 , 22:09   Re: nvault not setting or getting properly
Reply With Quote #4

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <engine> #include <cstrike> #include <fun> #include <nvault> #define PLUGIN "nAcHo's Special Weapon Mod" #define VERSION "0.02" #define AUTHOR "nAcHo cHeEsE" new g_PlayTime[33] new g_Vault public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);         register_clcmd("say /credits", "credits_say")     register_clcmd("say_team /credits", "credits_say")     register_clcmd("say credits", "credits_say")     register_clcmd("say creds", "credits_say")         g_Vault = nvault_open("CreditsMod23"); } public client_putinserver(id) {     new AuthID[36]     get_user_authid(id,AuthID,35);         g_PlayTime[id] = 0         new Data[256],Temp     if(nvault_lookup(g_Vault,AuthID,Data,255,Temp))     {         new pre_time[16]         parse(Data,pre_time,15);                 g_PlayTime[id] = str_to_num(pre_time);     } } public credits_say(id)     return client_print(id,print_chat,"You have %i Credits",g_PlayTime[id] + get_user_time(id)); public client_disconnect(id) {     new AuthID[36]     get_user_authid(id,AuthID,35);         if(AuthID[0])     {         new VaultData[36]         num_to_str(get_user_time(id),VaultData,35);         nvault_set(g_Vault,AuthID,VaultData);     } } public plugin_end()     nvault_close(g_Vault);

Are your "Credits" Your play time? Because that's what it looks like. But anyways.
Here it opens/closes the Vault on Map start/end. And your play time is saved at when they disconnect. And the credits is your current playtime, plus the old one. (That was saved in the Vault)
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Venomxtinct
Member
Join Date: Nov 2005
Old 09-06-2008 , 00:02   Re: nvault not setting or getting properly
Reply With Quote #5

Thanks much for the help. I was able to alter the code so that it actually converts the time played on the server to actual credits, as well as alter the nvault every time the user checks.

[FIXED/FINISHED]
__________________
LowgravCS. In development.
Venomxtinct 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 19:25.


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