save money problem!
#1

hey , i created a script! when player leaves server , his cash are saved intro a file : scriptfiles/sm/(player-name).ini
and when he's connecting , load money and gives to him! but when i exit server , and script must save ontro a file , samp-server.exe crashes and no file is saved!
i have:
pawn Код:
//on player connect
  new file[128];
  new pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\scriptfiles\\sm\\%s.ini", pname);
  GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
and
pawn Код:
//on player disconnect
  new file[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\scriptfiles\\sm\\%s.ini", pname);
  dini_Create(file);
  dini_IntSet(file, "money", GetPlayerMoney(playerid));
please help ppl
Reply
#2

i don't think thiere's anybody who don't knows how to do that!!!
Reply
#3

Quote:

GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(playerid, pname, sizeof(pname));

Why do you have 2 exactly same lines on same command?
Reply
#4

Quote:
Originally Posted by IntrozeN
Quote:

GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(playerid, pname, sizeof(pname));

Why do you have 2 exactly same lines on same command?
deleted it , but still crash ... thx for you help! , but still nothing
Reply
#5

Try this:
Код:
connect
  new file[128];
  new pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file,sizeof(file),"/sm/%s.ini", pname);
  	if(!dini_Exists(file))
	{
	dini_Create(file);
	print("\n >Player File created!");
	}
  if(!dini_Isset(file,"money")) dini_IntSet(file,"money",0);
  GivePlayerMoney(playerid, dini_Int(file,"money"));
	
	
disconnect	
  new file[128];
  new pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file,sizeof(file),"/sm/%s.ini", pname);
  dini_IntSet(file, "money", GetPlayerMoney(playerid));


And have you the "sm" folder in scriptfiles?
Reply
#6

OnPlayerConnect:
pawn Код:
new file[256],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
format(file,sizeof(file),"sm/%s.ini",pName);
SetPlayerMoney(playerid,dini_Int(file,"Money"));
OnPlayerDisconnect:
pawn Код:
new file[256],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
format(file,sizeof(file),"sm/%s.ini",pName);
new money = GetPlayerMoney(playerid);
if(!dini_Exists(file))
{
dini_Create(file);
}
dini_IntSet(file,"Money",money);
Reply
#7

thaaaank youu guuuys!! love ya all!
Reply


Forum Jump:


Users browsing this thread: