AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Storing name. (https://forums.alliedmods.net/showthread.php?t=252305)

abhishek_deshkar 11-30-2014 00:58

[Help] Storing name.
 
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 


Bugsy 11-30-2014 10:45

Re: [Help] Storing name.
 
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.

abhishek_deshkar 11-30-2014 10:48

Re: [Help] Storing name.
 
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. :)

fysiks 11-30-2014 11:26

Re: [Help] Storing name.
 
You should never be using a name for an NVault key. Always use SteamID.

abhishek_deshkar 11-30-2014 11:31

Re: [Help] Storing name.
 
Quote:

Originally Posted by fysiks (Post 2229780)
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.

Bugsy 11-30-2014 11:50

Re: [Help] Storing name.
 
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.

abhishek_deshkar 11-30-2014 12:03

Re: [Help] Storing name.
 
Quote:

Originally Posted by Bugsy (Post 2229782)
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.

fysiks 11-30-2014 12:51

Re: [Help] Storing name.
 
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.

abhishek_deshkar 11-30-2014 13:02

Re: [Help] Storing name.
 
Quote:

Originally Posted by fysiks (Post 2229800)
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 ? :(

Bugsy 11-30-2014 15:42

Re: [Help] Storing name.
 
I don't understand why you do not use steamID and automate this password stuff. Is your server non-steam or something? The only purpose I can see for this is if multiple users (brother\sister\friends) all use the same steam account, this would separate each individual users XP. I'm willing to help, but I need more of an understanding of exactly what you are trying to accomplish. Give an explanation in words not code.


All times are GMT -4. The time now is 15:24.

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