Page 1 of 2

Save Coins Nickname

Posted: 24 Apr 2017, 14:22
by mzqx
I want to know if is right like this

Code: Select all

public LoadCoins(id)
{
	new szName[32], iStartValue
	iStartValue = get_pcvar_num(Cvar_Start_Coins)
	
	get_user_name(id, szName, 31);
	
	new szData[16]
	
	if(fvault_get_data(g_szVaultName, szName, szData, sizeof(szData) - 1))
	{
		g_iEscapeCoins[id] = str_to_num(szData)
	}
	else
	{
		g_iEscapeCoins[id] = iStartValue
	}
}

public SaveCoins(id)
{
	new szName[32], iMaxValue;
	iMaxValue = get_pcvar_num(Cvar_Max_Coins)
	
	get_user_name(id, szName, 31);
	
	// Set Him to max if he Higher than Max Value
	if(g_iEscapeCoins[id] > iMaxValue)
	{
		g_iEscapeCoins[id] = iMaxValue
	}
	
	new szData[16]
	num_to_str(g_iEscapeCoins[id], szData, sizeof(szData) - 1)
	
	// Save His Name, Escape Coins
	fvault_set_data(g_szVaultName, szName, szData)
}
If not give me your version.

Re: Save Coins Nickname

Posted: 24 Apr 2017, 15:04
by Mohamed Alaa
It's correct.
Better use charsmax instead of writing 31.

Re: Save Coins Nickname

Posted: 24 Apr 2017, 15:15
by mzqx
Jack GamePlay wrote:
3 Years Ago
It's correct.
Better use charsmax instead of writing 31.
Do you want to make your version? and give me code here?

Re: Save Coins Nickname

Posted: 24 Apr 2017, 16:45
by johnnysins2000
mzqx wrote:
3 Years Ago
I want to know if is right like this

Code: Select all

public LoadCoins(id)
{
	new szName[32], iStartValue
	iStartValue = get_pcvar_num(Cvar_Start_Coins)
	
	get_user_name(id, szName, 31);
	
	new szData[16]
	
	if(fvault_get_data(g_szVaultName, szName, szData, sizeof(szData) - 1))
	{
		g_iEscapeCoins[id] = str_to_num(szData)
	}
	else
	{
		g_iEscapeCoins[id] = iStartValue
	}
}

public SaveCoins(id)
{
	new szName[32], iMaxValue;
	iMaxValue = get_pcvar_num(Cvar_Max_Coins)
	
	get_user_name(id, szName, 31);
	
	// Set Him to max if he Higher than Max Value
	if(g_iEscapeCoins[id] > iMaxValue)
	{
		g_iEscapeCoins[id] = iMaxValue
	}
	
	new szData[16]
	num_to_str(g_iEscapeCoins[id], szData, sizeof(szData) - 1)
	
	// Save His Name, Escape Coins
	fvault_set_data(g_szVaultName, szName, szData)
}
If not give me your version.
U are trying to make save coins code?

In my Opinion fvault is also ok but if u use nvault it would be better

and use charsmax which like this [31] u have written [32] those are strings

Re: Save Coins Nickname

Posted: 24 Apr 2017, 16:54
by Raheem
johnnysins2000, We use fVault bro as it's easy to edit it's just a .txt file so if you need to delete or edit any player account it will be so easy. Also it's same as nVault so we use fVault better.

mzqx, Jack mean to do like:
    1. public LoadCoins(id)
    2. {
    3.     new szName[32], iStartValue
    4.     iStartValue = get_pcvar_num(Cvar_Start_Coins)
    5.    
    6.     get_user_name(id, szName, charsmax(szName));
    7.    
    8.     new szData[16]
    9.    
    10.     if(fvault_get_data(g_szVaultName, szName, szData, sizeof(szData) - 1))
    11.     {
    12.         g_iEscapeCoins[id] = str_to_num(szData)
    13.     }
    14.     else
    15.     {
    16.         g_iEscapeCoins[id] = iStartValue
    17.     }
    18. }
    19.  
    20. public SaveCoins(id)
    21. {
    22.     new szName[32], iMaxValue;
    23.     iMaxValue = get_pcvar_num(Cvar_Max_Coins)
    24.    
    25.     get_user_name(id, szName, charsmax(szName));
    26.    
    27.     // Set Him to max if he Higher than Max Value
    28.     if(g_iEscapeCoins[id] > iMaxValue)
    29.     {
    30.         g_iEscapeCoins[id] = iMaxValue
    31.     }
    32.    
    33.     new szData[16]
    34.     num_to_str(g_iEscapeCoins[id], szData, sizeof(szData) - 1)
    35.    
    36.     // Save His Name, Escape Coins
    37.     fvault_set_data(g_szVaultName, szName, szData)
    38. }

Re: Save Coins Nickname

Posted: 24 Apr 2017, 17:31
by mzqx
Ok. Thanks
Solved.
EDIT: error 012 invalid function call, not a valid address... without charmax is working.

Re: Save Coins Nickname

Posted: 24 Apr 2017, 17:55
by Raheem
Code updates, See it.

Re: Save Coins Nickname

Posted: 24 Apr 2017, 18:13
by mzqx
Holly.. how i miss that
Thanks.

Re: Save Coins Nickname

Posted: 24 Apr 2017, 18:36
by Raheem
It's not advised to use names in saving the Escape Coins because anyone can enter with your name and steal all your Coins. Also for all should make auto generation for steamid in Dproto or ReUnion so no one can use steam changer to steal another player.

Re: Save Coins Nickname

Posted: 24 Apr 2017, 20:48
by mzqx
Raheem wrote:
3 Years Ago
It's not advised to use names in saving the Escape Coins because anyone can enter with your name and steal all your Coins. Also for all should make auto generation for steamid in Dproto or ReUnion so no one can use steam changer to steal another player.
I know... i will add /reg system.. who is smart will reg who is idiot will not.
on STEAMID i don't get their name and if a one player lose Coins from so much players data Coins will be lose
And player come at me and tell me he lost 10000 coins and where to know his nickname from steamid...?