[DINI] Help, why doesnt this work?
#1

Hey SAMP forum..

I've made a register system, and
OnPlayerDisconnect i have SaveStats(playerid);

like this
Код:
OnPlayerDisconnect(playerid)
{
   SaveStats(playerid);
   return 1;
}
and my SaveStats func. is

Код:
stock SaveStats(playerid)
{
	if(IsLogged[playerid] == 1)
	{
		new file[24+15];
		new PName[MAX_PLAYER_NAME];
		GetPlayerName(playerid, PName, sizeof(PName));
		format(file,sizeof(file),"N-Register/users/%s.ini",PName);

		dini_IntSet(file,"Cash", GetPlayerMoney(playerid));
		dini_IntSet(file,"Score", GetPlayerScore(playerid));
	}
}
Why doesnt it work?
Reply
#2

Did you make the folders:
N-Register and Users?
Reply
#3

Yes, the file saves etc. but when i exit the game it doesnt save my score and money
Reply
#4

Are you sure IsLogged[playerid] = = 1?
Reply
#5

That variable is 1 for sure because the file saves, except it won't write any data. By the way, this looks almost the similair to my function that saves a players' file, I recommend dudb for you.
Reply
#6

Quote:
Originally Posted by KnooL
That variable is 1 for sure because the file saves, except it won't write any data. By the way, this looks almost the similair to my function that saves a players' file, I recommend dudb for you.
My bad, so I assume every other variable saves?
Reply
#7

There are a couple errors. I don't know whether or not they will solve your problem, but:
pawn Код:
OnPlayerDisconnect(playerid, reason)
This callback also has the parameter "reason".
pawn Код:
new file[39];
Don't make the script do extra.

Also, SaveStats should return 1.

--------
Also, try making the variable "file" have a larger string. E.G.
pawn Код:
new file[128];
Reply
#8

Quote:
Originally Posted by _Xerxes_
There are a couple errors. I don't know whether or not they will solve your problem, but:
pawn Код:
OnPlayerDisconnect(playerid, reason)
This callback also has the parameter "reason".
pawn Код:
new file[39];
Don't make the script do extra.

Also, SaveStats should return 1.

--------
Also, try making the variable "file" have a larger string. E.G.
pawn Код:
new file[128];
1) It doesn't matter if you return any value, using a stock.
2) There's no point in creating extra cells that WON'T get used.
Reply
#9

1.You should return a value to a function whether it is a stock or not.
2. Currently "39" is to small to read that whole format. (The root+name of player). So it will be used.
Reply
#10

Quote:
Originally Posted by _Xerxes_
1.You should return a value to a function whether it is a stock or not.
2. Currently "39" is to small to read that whole format. (The root+name of player). So it will be used.
1) No, you shouldn't, nor do you have to.
2) Yes, it is, but 128 cells aren't needed for something that is 45 characters long MAX_PLAYER_NAME is 24 characters and "N-Register/users/.ini" (not including the player name) is 21 characters, so 21+24=45.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)