Resolved Save Coins Nickname

Coding Help/Re-API Supported
mzqx
Member
Member
Moldova
Posts: 25
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

Save Coins Nickname

#1

Post by mzqx » 2 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.

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 626
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 49 times
Age: 19
Contact:

#2

Post by Mohamed Alaa » 2 Years Ago

It's correct.
Better use charsmax instead of writing 31.
Want your own mod edition? PM me.
Accepting web projects.
CS 1.6 hosting: powergamingtech.com

mzqx
Member
Member
Moldova
Posts: 25
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

#3

Post by mzqx » 2 Years Ago

Jack GamePlay wrote:
2 Years Ago
It's correct.
Better use charsmax instead of writing 31.
Do you want to make your version? and give me code here?

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#4

Post by johnnysins2000 » 2 Years Ago

mzqx wrote:
2 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
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#5

Post by Raheem » 2 Years Ago

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. }
Last edited by Raheem on 24 Apr 2017, 17:56, edited 1 time in total.
Reason: charsmax not charmax.......
You don't know? Learn and you will know.

mzqx
Member
Member
Moldova
Posts: 25
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

#6

Post by mzqx » 2 Years Ago

Ok. Thanks
Solved.
EDIT: error 012 invalid function call, not a valid address... without charmax is working.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#7

Post by Raheem » 2 Years Ago

Code updates, See it.
You don't know? Learn and you will know.

mzqx
Member
Member
Moldova
Posts: 25
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

#8

Post by mzqx » 2 Years Ago

Holly.. how i miss that
Thanks.

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#9

Post by Raheem » 2 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.
You don't know? Learn and you will know.

mzqx
Member
Member
Moldova
Posts: 25
Joined: 2 Years Ago
Has thanked: 0
Been thanked: 0
Contact:

#10

Post by mzqx » 2 Years Ago

Raheem wrote:
2 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...?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest