Raised This Month: $ Target: $400
 0% 

[SOLVED][nVault] Loading problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 06-23-2011 , 07:51   [SOLVED][nVault] Loading problems
Reply With Quote #1

PHP Code:
SaveData(id)
{
    new 
vaultkey[64],vaultdata[256]
    
    
formatex(vaultkey63"%s"iUserSavedPassword[id])
    
formatex(vaultdata255"%i %i"iRank[id], iXP[id])
    
    
nvault_set(nVaultvaultkeyvaultdata)
    
    return 
PLUGIN_CONTINUE
}

LoadData(id)
{
    new 
vaultkey[64],vaultdata[256]
    
    
formatex(vaultkey63"%s"iUserSavedPassword[id])
    
formatex(vaultdata255"%i %i"iRank[id], iXP[id])
    
    
nvault_get(nVaultvaultkeyvaultdata255)
    
    new 
Rank[32], XP[32]
    
parse(vaultdataRank31XP31)
    
    
iRank[id] = str_to_num(Rank)
    
iXP[id] = str_to_num(XP)
    
    return 
PLUGIN_CONTINUE

Saving is not a problem. But loading it is a problem.

What is the problem?
- Loading works but it loads the wrong thing.
- E.g. You are Colonel rank but when it loads, it changes to Private rank.
- Same goes for EXP. They get resetted to 0.

Description
- Private is the default rank when they login.

nVault Editor view

Key: test
Value: 14 204800

Where key is the password for login, 14 is the rank number and 204800 is the EXP.

Extra information
PHP Code:
new const RANKS[][]=
{
    
"Unranked"// 0
    
"Private"// 1
    
"Private 1st Class"// 2
    
"Corporal"// 3
    
"Sergeant"// 4
    
"Staff Sergeant"// 5
    
"Sergeant 1st Class"// 6
    
"Master Sergeant"// 7
    
"Sergeant Major"// 8
    
"2nd Lieutenant"// 9
    
"1st Lieutenant"// 10
    
"Captain"// 11
    
"Major"// 12
    
"Lieutenant Colonel"// 13
    
"Colonel"// 14
    
"Brigadier General"// 15
    
"Major General"// 16
    
"Lieutenant General"// 17
    
"General"// 18
    
"General of the Army" // 19
}

new const 
EXP[] =
{
    
0// 0
    
0// 1
    
50// 2
    
100// 3
    
200// 4
    
400// 5
    
800// 6
    
1600// 7
    
3200// 8
    
6400// 9
    
12800// 10
    
25600// 11
    
51200// 12
    
102400// 13
    
204800// 14
    
409600// 15
    
819200// 16
    
1638400// 17
    
3276800// 18
    
6553600 // 19


Last edited by Excalibur.007; 06-23-2011 at 09:06.
Excalibur.007 is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-23-2011 , 08:29   Re: [nVault] Loading problems
Reply With Quote #2

According to your notation, iUserSavedPassword[id] is an integer value.
So you have to use %i or %d when formatting.

PHP Code:
formatex(vaultkey63"%d"iUserSavedPassword[id]) 
Also you don't have to format the vaultdata in the LoadData() function.
And the returns aren't needed, but they shouldn't cause any problems.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 06-23-2011 , 08:30   Re: [nVault] Loading problems
Reply With Quote #3

iUserSavedPassword is a string not a integer. Sorry for not adding that. And can you show an example of it. This is my first time doing nVault.

As you can see

Code:
nVault Editor view

Key: test
Value: 14 204800
test is the password which is a string. Login system works. Just that it loads incorrectly

EDIT: I tried drekes method. It still loads incorrectly.

EDIT2: Stupid me. It was the login problem. I setted the rank to 0 after it loads the data when it should be the opposite. OMG. I spent 2 hour fixing this...

Last edited by Excalibur.007; 06-23-2011 at 09:04.
Excalibur.007 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-23-2011 , 08:55   Re: [nVault] Loading problems
Reply With Quote #4

Quote:
Originally Posted by Excalibur.007 View Post
PHP Code:
SaveData(id)
{
    new 
vaultkey[64],vaultdata[256]
    
    
formatex(vaultkey63"%s"iUserSavedPassword[id])
    
formatex(vaultdata255"%i %i"iRank[id], iXP[id])
    
    
nvault_set(nVaultvaultkeyvaultdata)
    
    return 
PLUGIN_CONTINUE
}

LoadData(id)
{
    new 
vaultkey[64],vaultdata[256]
    
    
formatex(vaultkey63"%s"iUserSavedPassword[id])
    
formatex(vaultdata255"%i %i"iRank[id], iXP[id])
    
    
nvault_get(nVaultvaultkeyvaultdata255)
    
    new 
Rank[32], XP[32]
    
parse(vaultdataRank31XP31)
    
    
iRank[id] = str_to_num(Rank)
    
iXP[id] = str_to_num(XP)
    
    return 
PLUGIN_CONTINUE

Saving is not a problem. But loading it is a problem.

What is the problem?
- Loading works but it loads the wrong thing.
- E.g. You are Colonel rank but when it loads, it changes to Private rank.
- Same goes for EXP. They get resetted to 0.

Description
- Private is the default rank when they login.

nVault Editor view

Key: test
Value: 14 204800

Where key is the password for login, 14 is the rank number and 204800 is the EXP.

Extra information
PHP Code:
new const RANKS[][]=
{
    
"Unranked"// 0
    
"Private"// 1
    
"Private 1st Class"// 2
    
"Corporal"// 3
    
"Sergeant"// 4
    
"Staff Sergeant"// 5
    
"Sergeant 1st Class"// 6
    
"Master Sergeant"// 7
    
"Sergeant Major"// 8
    
"2nd Lieutenant"// 9
    
"1st Lieutenant"// 10
    
"Captain"// 11
    
"Major"// 12
    
"Lieutenant Colonel"// 13
    
"Colonel"// 14
    
"Brigadier General"// 15
    
"Major General"// 16
    
"Lieutenant General"// 17
    
"General"// 18
    
"General of the Army" // 19
}

new const 
EXP[] =
{
    
0// 0
    
0// 1
    
50// 2
    
100// 3
    
200// 4
    
400// 5
    
800// 6
    
1600// 7
    
3200// 8
    
6400// 9
    
12800// 10
    
25600// 11
    
51200// 12
    
102400// 13
    
204800// 14
    
409600// 15
    
819200// 16
    
1638400// 17
    
3276800// 18
    
6553600 // 19

Try logging the value of iUserSavedPassword inside of the load function.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Excalibur.007
Veteran Member
Join Date: Sep 2009
Location: Singapore
Old 06-23-2011 , 09:04   Re: [nVault] Loading problems
Reply With Quote #5

Yeah. I found out that the function automatically sets the iRank to 0. My bad. I wasted 2 hour finding the problem. Thanks drekes for removing some of the LoadData code.

and exolent sorry to bother you but it's fixed now. really sorry :X.
Excalibur.007 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 23:24.


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