[Problem]Y_INI save accounts -
-[R]hysi- - 19.05.2012
Hi. Help me please .. I have a problem with Y_INI, use that data stored in OnPlayerDisconnect, but to restart the server accounts are not kept, at disconnected are stored properly, the problem is when the server is restarting.
Thank you for all.
Re: [Problem]Y_INI save accounts -
iGetty - 19.05.2012
Show us some code and maybe we can help you.
Respuesta: [Problem]Y_INI save accounts -
-[R]hysi- - 19.05.2012
I am using a script similar to this.
https://sampforum.blast.hk/showthread.php?tid=273088
Use this tutorial and put more variables but restarting is not saved = /
Re: [Problem]Y_INI save accounts -
iGetty - 19.05.2012
We need to see yours, not something "similar". If you're not willing to show the script, we can't help you. Simple as that.
Paste your registering, logging in and onplayerconnect functions here. Also, your onplayerdisconnect and ongamemodeinit.
Respuesta: [Problem]Y_INI save accounts -
-[R]hysi- - 19.05.2012
ok ok is much code for that but I stick here
Onplayerconnect
pawn Код:
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, Login, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}
Onplayerdisconnect
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
SetPlayerScore (playerid, Playerinfo[playerid][pLevel]);
GetPlayerPos( playerid,Playerinfo[playerid][pPos_x], Playerinfo[playerid][pPos_y], Playerinfo[playerid][pPos_z]);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Tutorial",Playerinfo[playerid][pTutorial]);
INI_WriteInt(File,"Admin",Playerinfo[playerid][pAdmin]);
INI_WriteInt(File,"Sex",Playerinfo[playerid][pSex]);
INI_WriteInt(File,"Age",Playerinfo[playerid][pAge]);
INI_WriteInt(File,"Facc",Playerinfo[playerid][pFaccn]);
INI_WriteInt(File,"Level",Playerinfo[playerid][pLevel]);
INI_WriteInt(File,"Origin",Playerinfo[playerid][pOrigin]);
INI_WriteInt(File,"skin",Playerinfo[playerid][pChar]);
INI_WriteInt(File,"Leader",Playerinfo[playerid][pLeader]);
INI_WriteInt(File,"Rank",Playerinfo[playerid][pRank]);
INI_WriteInt(File,"TRadio",Playerinfo[playerid][pWalkie]);
INI_WriteInt(File,"Phone",Playerinfo[playerid][pPnumber]);
INI_WriteInt(File,"Baned",Playerinfo[playerid][pBaned]);
INI_WriteFloat(File,"Posx",Playerinfo[playerid][pPos_x]);
INI_WriteFloat(File,"Posy",Playerinfo[playerid][pPos_y]);
INI_WriteInt( File, "Interior", GetPlayerInterior( playerid ) );
INI_WriteInt( File, "VirtualWorld", GetPlayerVirtualWorld( playerid ) );
INI_WriteInt(File,"Premium",Playerinfo[playerid][pPremium]);
INI_WriteInt(File,"Drugs",Playerinfo[playerid][pDrugs]);
INI_WriteInt(File,"Materials",Playerinfo[playerid][pMaterials]);
INI_WriteInt(File,"Speed",Playerinfo[playerid][pSpeed]);
//Y_INI
INI_Close(File);
return 1;
}
Ongamemodeinit
pawn Код:
public OnGameModeInit()
{
new string[MAX_PLAYER_NAME];
new string1[MAX_PLAYER_NAME];
for(new c=0;c<CAR_AMOUNT;c++)
{
Gas[c] = GasMax;
}
LoadCar();
CreateFoodMenus();
CreateGuideMenus();
LoadProperty();
LoadBizz();
LoadSBizz();
LoadBoxer();
LoadStuff();
LoadIRC();
LoadFamilies();
LoadCK();
LoadTurfs();
LoadPapers();
LoadDrugSystem();
LoadMatsSystem();
LoadHQLocks();
LoadTrunk();
IRCInfo[0][iPlayers] = 0; IRCInfo[1][iPlayers] = 0; IRCInfo[2][iPlayers] = 0;
IRCInfo[3][iPlayers] = 0; IRCInfo[4][iPlayers] = 0; IRCInfo[5][iPlayers] = 0;
IRCInfo[6][iPlayers] = 0; IRCInfo[7][iPlayers] = 0; IRCInfo[8][iPlayers] = 0;
IRCInfo[9][iPlayers] = 0;
News[hTaken1] = 0; News[hTaken2] = 0; News[hTaken3] = 0; News[hTaken4] = 0; News[hTaken5] = 0;
format(string, sizeof(string), "Nothing");
strmid(News[hAdd1], string, 0, strlen(string), 255);
strmid(News[hAdd2], string, 0, strlen(string), 255);
strmid(News[hAdd3], string, 0, strlen(string), 255);
strmid(News[hAdd4], string, 0, strlen(string), 255);
strmid(News[hAdd5], string, 0, strlen(string), 255);
format(string1, sizeof(string1), "No-one");
strmid(News[hContact1], string1, 0, strlen(string1), 255);
strmid(News[hContact2], string1, 0, strlen(string1), 255);
strmid(News[hContact3], string1, 0, strlen(string1), 255);
strmid(News[hContact4], string1, 0, strlen(string1), 255);
strmid(News[hContact5], string1, 0, strlen(string1), 255);
PlayerHaul[108][pCapasity] = 100;
PlayerHaul[109][pCapasity] = 100;
PlayerHaul[110][pCapasity] = 50;
PlayerHaul[111][pCapasity] = 50;
SetGameModeText("Los Angeles RP 0.3");
// SendRconCommand("mapname Los Angeles");
// SendRconCommand("weburl ");
format(objstore, sizeof(objstore), "MOLE: I got nothing, check back with me later.");
format(cbjstore, sizeof(cbjstore), "HQ: There is nothing in your Vicinity, Out.");
format(motd, sizeof(motd), "Welcome to the Los Angeles Roleplay server.");
gettime(ghour, gminute, gsecond);
FixHour(ghour);
ghour = shifthour;
if(!realtime)
{
SetWorldTime(wtime);
}
AllowInteriorWeapons(1);
UsePlayerPedAnims(); //Unique walk
DisableInteriorEnterExits();
EnableStuntBonusForAll(0);
ManualVehicleEngineAndLights();
//=====[TIMERS]===========//
SetTimer("ChangeName",1000, true);
hackchecktimer = SetTimer("GlobalHackCheck", 1000, 1);
synctimer = SetTimer("SyncUp", 60000, 1);
unjailtimer = SetTimer("SetPlayerUnjail", 1000, 1);
othtimer = SetTimer("OtherTimer", 1000, 1);
cartimer = SetTimer("CarCheck", 30000, 1);
pickuptimer = SetTimer("CustomPickups", 1000, 1);
spectatetimer = SetTimer("Spectator", 2000, 1);
idletimer = SetTimer("IdleKick", idletime, 1);
productiontimer = SetTimer("Production", 300000, 1); //5 mins (300000)
//accountstimer = SetTimer("SaveAccounts", 900000, 1); //15 mins every account saved
checkgastimer = SetTimer("CheckGas", RunOutTime, 1);
stoppedvehtimer = SetTimer("StoppedVehicle", RunOutTime, 1);
LifeTimer = SetTimer("CheckVida", 1500, 1);
checkcarhealthtimer = SetTimer("CheckCarHealth", 10000, 1);
burgertimer = SetTimer("UpdateBurgerPositions", 1000, 1);
chickentimer = SetTimer("UpdateChickenPositions", 1000, 1);
tracetimer = SetTimer("TraceLastCall", 300000, 1);
return 1;
}
Response
pawn Код:
if (dialogid == Register)
{
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "{00FF00}Role Play ", "{FFFFFF}Please, Register new account", "Register", "exit");//
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Tutorial",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Sex",0);
INI_WriteInt(File,"Age",0);
INI_WriteInt(File,"Facc",0);
INI_WriteInt(File,"Level",1);
INI_WriteInt(File,"Origin",0);
INI_WriteInt(File, "Skin", PlayerInfo[playerid][pChar] = 23);
INI_WriteInt(File,"Leader",0);
INI_WriteInt(File,"rank",0);
INI_WriteInt(File,"TRadio",0);
INI_WriteInt(File,"phone",0);
INI_WriteInt(File,"baned",0);
INI_WriteFloat(File,"Posx",1612.3240);
INI_WriteFloat(File,"Posy",-2330.1670);
INI_WriteFloat(File,"Posz",13.5469);
INI_WriteInt(File,"Premium",0);
INI_WriteInt(File,"Speed",0);
//Y_INI
INI_Close(File);
if (!response) return Kick(playerid);
PlayerLogued[playerid] = 1;
SetSpawnInfo(playerid, 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SetPlayerSkin(playerid, PlayerInfo[playerid][pChar]);
}
if (dialogid == Login)
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pContra])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
SafeGivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
PlayerLogued[playerid] = 1;
SetSpawnInfo(playerid, 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, 25, DIALOG_STYLE_MSGBOX, "{FFFFFF} Role Play {FFFFFF}|", "{FF0000}Incorrect Password!", "ok", "");
}
return 1;
}
}
Re: [Problem]Y_INI save accounts -
nickdodd25 - 20.05.2012
Well here is what i do for my saving accounts, i just made a stock and then call the stock when the player disconnects or on my 10 min auto save timer but i have yet to put this so the when the server restarts, but i assume if you put this under OnGamemodeExit it would save it all
pawn Код:
stock SavePinfo(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
INI_WriteInt(File,"Online",PlayerInfo[playerid][pLoggedIn]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
INI_WriteInt(File,"Bans",PlayerInfo[playerid][pBans]);
INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
INI_WriteInt(File,"VipSkin",PlayerInfo[playerid][pVipSkin]);
INI_WriteInt(File,"MMute",PlayerInfo[playerid][pMMute]);
INI_WriteInt(File,"MStop",PlayerInfo[playerid][pMStop]);
INI_WriteInt(File,"Hours",PlayerInfo[playerid][pHours]);
INI_WriteInt(File,"Mintues",PlayerInfo[playerid][pMinutes]);
INI_WriteInt(File,"Seconds",PlayerInfo[playerid][pSeconds]);
INI_WriteInt(File,"SpeedSet",PlayerInfo[playerid][pSpeedSet]);
INI_Close(File);
}
that is my players saving system and saving players settings. then under ongamemodeexit put this
pawn Код:
public OnGameModeExit()
{
for (new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i))
{
SavePinfo(i);
}
}
//rest of your code
//or
return 1;
}
Just add your saving code to the stock and you can use it anywhere you want the players file to save, if you have a restart command make sure to loop and save like i did in the ongamemodeexit.
Respuesta: [Problem]Y_INI save accounts -
-[R]hysi- - 20.05.2012
Not saved .. I close the console and I open and not saved the data. .No saved . disconnected yes saved why this happens, i restart the server the users suddenly lose their possessions if not disconnected...
Respuesta: [Problem]Y_INI save accounts -
-[R]hysi- - 20.05.2012
sorry wanted to edit the message