Problem with saving system using y_ini
#1

Here is my SaveUser code:
Код:
forward SaveUser(playerid);
public SaveUser(playerid)
{

    new float:x,float:y,float:z;
    GetPlayerPos(playerid,x,y,z);
    new float:health,float:armour;
     GetPlayerHealth(playerid,health);
     GetPlayerArmour(playerid,armour);
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"BankCash",BankCash[playerid]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Helmets",Helmets[playerid]);
    INI_WriteInt(File,"Vests",Vests[playerid]);
    INI_WriteInt(File,"Medikits",Medikits[playerid]);
    INI_WriteInt(File,"Job",PlayerJob[playerid]);
    INI_WriteFloat(File,"Health",health,2); 
    INI_WriteFloat(File,"Armour",armour,2);
    INI_WriteInt(File,"Mats",PlayerInfo[playerid][pMats]);
	INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
    INI_WriteInt(File,"SalaryDate",SalaryDate[playerid]);
    INI_WriteInt(File,"JobLevel",PlayerInfo[playerid][JobLevel]);
    INI_WriteFloat(File,"PosX",x);
    INI_WriteFloat(File,"PosY",y); 
    INI_WriteFloat(File,"PosZ",z);
    INI_Close(File);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"Data saved!");
    return 1;
}
when data saved it send client message to player "Data saved!"
but when i updated the script it showing Unknown command and also not saving data

full code(included : command,disconnect,loaduser,saveuser):
Код:
public OnPlayerDisconnect(playerid, reason)
{

	SaveUser(playerid);
	return 1;
}

CMD:savedata(playerid, params[])
{
	SaveUser(playerid);
	return 1;
}

forward SaveUser(playerid);
public SaveUser(playerid)
{

    new float:x,float:y,float:z;
    GetPlayerPos(playerid,x,y,z);
    new float:health,float:armour;
     GetPlayerHealth(playerid,health);
     GetPlayerArmour(playerid,armour);
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"BankCash",BankCash[playerid]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Helmets",Helmets[playerid]);
    INI_WriteInt(File,"Vests",Vests[playerid]);
    INI_WriteInt(File,"Medikits",Medikits[playerid]);
    INI_WriteInt(File,"Job",PlayerJob[playerid]);
    INI_WriteFloat(File,"Health",health,2); 
    INI_WriteFloat(File,"Armour",armour,2); 
    INI_WriteInt(File,"Mats",PlayerInfo[playerid][pMats]);
	INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
    INI_WriteInt(File,"SalaryDate",SalaryDate[playerid]);
    INI_WriteInt(File,"JobLevel",PlayerInfo[playerid][JobLevel]);
    INI_WriteFloat(File,"PosX",x);
    INI_WriteFloat(File,"PosY",y);
    INI_WriteFloat(File,"PosZ",z); 
    INI_Close(File);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"Data saved!");
    return 1;
}

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("BankCash",PlayerInfo[playerid][pBankCash]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Helmets",Helmets[playerid]);
    INI_Int("Vests",Vests[playerid]);
    INI_Int("Medikits",Medikits[playerid]);
    INI_Int("Job",PlayerJob[playerid]);
    INI_Float("Health",PlayerInfo[playerid][pHealth]); 
    INI_Float("Armour",PlayerInfo[playerid][pArmour]); 
    INI_Int("Mats",PlayerInfo[playerid][pMats]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("SalaryDate",SalaryDate[playerid]);
    INI_Int("JobLevel",PlayerInfo[playerid][JobLevel]);
    INI_Float("PosX",PlayerInfo[playerid][PosX]); 
    INI_Float("PosY",PlayerInfo[playerid][PosY]); 
    INI_Float("PosZ",PlayerInfo[playerid][PosZ]);




    OldMats[playerid] = PlayerInfo[playerid][pMats];
     return 1;
}
Reply
#2

Get crashdetect and see what the console says when the problem appears.

Also, regarding this line:
pawn Код:
INI_Int("Password",PlayerInfo[playerid][pPass]);
Unless you're using udb_hash, you should save the password as a string, but also you should use a better hash function if that's the case, like SHA256.
Reply
#3

Quote:
Originally Posted by DTV
Посмотреть сообщение
Get crashdetect and see what the console says when the problem appears.

Also, regarding this line:
pawn Код:
INI_Int("Password",PlayerInfo[playerid][pPass]);
Unless you're using udb_hash, you should save the password as a string, but also you should use a better hash function if that's the case, like SHA256.
crashdetect result is:
Код:
[debug] Run time error 6: "Invalid instruction"
[debug]  Unknown opcode 0x0 at address 0x00000044
[debug] AMX backtrace:
[debug] #0 00000044 in public cmd_givefirefighterjob () from cdm.amx
[debug] #1 native CallLocalFunction () [004743b0] from samp-server.exe
[debug] #2 00004bf8 in public OnPlayerCommandText () from cdm.amx
what does it means?

givefirefighterjob command:
Код:
CMD:givefirefighterjob(playerid, params[])
{
	new string[256],year,month,day;
    getdate(year, month, day);
    format(string, sizeof string, "%d/%s%d/%s%d", day, ((month < 10) ? ("0") : ("")), month, (year < 10) ? ("0") : (""), year);
	if(PlayerJob[playerid] == 8)
	{
		new targetid,pName[MAX_PLAYER_NAME];
		if(sscanf(params,"u", targetid)) return SendClientMessage(playerid,COLOR_RED , "Correct Usage: /givefirefighterjob [Playerid]");
		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_RED,"Player not connected.");
		GetPlayerName(targetid,pName,sizeof(pName));
		new msg[126],lName[MAX_PLAYERS];
		GetPlayerName(playerid,lName,sizeof(lName));
		format(msg,sizeof(msg),"{FFFF00}[FireFighter]{FFFFFF}You are now a firefighter. Job given by fire department leader %s.",lName);
		PlayerJob[targetid] = 7;
		SendClientMessage(targetid,COLOR_GREEN,msg);
		new msg2[126];
		format(msg2,sizeof(msg2),"{FFFF00}[FireFighter]{FFFFFF}You given firefighter job to %s",pName);
		SendClientMessage(playerid,COLOR_GREEN,msg2);
        JobSalary[playerid] = gettime() + 604800;
        new job[126];
        format(job,sizeof(job),"Your Job Code Is %i | Saray at : %i",PlayerJob[targetid],JobSalary[playerid]);
        SendClientMessage(targetid,COLOR_GREEN,job);
        //PlayerInfo[targetid][JobSalary] = gettime()+604800;
        SaveUser(playerid);
	}
	else
	{
	    SendClientMessage(playerid,COLOR_RED,"{FF0000}[Insufficient]{FFFFFF}You don't have sufficient power to use this command.");
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)