Raised This Month: $ Target: $400
 0% 

[Help] Storing name.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
abhishek_deshkar
Senior Member
Join Date: Jun 2013
Location: Earth
Old 11-30-2014 , 00:58   [Help] Storing name.
Reply With Quote #1

Hello there,
Im storing name in nVault. So What I'm doing is storing name with the key of name. But when there are more than one players in the server and they type /reg to register at that time the name overlaps.

For eg. First player. /reg
He set his name: abc

For eg. Second player. /reg
He set his name: xyz

so when second players wants to know his password he types /showname

it shows xyz for both the users. Please help me out.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <nvault>  
#include <csx> 
#include <fakemeta>
#include <engine>
 

#define PLUGIN "Store Name"
#define VERSION "1.6"
#define AUTHOR "Abhishek"



new g_Vault
new uname[32]


public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
//XP Register System 
    
register_clcmd("say /reg","cmdDoRegister")
    
register_clcmd("doRegister","cmdRegister")
    
register_clcmd"say /showname" "cmdShowName" );
    
    
}
public 
plugin_cfg()
{
    
    
g_Vault nvault_open"yourvault" );
}

public 
plugin_end()
{
    
    
nvault_closeg_Vault );
}
public 
client_connect(id)
{
    
get_user_name(id,uname,31)
}


public 
cmdDoRegister(id)
{

            
client_cmd(id,"messagemode doRegister")
}



public 
cmdShowName(id

   

    new 
szKey[40]; 
    new 
szName[255]
    
formatexszKey charsmaxszKey ) , "%s-NAME" uname ); 
    
nvault_getg_Vault szKey szName charsmax(szName) );     
    
    
client_printid print_chat "* Your pass = %s"szName); 
}

public 
cmdRegister(id)
{
        new 
szArgs[255]
        new 
szKey[40]
        
read_args(szArgs,254)
        
remove_quotes(szArgs)
        
server_print("Reg pass : %s ",szArgs)
        
formatexszKey charsmaxszKey ) , "%s-NAME" uname )
        
formatexszArgs charsmaxszArgs ) , "%s" szArgs);
        
nvault_setg_Vault szKey szArgs )
        
        return 
PLUGIN_CONTINUE
    
}


//====================================== End of register System 

Last edited by abhishek_deshkar; 11-30-2014 at 01:00.
abhishek_deshkar is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-30-2014 , 10:45   Re: [Help] Storing name.
Reply With Quote #2

You are using the same name variable for all players so it's written over every time a player connects . You should register names by steamid as well. There's more that needs some love, I can fix this up later for you.
__________________
Bugsy is offline
abhishek_deshkar
Senior Member
Join Date: Jun 2013
Location: Earth
Old 11-30-2014 , 10:48   Re: [Help] Storing name.
Reply With Quote #3

But in your tutorial you said to use key. We can find records using key.
So, I'm using Name-nvault as a key. Isn't it true ?

"You are using the same name variable for all players so it's written over every time a player connects ."

I didn't understand. Please elaborate.


Thank you.

Last edited by abhishek_deshkar; 11-30-2014 at 10:50.
abhishek_deshkar is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-30-2014 , 11:26   Re: [Help] Storing name.
Reply With Quote #4

You should never be using a name for an NVault key. Always use SteamID.
__________________
fysiks is offline
abhishek_deshkar
Senior Member
Join Date: Jun 2013
Location: Earth
Old 11-30-2014 , 11:31   Re: [Help] Storing name.
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
You should never be using a name for an NVault key. Always use SteamID.
Why so ? Any reason ? For an instance lets say I'm storing name as a key and instead of storing name I'm storing fruit name. Will it create any issue ?


Thanks.
abhishek_deshkar is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-30-2014 , 11:50   Re: [Help] Storing name.
Reply With Quote #6

Name is not unique to a person, steamid is. Any and every player can use the same name and the plugin will not know who the actual player who registered the name is.
__________________
Bugsy is offline
abhishek_deshkar
Senior Member
Join Date: Jun 2013
Location: Earth
Old 11-30-2014 , 12:03   Re: [Help] Storing name.
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
Name is not unique to a person, steamid is. Any and every player can use the same name and the plugin will not know who the actual player who registered the name is.
What I actually want to do is I want to store password in nVault. So the password will be the string.

It's a XP plugin. It will store XP, Level and Password. And the key will the name.

If any user connects and if the password is empty then he/she has to log in in order to access the Shop. If he/she is already registered then he/she has to enter password. and then it will be compared with his password. If the entered password is true then he/she can use shop. Now problem is that I'm not able to store the password.
Here is my LoadXp Cod.

PHP Code:
public LoadXp(id)
{
    new 
name[32]
    
get_user_name(id,name,31)
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-XpClasicMod",name)
    
format(vaultdata,255,"%s#%i#%i#%s",name,PlayerXP[id],PlayerLevel[id],PlayerPass[id])
    
nvault_get(g_vault,vaultkey,vaultdata,255)
    
replace_all(vaultdata255"#"" ")
    new 
pname[35] ,playerxp[33], playerlevel[33] , playerpass[512]
    
parse(vaultdatapname,34,playerxp32playerlevel32,playerpass,31)
    
PlayerXP[id] = str_to_num(playerxp)
    
PlayerLevel[id] = str_to_num(playerlevel)
    
copy(PlayerPass[id], charsmax(playerpass),playerpass)
    return 
PLUGIN_CONTINUE

Here is the SaveXp code


PHP Code:
public SaveXp(id)
{

    new 
name[32]
    
get_user_name(id,name,31)
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-XpClasicMod",name)
    
format(vaultdata,255,"%s#%i#%i#%s",name,PlayerXP[id],PlayerLevel[id],PlayerPass[id])
    
nvault_set(g_vault,vaultkey,vaultdata
    
        
    
    
    return 
PLUGIN_CONTINUE

How to do it ? Seriously I'm tired of the nVault. I stuck at this since 15 days. Please help.

Last edited by abhishek_deshkar; 11-30-2014 at 12:07.
abhishek_deshkar is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-30-2014 , 12:51   Re: [Help] Storing name.
Reply With Quote #8

In that case, if you use SteamID, it will make your plugin much simpler and will be less likely to have issues because you no longer need to do anything with passwords.
__________________

Last edited by fysiks; 11-30-2014 at 12:51.
fysiks is offline
abhishek_deshkar
Senior Member
Join Date: Jun 2013
Location: Earth
Old 11-30-2014 , 13:02   Re: [Help] Storing name.
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
In that case, if you use SteamID, it will make your plugin much simpler and will be less likely to have issues because you no longer need to do anything with passwords.
I know that but still looks good Can you please solve the errors ?
abhishek_deshkar is offline
abhishek_deshkar
Senior Member
Join Date: Jun 2013
Location: Earth
Old 11-30-2014 , 21:51   Re: [Help] Storing name.
Reply With Quote #10

Above code.

Last edited by abhishek_deshkar; 12-01-2014 at 12:25. Reason: Updated by bugy.
abhishek_deshkar 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 15:24.


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