Saving a file. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving a file. (
/showthread.php?tid=271433)
Saving a file. -
slymatt - 24.07.2011
When im in the game everything in the file saves.... but when i reloggin everything its set to 0 any help on why this could be?
Re: Saving a file. -
Bu$ter - 24.07.2011
mmh could you provide some more info like showing your file saving thing in your script? Would be much easier to help you
-
slymatt - 24.07.2011
should i post my full gamemode on a pastbin link?
everything saves untill they disconnect and then the stats return to 0 for everything i think il check again now though.
Ive just noticed that even when im not logged in the file is re-created when i delete it. =S could that be something to do with the savestates function i have that saves every 30 seconds?
Код:
public SaveStats(playerid)
{
for(playerid=0;playerid<MAX_PLAYERS;playerid++)
{
if(INI_Open(getINI(playerid)))
{
SendClientMessage(playerid, COLOUR_YELLOW, "SAVED!");
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
//INI_WriteInt("Age",PlayerInfo[playerid][Age]);
INI_WriteInt("Cash", GetPlayerMoney(playerid));
INI_WriteInt("Score", GetPlayerScore(playerid));
INI_WriteInt("Skin",GetPlayerSkin(playerid));
INI_WriteInt("Kills", killer[playerid]);
INI_WriteInt("Deaths", died[playerid]);
//INI_WriteInt("Hospital", PlayerInfo[playerid][Hospital]);
//INI_WriteInt("Timepalyed",PlayerInfo[playerid][Timeplayed]);
//INI_WriteString("Ipaddress",PlayerInfo[playerid][Ipaddress]);
INI_WriteFloat("Savedpositionx", x);
INI_WriteFloat("Savedpositiony", y);
INI_WriteFloat("Savedpositionz", z);
INI_WriteFloat("Savedpositiona", a);
INI_WriteInt("playersInterior", GetPlayerInterior(playerid));
INI_WriteInt("playersVworld", GetPlayerVirtualWorld(playerid));
INI_WriteInt("Admin",PlayerInfo[playerid][Admin]);
INI_WriteInt("Faction",PlayerInfo[playerid][Faction]);
INI_WriteInt("Factionrank",PlayerInfo[playerid][Factionrank]);
//INI_WriteInt("Bankdeposit",PlayerInfo[playerid][Bankdeposit]);
//INI_WriteInt("Banned",PlayerInfo[playerid][Banned]);
//INI_WriteString("Banreason",PlayerInfo[playerid][Banreason]);
//INI_WriteInt("House",PlayerInfo[playerid][House]);
//INI_WriteInt("Biz",PlayerInfo[playerid][Biz]);
//INI_WriteInt("Fightstyle",PlayerInfo[playerid][Fightstyle]);
//INI_WriteInt("Walkstyle", PlayerInfo[playerid][Walkstyle]);
//INI_WriteInt("TimesArrested", PlayerInfo[playerid][TimesArrested]);
//INI_WriteInt("Drivinglicense", PlayerInfo[playerid][Drivinglicense]);
//INI_WriteInt("Flyinglicense", PlayerInfo[playerid][Flyinglicense]);
//INI_WriteInt("Boatlicense", PlayerInfo[playerid][Boatlicense]);
//INI_WriteInt("GunLicense", PlayerInfo[playerid][Gunlicense]);
//INI_WriteInt("Car", PlayerInfo[playerid][Car]);
//INI_WriteInt("Job", PlayerInfo[playerid][Job]);
//INI_WriteInt("Earnings", PlayerInfo[playerid][Earnings]);
INI_Save();
INI_Close();
}
}
return 1;
}
ive added isplayerconnected to that piece of code which works as far as spawning goes but it now only saves once for you =(
Re: Saving a file. -
Finn - 24.07.2011
Please read the
y_ini thread carefully before you continue your scripting.
This is an example provided in that link above (
https://sampforum.blast.hk/showthread.php?tid=175565), which shows you how to write files correctly:
pawn Код:
new
INI:ini = INI_Open("myini.ini");
INI_WriteString(ini, "NAME", "******");
INI_WriteInt(ini, "SCORE", gScore);
INI_WriteFloat(ini, "HEALTH", health);
INI_Close(ini);
Re: Saving a file. -
slymatt - 24.07.2011
Sorted =P
it was nothing to do with writing to a file........