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

nvault problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 10-15-2015 , 10:30   nvault problems
Reply With Quote #1

Hello i got some nvault problems.
So i been working on this plugin which makes so you can marry other people on the server.

The saving works great it saves the users SteamID and the user steamid + name he is married. The thing that is not working is the loading part. It works whenever you are alone in the server or with other people you are not married to.

But when the guy/girl you are married to joins the server the plugin will loads my marriage + theirs marriage information. I just want it just to load their marriage information.
When it loads my marriage information too it messes up the names. How could i solve this?


This is the nvault code im currently using.
Code:
When someone gets married i save it like this
	SaveData( id, g_iPlayer[id]);
	SaveData( g_iPlayer[id], id );

public client_disconnect(id) 
{
	if(g_iMarriedSteamID[id] != 0 )
		UpdateName(id)
}
	
public client_putinserver(id)
	LoadData(id)


public UpdateName(id) 
{	
	new szSteamID[32], szName[32]
	get_user_authid(id, szSteamID, charsmax(szSteamID))
	get_user_name(id, szName, charsmax(szName))
	
	formatex(g_VaultData, charsmax(g_VaultData), "%s %s", szSteamID, szName)
	nvault_set(g_Vault, g_iMarriedSteamID[id], g_VaultData)

	return PLUGIN_HANDLED
}
public SaveData(id, id2) 
{
	new szSteamID[32], szName[32], szName2[32], szSteamID2[32]
	get_user_authid(id, szSteamID, charsmax(szSteamID))
	get_user_authid(id2, szSteamID2, charsmax(szSteamID2))
	
	get_user_name(id, szName, charsmax(szName))
	get_user_name(id2, szName2, charsmax(szName2))
	
	copy(g_iMarriedSteamID[id2], 32, szSteamID)
	copy(g_iMarriedName[id2], 32, szName)
	
	copy(g_iMarriedSteamID[id], 32, szSteamID2)
	copy(g_iMarriedName[id], 32, szName2)

	formatex(g_VaultData, charsmax(g_VaultData), "%s %s", szSteamID2, szName2)
	nvault_set(g_Vault, szSteamID, g_VaultData)
	
	server_print("SAVE steamid: %s. Marriedsteamid: %s marriedname: %s", szSteamID, g_iMarriedSteamID[id], g_iMarriedName[id])
}
public LoadData(id) 
{
	new szSteamID[32]
	get_user_authid(id, szSteamID, charsmax(szSteamID))
	
	new iTimeStamp
	if(!nvault_lookup(g_Vault, szSteamID, g_VaultData, charsmax(g_VaultData), iTimeStamp) )
		return PLUGIN_HANDLED

	new MarriedSteamID[32], MarriedName[32]
	nvault_get(g_Vault, szSteamID, g_VaultData, charsmax(g_VaultData))
	parse(g_VaultData, MarriedSteamID, charsmax(MarriedSteamID), MarriedName, charsmax(MarriedName))
	
	copy(g_iMarriedSteamID[id], 32, MarriedSteamID)
	copy(g_iMarriedName[id], 32, MarriedName)
	
	server_print("LOAD steamid: %s. Marriedsteamid: %s marriedname: %s", szSteamID, g_iMarriedSteamID[id], g_iMarriedName[id])
	
	return PLUGIN_HANDLED
}
Ps. I dont want to switch to SQL
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.

Last edited by ironskillz1; 10-15-2015 at 10:33.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-15-2015 , 20:46   Re: nvault problems
Reply With Quote #2

Is this along the lines of what you're trying to do?
Code:
key="STEAM_0:0:12345"  data="STEAM_0:0:98765 bugsy"
key="STEAM_0:0:98765"  data="STEAM_0:0:12345 bugsys wife"
__________________
Bugsy is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 10-16-2015 , 01:09   Re: nvault problems
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
Is this along the lines of what you're trying to do?
Code:
key="STEAM_0:0:12345"  data="STEAM_0:0:98765 bugsy"
key="STEAM_0:0:98765"  data="STEAM_0:0:12345 bugsys wife"
Yes
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-16-2015 , 18:55   Re: nvault problems
Reply With Quote #4

Quote:
Originally Posted by ironskillz1 View Post
Yes
You should cache the players steamid in a global variable @ client_authorized(). I would also organize the data using an enum, something like the below, for example.
PHP Code:
enum MarriedData
{
    
szSteamID34 ],
    
szSpouseSteamID34 ],
    
szSpouseName33 ]
}
new 
g_mdDataMAX_PLAYERS ][ MarriedData 
I didn't look through your entire plugin, but I can tell that your loading/saving was wrong. Hopefully this solves it.

Untested:
PHP Code:
public UpdateNameid )
{
    new 
szName33 ] , szAuthID34 ] , szBuffer66 ];
    
    
get_user_nameid szName charsmaxszName ) );
    
get_user_authidid szAuthID charsmaxszAuthID ) );
    
    
formatexszBuffer charsmaxszBuffer ) , "%s ^"%s^"" szAuthID szName );
    
nvault_setg_Vault g_iMarriedSteamIDid ] , szBuffer ); 
}

public 
SaveDataid1 id2 )
{
    
//ID1 : KEY=[ID1_STEAMID] DATA=[ID2_STEAMID "ID2_NAME"]
    //ID2 : KEY=[ID2_STEAMID] DATA=[ID1_STEAMID "ID1_NAME"]
    
    
new szName][ 32 ] , szAuthID][ 34 ] , szBuffer66 ];
    
    
get_user_nameid1 szName] , charsmaxszName[] ) );
    
get_user_nameid2 szName] , charsmaxszName[] ) );
    
    
get_user_authidid1 szAuthID] , charsmaxszAuthID[] ) );
    
get_user_authidid2 szAuthID] , charsmaxszAuthID[] ) );
    
    
formatexszBuffer charsmaxszBuffer ) , "%s ^"%s^"" szAuthID] , szName] );
    
nvault_setg_Vault szAuthID] , szBuffer );

    
formatexszBuffer charsmaxszBuffer ) , "%s ^"%s^"" szAuthID] , szName] );
    
nvault_setg_Vault szAuthID] , szBuffer );
}

public 
LoadDataid )
{
    new 
szAuthID34 ] , szBuffer66 ] , iTS;
    
    
get_user_authidid szAuthID charsmaxszAuthID ) );
    
    if ( 
nvault_lookupg_Vault szAuthID szBuffer charsmaxszBuffer ) , iTS ) )
    {
        
parseszBuffer g_iMarriedSteamIDid ] , charsmaxg_iMarriedSteamID[] ) , g_iMarriedNameid ] , charsmaxg_iMarriedName[] ) );
    }
    

__________________

Last edited by Bugsy; 10-17-2015 at 12:23.
Bugsy is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 10-17-2015 , 09:26   Re: nvault problems
Reply With Quote #5

Thanks a lot man. I really appreciate that you have spent time fixing this for me. I will return with the results if it worked or not
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-17-2015 , 12:24   Re: nvault problems
Reply With Quote #6

I found one minor mistake in my above code which resulted in only the first letter of each players name to be saved in the vault. I edited the above code to fix this.
__________________
Bugsy is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 10-17-2015 , 17:37   Re: nvault problems
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
I found one minor mistake in my above code which resulted in only the first letter of each players name to be saved in the vault. I edited the above code to fix this.
With the new loading code it wont load at all. The saving are working great tho.

It wont load anything.

Code:
public LoadData( id )
{
	new szBuffer[ 66 ] , iTS;
	
	if ( nvault_lookup( g_Vault , g_szAuthID[id] , szBuffer , charsmax( szBuffer ) , iTS ) )
	{
		parse( szBuffer , g_iMarriedSteamID[ id ] , charsmax( g_iMarriedSteamID[] ) , g_iMarriedName[ id ] , charsmax( g_iMarriedName[] ) );

		server_print("LOAD steamid: %s. Marriedsteamid: %s marriedname: %s", g_szAuthID[id], g_iMarriedSteamID[id], g_iMarriedName[id])
	}

}
The server print is blank at marriedsteamid and steamname.
So i guess something is wrong.
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-17-2015 , 18:05   Re: nvault problems
Reply With Quote #8

Quote:
Originally Posted by ironskillz1 View Post
With the new loading code it wont load at all. The saving are working great tho.

It wont load anything.

Code:
public LoadData( id )
{
	new szBuffer[ 66 ] , iTS;
	
	if ( nvault_lookup( g_Vault , g_szAuthID[id] , szBuffer , charsmax( szBuffer ) , iTS ) )
	{
		parse( szBuffer , g_iMarriedSteamID[ id ] , charsmax( g_iMarriedSteamID[] ) , g_iMarriedName[ id ] , charsmax( g_iMarriedName[] ) );

		server_print("LOAD steamid: %s. Marriedsteamid: %s marriedname: %s", g_szAuthID[id], g_iMarriedSteamID[id], g_iMarriedName[id])
	}

}
The server print is blank at marriedsteamid and steamname.
So i guess something is wrong.
Are you reading player authid into g_szAuthID[id] at client_authorized()?
__________________
Bugsy is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 10-17-2015 , 18:36   Re: nvault problems
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
Are you reading player authid into g_szAuthID[id] at client_authorized()?
Code:
g_szAuthID[ 33 ][ 34 ]; 

public client_putinserver(id)
{
	LoadData(id)
	get_user_authid( id , g_szAuthID[ id ] , charsmax( g_szAuthID[] ) ); 
}
Yes
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.

Last edited by ironskillz1; 10-17-2015 at 18:36.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-17-2015 , 18:50   Re: nvault problems
Reply With Quote #10

Try the copy of the plugin I PM'd you

And make sure you read the authid before calling the load function
__________________

Last edited by Bugsy; 10-17-2015 at 18:51.
Bugsy 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 21:26.


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