Solved Save Coins Nickname

Coding Help/Re-API Supported
Post Reply
mzqx
Member
Member
Moldova
Posts: 25
Joined: 7 years ago
Contact:

Save Coins Nickname

#1

Post by mzqx » 7 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
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#2

Post by Night Fury » 7 years ago

It's correct.
Better use charsmax instead of writing 31.
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

mzqx
Member
Member
Moldova
Posts: 25
Joined: 7 years ago
Contact:

#3

Post by mzqx » 7 years ago

Jack GamePlay wrote: 7 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
Paraguay
Posts: 678
Joined: 7 years ago
Location: Paraguay
Contact:

#4

Post by johnnysins2000 » 7 years ago

mzqx wrote: 7 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
Posts: 2214
Joined: 7 years ago
Contact:

#5

Post by Raheem » 7 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 7 years ago, edited 1 time in total.
Reason: charsmax not charmax.......
He who fails to plan is planning to fail

mzqx
Member
Member
Moldova
Posts: 25
Joined: 7 years ago
Contact:

#6

Post by mzqx » 7 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
Posts: 2214
Joined: 7 years ago
Contact:

#7

Post by Raheem » 7 years ago

Code updates, See it.
He who fails to plan is planning to fail

mzqx
Member
Member
Moldova
Posts: 25
Joined: 7 years ago
Contact:

#8

Post by mzqx » 7 years ago

Holly.. how i miss that
Thanks.

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#9

Post by Raheem » 7 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.
He who fails to plan is planning to fail

mzqx
Member
Member
Moldova
Posts: 25
Joined: 7 years ago
Contact:

#10

Post by mzqx » 7 years ago

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

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#11

Post by Raheem » 7 years ago

You don't need to know his name, Just he will give you his name and then you will search for it and then back to him his coins. Or you mean if he re-installed his game in case he is no-steam so he won't be able to remember his old steamid. Ok anyway you can do it as you need. And in next release i'll make cvar so one can use names, steamids, ips.
He who fails to plan is planning to fail

mzqx
Member
Member
Moldova
Posts: 25
Joined: 7 years ago
Contact:

#12

Post by mzqx » 7 years ago

Raheem wrote: 7 years ago You don't need to know his name, Just he will give you his name and then you will search for it and then back to him his coins. Or you mean if he re-installed his game in case he is no-steam so he won't be able to remember his old steamid. Ok anyway you can do it as you need. And in next release i'll make cvar so one can use names, steamids, ips.
Yes he won't be able to remember his old steam id if he reinstall the game.

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#13

Post by Raheem » 7 years ago

Ok, That's good reason. So use register system as you said. It will be nice idea.
He who fails to plan is planning to fail

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#14

Post by Night Fury » 6 years ago

Raheem! Feel Freedom without studying..It's good feeling if you're studying & other people like me playing. :P :P
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#15

Post by Raheem » 6 years ago

Jack GamePlay wrote: 6 years ago Raheem! Feel Freedom without studying..It's good feeling if you're studying & other people like me playing. :P :P
You are noob and study things you don't like but i'am studying things i like so for me studying is same as playing...... 8-)
Also what is the relation between your comment and this topic :?: :?:
He who fails to plan is planning to fail

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 7 guests