stats not saving y_ini
#1

hello guys, I've made a login/register system according to a tutorial by Andy, but it seems that it doesn't save the stats of my player when I relog back, it doesn't save my money, score, k/d, pos and weapons?

What do I have to change to get it to work? (Everything compiles fine tho)

thanks in advance for the help!
Reply
#2

U have not made variables of that
Reply
#3

This one is working perfectly..

https://sampforum.blast.hk/showthread.php?tid=273088
Reply
#4

Quote:
Originally Posted by Micko123
Посмотреть сообщение
Ahm, the tutorials are the same, I've tried with both of them, but this keeps happening, it save my faction, fac rank, admin level, but it doesnt save my money and my score, weapons nor position..that's what I was asking how to code, since it's not explained in the tutorial hehe

i am really a newbie scripter, that's why I ask so much, but I just really want to learn it..so if you could post an example that will be awsome! thanks
Reply
#5

You start by adding variables you want to save in the enum:
Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pNextVariable,
    pVariableForSavingFactionRank,
    pVariableForSavingFactionEtc
}
Then you add to load them in the LoadUser_data function (more information about reading different TYPES can be read about here https://sampforum.blast.hk/showthread.php?tid=570957):
Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
	INI_Int("Password",PlayerInfo[playerid][pPass]);
	INI_Int("Cash",PlayerInfo[playerid][pCash]);
	INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
	INI_Int("Kills",PlayerInfo[playerid][pKills]);
        INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
        INI_Int("FactionRank",PlayerInfo[playerid][pVariableForSavingFactionRank]);
        INI_Int("FactionEtc",PlayerInfo[playerid][pVariableForSavingFactionEtc]);
 	return 1;
}
When you want to write to those you simply do same as Step X/XI but you add your variables as well:
Код:
       INI_WriteInt(File,"FactionRank",0); //or any other value instead of 0
       INI_WriteInt(File,"FactionEtc",0); //or any other value instead of 0
When you don't want to save them in the file (at least not directly) but do want to save them in-game you simply just:
Код:
       PlayerInfo[playerid][pVariableForSavingFactionEtc] = SOME_VARIABLE_ASSIGNED;
Obviously I didn't make everything complete, the whole faction system for instance will have to be implemented by you. Reading the y_ini thread will help a lot: https://sampforum.blast.hk/showthread.php?tid=570957 or https://sampforum.blast.hk/showthread.php?tid=570912
Reply
#6

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
You start by adding variables you want to save in the enum:
Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pNextVariable,
    pVariableForSavingFactionRank,
    pVariableForSavingFactionEtc
}
Then you add to load them in the LoadUser_data function (more information about reading different TYPES can be read about here https://sampforum.blast.hk/showthread.php?tid=570957):
Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
	INI_Int("Password",PlayerInfo[playerid][pPass]);
	INI_Int("Cash",PlayerInfo[playerid][pCash]);
	INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
	INI_Int("Kills",PlayerInfo[playerid][pKills]);
        INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
        INI_Int("FactionRank",PlayerInfo[playerid][pVariableForSavingFactionRank]);
        INI_Int("FactionEtc",PlayerInfo[playerid][pVariableForSavingFactionEtc]);
 	return 1;
}
When you want to write to those you simply do same as Step X/XI but you add your variables as well:
Код:
       INI_WriteInt(File,"FactionRank",0); //or any other value instead of 0
       INI_WriteInt(File,"FactionEtc",0); //or any other value instead of 0
When you don't want to save them in the file (at least not directly) but do want to save them in-game you simply just:
Код:
       PlayerInfo[playerid][pVariableForSavingFactionEtc] = SOME_VARIABLE_ASSIGNED;
Obviously I didn't make everything complete, the whole faction system for instance will have to be implemented by you. Reading the y_ini thread will help a lot: https://sampforum.blast.hk/showthread.php?tid=570957 or https://sampforum.blast.hk/showthread.php?tid=570912
Well, let's say I did this:
Код:
CMD:money(playerid, params[])
{
	if(IsPlayerAdmin(playerid))
	{
	    SendClientMessage(playerid, COLOR_ADM, "* [AdmCMD]: You have recived 100,000$!");
		GivePlayerMoney(playerid, 100000);
		new INI:file = INI_Open(UserPath(playerid));
    	INI_SetTag(file,"PlayerInfo");
    	INI_WriteInt(file, "Money", PlayerInfo[playerid][Money]);
    	INI_Close(file);
	}
	else SendClientMessage(playerid, COLOR_SYS, "* [SYSTEM]: You are not an admin!");
	return 1;
}
is the data saving done correctly? since when i use /stats it leaves everything on 0..
Код:
//stats cmds

CMD:stats(playerid, params[])
{
    new money = PlayerInfo[playerid][Money];
    new deaths = PlayerInfo[playerid][Deaths];
    new kills = PlayerInfo[playerid][Kills];
    new score = PlayerInfo[playerid][Score];
    new admin = PlayerInfo[playerid][AdminLevel];
    new string[128];
    format(string, sizeof(string), "[General] - [Money: %d] | [Deaths: %d] | [Kills: %d] | [Score: %d] | [Admin Level: %d]", money, deaths, kills, score, admin);
    SendClientMessage(playerid, COLOR_GREEN, string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)