Raised This Month: $51 Target: $400
 12% 

How to save in nvault?


Post New Thread Reply   
 
Thread Tools Display Modes
Gasior
Member
Join Date: Mar 2012
Old 11-24-2016 , 07:37   Re: How to save in nvault?
Reply With Quote #11

Code:
public SaveData(id)
{ 
	new authid[32];
	get_user_authid(id, authid, 31);
	
	nvault_set( plik_vault , authid , Model_Name, bla  bbla, you knwo here .. )
}

public LoadModel(id)
{ 
    new authid[32] , GetModel[64] , iTs;
    get_user_authid(id, authid, 31);

    if( is_user_alive ( id ) && nvault_lookup( plik_vault, authid, GetModel, charsmax( GetModel ), iTs ) )
        cs_set_user_model( id, team = 0 , GetModel );
    
}

I am totally lost here, I try to make sense of it but my mind is shattered.

So I abandon SaveData & Load Data and whatever I nvault I had in there and replace it with above?

Couple of questions:
Where did you get "GetModel" from? Sorry but how am I supposed to use it an what is it?
So how are we going to save the nvault data in the above form?
Why does team equal to 0?

I'm sorry but I am totally lost .

Could someone perhaps fix it up or at least write comments next to the lines so I understand the whole process. I sit here for like an hour, trying to figure it all up but I think my brain gave up on me.
Gasior is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 11-24-2016 , 10:34   Re: How to save in nvault?
Reply With Quote #12

Yes yes sorry, just a wait a minute.

Code:
new const Model_Name[] = "cstrike/models/players/vip.mdl"; public plugin_precache() {     precache_model( Model_Name); } public SaveData(id) {     // Here you take the user SteamID , correct ?      new authid[35];     get_user_authid(id, authid, charsmax ( authid ) );     //////////////////////////////     //         plik_vault - Here should be your nvault file Index ( that is how i found its name. )         authid - is the KEY .         Model_name - is the DATA of the KEY.     //      nvault_set( plik_vault , authid , Model_Name )     // About the Model_Name, just the Model_variable string wich you used to precache it, example in plugin_precache() } public LoadModel(id) {     //  Same process, we create variables ...  inside of GetModel we retrieve the data of the Key     // iTs variabile its the TimeStamp wich is a must to retrieve, even if you do not use it.     new authid[35] , GetModel[64] , iTs;     get_user_authid(id, authid, charsmax( authid ) );     // We check here if the user is ALIVE and Also if the entry exists, nvault_lookup() return 0 if the entry is not founded.     // in the same time we check bla bla and also we insert the data of the key (authid) inside of our variable ( GetModel ).     if( is_user_alive ( id ) && nvault_lookup( plik_vault, authid, GetModel, charsmax( GetModel ), iTs ) )         cs_set_user_model( id, team = 0 , GetModel );     // about team = 0 is UNNASIGNED, you can just read cs_set_user_team native information ( open cstrike.inc ) and you will se.         }


Also, read what i wrote > https://forums.alliedmods.net/showthread.php?t=290692
Also, open nvault.inc and try to understand something not only by reading my code.
__________________
Project: Among Us

Last edited by Craxor; 11-24-2016 at 11:01.
Craxor is offline
Send a message via ICQ to Craxor
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-24-2016 , 12:19   Re: How to save in nvault?
Reply With Quote #13

You are better off saving the model index number instead of the actual model name. I went through your code and fixed some things but I could not fully test because I do not have those models. I also assumed that you are not using nvault to store anything else in your plugin. If you are, you will need to make the key unique for the model index, as you have in your original code.

Please review the code and compare with your code to see what I changed so you can learn something from it.

Edit: This will take additional work to set the players model when he first connects because at client_authorized() his team is not yet assigned.
Edit2: Code updated to set model when a team is selected and also fixed an index out of bounds error. Untested.
Spoiler
__________________

Last edited by Bugsy; 11-24-2016 at 22:47.
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 11-24-2016 , 12:24   Re: How to save in nvault?
Reply With Quote #14

honestly i didn't know models have an index ) sorry
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-24-2016 , 12:26   Re: How to save in nvault?
Reply With Quote #15

Quote:
Originally Posted by Craxor View Post
honestly i didn't know models have an index ) sorry
They don't, but when they are stored in an array they do.
PHP Code:
new g_ModelFiles[][][] = {
    {
"saperterro""ctsplinter"},  = 0
    
{"oranget""camoct"},   = 1
    
{"phoenixt""urbanos"},   = 2
    
{"viptt""snowct"}   = 3
};

new 
g_ModelNames[][] = {
    
"Model 1",  = 0
    
"Model 2",  = 1
    
"Model 3",  = 2
    
"Model 4"  3
}; 
__________________
Bugsy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 11-24-2016 , 12:39   Re: How to save in nvault?
Reply With Quote #16

Quote:
Originally Posted by Bugsy View Post
They don't, but when they are stored in an array they do.
AAaaa, sorry, didn't check the code.

Hope the author can understand
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-24-2016 , 13:02   Re: How to save in nvault?
Reply With Quote #17

Quote:
Originally Posted by Craxor View Post
AAaaa, sorry, didn't check the code.

Hope the author can understand
Yea, I should have commented line by line. It required very little effort to make it work by storing the model index in the vault--he already had the logic in place to show the current model as disabled in the menu.
__________________
Bugsy is offline
Gasior
Member
Join Date: Mar 2012
Old 11-24-2016 , 21:08   Re: How to save in nvault?
Reply With Quote #18

Hi,

Tremendous thank you for you help, however the models do not set on the player.

When I choose the option from the menu nothing happens.

//
Edit

Actually models in CT team do not work but when I go to T team I have CT models. There's also a problem because once I picked a model of CT in T Team I change teams so T (with CT model) goes to CT (still have CT model) it doesn't change.

It also saves appropriately but works only after player has re spawned not the first original spawn after connection, which is totally fine with me.

Last edited by Gasior; 11-24-2016 at 21:13.
Gasior is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-24-2016 , 21:19   Re: How to save in nvault?
Reply With Quote #19

Yes, I added a comment above. I didn't totally think it through since I went through the code quickly. It will take more work to set the model after the user chooses a team. In my code above, it attempts to set the model immediately upon connecting at which time the team is unassigned. It also does not account for team changes.
__________________
Bugsy is offline
Gasior
Member
Join Date: Mar 2012
Old 11-24-2016 , 21:43   Re: How to save in nvault?
Reply With Quote #20

What if on connection we would just read the data and then set it up on respawn? After respawn set up an index preventing a cycle. Would that fix the problem?
Gasior 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 19:47.


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