AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   nvault not setting or getting properly (https://forums.alliedmods.net/showthread.php?t=77033)

Venomxtinct 09-03-2008 22:38

nvault not setting or getting properly
 
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]) }

Venomxtinct 09-05-2008 21:43

Re: nvault not setting or getting properly
 
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]) }

Emp` 09-05-2008 22:01

Re: nvault not setting or getting properly
 
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)

Drak 09-05-2008 22:09

Re: nvault not setting or getting properly
 
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)

Venomxtinct 09-06-2008 00:02

Re: nvault not setting or getting properly
 
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]


All times are GMT -4. The time now is 03:18.

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