Saving stats
#1

Код:
public OnPlayerDisconnect(playerid, reason)
{
    SavePlayer(playerid);
	return 1;
}
Код:
stock SavePlayer(playerid)
{
	if(GetPVarInt(playerid,"LoggedIn") == 1)
	{
		new name[24];
		GetPlayerName(playerid,name,sizeof name);
		dUserSetINT(name).("Deaths",GetPVarInt(playerid,"Deaths"));
	    dUserSetINT(name).("Kills",GetPVarInt(playerid,"Kills"));
	    dUserSetINT(name).("Money",GetPVarInt(playerid,"Money"));
	    dUserSetINT(name).("Color",GetPVarInt(playerid,"Color"));
	    dUserSetINT(name).("Level",GetPVarInt(playerid,"Level"));

		new ip[16];
		GetPVarString(playerid,"IP",ip,16);
	    dUserSet(name).("IPAddress",ip);
    }
}
Why stats dont save?
Reply
#2

Did you created a new folder where stats will be saved ?
Reply
#3

No cuz i save them in scriptfiles(not any other specifid folder)But that's not problem.
Reply
#4

There is no file path for the player to save to.
Reply
#5

I dont understand,players register and in scriptfiles create account from player...but stats dont write in
Reply
#6

pawn Код:
OnPlayerDisconnect

new file[256], n[MAX_PLAYER_NAME]; GetPlayerName(playerid,n,sizeof(n));  format(file,sizeof(file),"Users/%s.sav",n);

//your stuff

SavePlayer

new file[256]; format(file,sizeof(file),"Users/%s.sav",name);

//your stuff
Reply
#7

i added that but still dont work i guess i need somethin add in login and register...
Код:
dcmd_register(playerid,params[])
{
	new pass[24];
	if (sscanf(params, "s[24]",pass)) return SendClientMessage(playerid,COLOR_RED,"* Usage: /register <password>");
	new name[24];
	GetPlayerName(playerid,name,sizeof(name));
	if (udb_Exists(name)) return SendClientMessage(playerid,COLOR_RED,"This username is already taken, choose another one!");
	new ip[16];
	GetPlayerName(playerid,name,sizeof(name));
	GetPlayerIp(playerid,ip,16);
	if(udb_Create(name,params))
	{
		SetPVarInt(playerid,"LoggedIn",1);
		dUserSet(name).("IPAddress",ip);
		SendClientMessage(playerid,COLOR_GREEN, "You have been registered and logged in.");
		PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
	}
	return 1;
}

dcmd_login(playerid,params[])
{
	new pass[24];
	if (sscanf(params, "s[24]",pass)) return SendClientMessage(playerid,COLOR_RED,"Usage: /login <password>");
	   new name[24]; GetPlayerName(playerid,name,24);
	if (!udb_Exists(name)) return SendClientMessage(playerid,COLOR_RED,"Account doesn't exist, please use '/register [password]'.");
    if (udb_CheckLogin(name,params))
	{
		new tmp3[16];
   		GetPlayerIp(playerid,tmp3,16);
	   	dUserSet(name).("IPAddress",tmp3);
		LoginPlayer(playerid);
       	SendClientMessage(playerid,COLOR_GREEN,"Successfully Logged In");
	}
	else SendClientMessage(playerid,COLOR_RED,"Login failed! Incorrect Password.");
	return 1;
}
Reply
#8

Im not familiar to that INC your using, but it seems right to me.

My theory is that when a player types /q the player stats get automatically deleted as a nice feature of GetPVar.
I think that because that the server will first have to call the OnPlayerDisconnect callback and then get the information from the stock, the stats gets deleted before they get saved in the file. This can also be seen in alot of cases when you disconnect that the IP will be shown as 255.255.255.255. Try to move the saving code to the callback itself, or update the file whenever the information changes (like he dies or gets a higher or lower ammount of money)
Reply
#9

Im not pro scripter,but im sure on register i need add something to create account(with kills,deaths,money,color,level) in "users" folder
Reply
#10

You maybe forgot to SetPVarInt (LoggedIn) when the player logs in, since we cannot see your LoginPlayer function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)