INI help
#1

Well it saves the variables fine but there's something wrong on OnPlayerConnect because it don't convert the INI variables to the enum's variables correctly, so like I set my pScore to 20 and pAdmin to 1 in the INI file and when I log in it doesn't convert it to the enum's variables and it stays 0.
PHP код:
public OnPlayerConnect(playerid)
{
    
GameTextForPlayer(playerid"~w~Team Deathmatch",3000,1);
    
SetPlayerColor(playerid0xFFFFFF00);
    if(
gCriminals == && gSWAT 0)
    {
        new 
string[128], Name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridNamesizeof(Name));
        
format(stringsizeof(string), "%s has logged in \n New round is starting up..."Name);
        
SendClientMessageToAll(COLOR_WHITEstring);
        
SetEveryoneToSpawn(playerid);
    }
    if(
fexist(UserPath(playerid)))
    {
         
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
        
SetPlayerScore(playeridPlayerInfo[playerid][pScore]);
    }
    return 
1;
}
stock LoadUser_data(playerid,name[],value[])
{
    
INI_Int("Score"PlayerInfo[playerid][pScore]);
    
INI_Int("Admin"PlayerInfo[playerid][pAdmin]);
}
stock UserPath(playerid)
{
    new 
string[128],playername[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,playername,sizeof(playername));
    
format(string,sizeof(string),PATH,playername);
    return 
string;

Reply
#2

I really hate bumping my thread but it's already in the second page, no way that anyone gonna see it there.
Reply
#3

You're not calling 'LoadUser_data' anywhere under OnPlayerConnect.
Reply
#4

As I told you before, in y_ini this is the way of calling it, ParseFile.
Reply
#5

Quote:
Originally Posted by Tomer!.$
Посмотреть сообщение
As I told you before, in y_ini this is the way of calling it, ParseFile.
I don't think you told me before. But either way, I don't get why you have 'LoadUser_%s' instead of 'LoadUser_data'.
Reply
#6

I thought that I should use LoadUser_%s in INI_ParseFile.
Код:
public OnPlayerDisconnect(playerid, reason)
{
	new
 		INI:iniFile = INI_Open(UserPath(playerid)), score = GetPlayerScore(playerid);
 	INI_SetTag(iniFile, "data");
  	INI_WriteInt(iniFile, "Score", score);
  	INI_WriteInt(iniFile, "Admin", PlayerInfo[playerid][pAdmin]);
   	INI_Close(iniFile);
	return 1;
}
Reply
#7

Do you have an idea why it isn't working?
Reply
#8

By the way I learnt from somebody's tutorial for register and login system in Y_INI, maybe the tutorial was wrong I dunno.
Reply
#9

Yes and I didn't understand everything, I set it to return 1; and it's still not working, LoadUser_data is called in INI_ParseFile, I prefer learning y_ini instead of uvar, I dunno what's debug and how it's related to y_ini, that's what's written to the file:

Код:
[data]
Score = 20
Admin = 1
Reply
#10

Debugged it, and there's something wrong with LoadUser_data, it is not showing any print messages in LoadUser_data, here is the function INI_ParseFile and the LoadUser_data stock below:
Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

stock LoadUser_data(playerid,name[],value[])
{
print("LoadUser: Before Score");
INI_Int("Score", PlayerInfo[playerid][pScore]);
print("LoadUser: After Score");
INI_Int("Admin", PlayerInfo[playerid][pAdmin]);
print("LoadUser: After Admin");
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)