15.03.2012, 05:50
Alright so I register an account and go to lets say the cords 42,21,12 then relog, when I log back in I am at the place I logged out but If I run down the street then log out when I log back in I am back where I was when I logged out the very first time I logged out, I have no idea what is causing the issue so I am going to post my whole saving system here. To sum it up your position is only saved on your first visit to the server.
pawn Код:
//Player info enum
enum pInfo
{
pPass,
pCash,
pAdmin,
pSex,
pAge,
Float:pPos_x,
Float:pPos_y,
Float:pPos_z,
pSkin,
pTeam,
pAccent,
pTutorial,
pJob,
pDlvpkg,
pKills,
pDeaths,
pDead,
pCop,
pLeader,
pPolitician,
pGunPermit,
pBank,
pBanned,
pLevel,
pHours,
pScrapMetal,
pWtest,
pDtest,
pCar,
Float:pCarPos_x,
Float:pCarPos_y,
Float:pCarPos_z,
Float:pCarPos_a,
pCarID,
pRadioFreq,
pRadio,
pJailtime,
pJailed,
pLawLicense,
pAseCertified
}
function SaveAccountStats(playerid)
{
if(Logged[playerid] == 1)
{
new
INI:File = INI_Open(UserPath(playerid))
;
INI_SetTag(File,"data");
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
PlayerInfo[playerid][pCash] = GetPlayerCash(playerid);
PlayerInfo[playerid][pLevel] = GetPlayerScore(playerid);
new
Float:x,
Float:y,
Float:z
;
GetPlayerPos(playerid,x,y,z);
PlayerInfo[playerid][pPos_x] = x;
PlayerInfo[playerid][pPos_y] = y;
PlayerInfo[playerid][pPos_z] = z;
INI_WriteInt(File,"Cash",PlayerInfo[playerid][pCash]);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
INI_WriteFloat(File,"Pos_x",PlayerInfo[playerid][pPos_x]);
INI_WriteFloat(File,"Pos_y",PlayerInfo[playerid][pPos_y]);
INI_WriteFloat(File,"Pos_z",PlayerInfo[playerid][pPos_z]);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
INI_WriteInt(File,"Accent",PlayerInfo[playerid][pAccent]);
INI_WriteInt(File,"Tutorial",PlayerInfo[playerid][pTutorial]);
INI_WriteInt(File, "Job",PlayerInfo[playerid][pJob]);
INI_WriteInt(File, "Dlvpkg",PlayerInfo[playerid][pDlvpkg]);
INI_WriteInt(File, "Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File, "Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File, "Dead",PlayerInfo[playerid][pDead]);
INI_WriteInt(File, "Cop",PlayerInfo[playerid][pCop]);
INI_WriteInt(File, "Leader",PlayerInfo[playerid][pLeader]);
INI_WriteInt(File,"Politician",PlayerInfo[playerid][pPolitician]);
INI_WriteInt(File,"GunPermit",PlayerInfo[playerid][pGunPermit]);
INI_WriteInt(File,"Bank",PlayerInfo[playerid][pBank]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Hours",PlayerInfo[playerid][pHours]);
INI_WriteInt(File,"ScrapMetal", PlayerInfo[playerid][pScrapMetal]);
INI_WriteInt(File,"Wtest", PlayerInfo[playerid][pWtest]);
INI_WriteInt(File,"Dtest",PlayerInfo[playerid][pDtest]);
INI_WriteInt(File,"Car", PlayerInfo[playerid][pCar]);
INI_WriteFloat(File,"CarPos_x", PlayerInfo[playerid][pCarPos_x]);
INI_WriteFloat(File,"CarPos_y", PlayerInfo[playerid][pCarPos_y]);
INI_WriteFloat(File,"CarPos_z", PlayerInfo[playerid][pCarPos_z]);
INI_WriteFloat(File,"CarPos_a", PlayerInfo[playerid][pCarPos_a]);
INI_WriteInt(File,"CarID", PlayerInfo[playerid][pCarID]);
INI_WriteInt(File,"RadioFreq", PlayerInfo[playerid][pRadioFreq]);
INI_WriteInt(File,"Radio",PlayerInfo[playerid][pRadio]);
INI_WriteInt(File,"Jailtime",PlayerInfo[playerid][pJailtime]);
INI_WriteInt(File,"Jailed",PlayerInfo[playerid][pJailed]);
INI_WriteInt(File,"LawLicense",PlayerInfo[playerid][pLawLicense]);
INI_WriteInt(File,"AseCertified",PlayerInfo[playerid][pAseCertified]);
INI_Close(File);
}
return 1;
}
// next is my login code
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
new
tmp2[ 256 ],
playername2[ MAX_PLAYER_NAME ]
;
GetPlayerName(playerid, playername2, sizeof(playername2));
format(tmp2, sizeof(tmp2), "~w~Welcome ~n~~g~%s", playername2);
GameTextForPlayer(playerid, tmp2, 5000, 1);
GivePlayerCash(playerid, PlayerInfo[playerid][pCash]);
SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
Logged[playerid] ++;
new
Float: X,
Float: Y,
Float: Z
;
X = PlayerInfo[playerid][pPos_x];
Y = PlayerInfo[playerid][pPos_y];
Z = PlayerInfo[playerid][pPos_z];
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], X, Y, Z, 120, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
PlayerInfo[playerid][pCarID] = CreateVehicle(PlayerInfo[playerid][pCar], PlayerInfo[playerid][pCarPos_x], PlayerInfo[playerid][pCarPos_y], PlayerInfo[playerid][pCarPos_z], PlayerInfo[playerid][pCarPos_a], 0, 0, 9999);
SetTimerEx("message", 20000, true, "d" , playerid );
if(PlayerInfo[playerid][pJailtime] >= 2)
{
SetPlayerPos(playerid, 223.4806, 110.8119, 999.0156);
SetPlayerInterior(playerid, 10);
SetTimer("JailTime", 60000, true);
}
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
}
return 1;
}
}
// load user data
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Sex",PlayerInfo[playerid][pSex]);
INI_Int("Age",PlayerInfo[playerid][pAge]);
INI_Float("Pos_x",PlayerInfo[playerid][pPos_x]);
INI_Float("Pos_y",PlayerInfo[playerid][pPos_y]);
INI_Float("Pos_z",PlayerInfo[playerid][pPos_z]);
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
INI_Int("Team",PlayerInfo[playerid][pTeam]);
INI_Int("Accent",PlayerInfo[playerid][pAccent]);
INI_Int("Tutorial",PlayerInfo[playerid][pTutorial]);
INI_Int("Job", PlayerInfo[playerid][pJob]);
INI_Int("Dlvpkg", PlayerInfo[playerid][pDlvpkg]);
INI_Int("Kills", PlayerInfo[playerid][pKills]);
INI_Int("Deaths", PlayerInfo[playerid][pDeaths]);
INI_Int("Dead",PlayerInfo[playerid][pDead]);
INI_Int("Cop",PlayerInfo[playerid][pCop]);
INI_Int("Leader",PlayerInfo[playerid][pLeader]);
INI_Int("Politician",PlayerInfo[playerid][pPolitician]);
INI_Int("GunPermit", PlayerInfo[playerid][pGunPermit]);
INI_Int("Bank", PlayerInfo[playerid][pBank]);
INI_Int("Banned", PlayerInfo[playerid][pBanned]);
INI_Int("Level",PlayerInfo[playerid][pLevel]);
INI_Int("Hours",PlayerInfo[playerid][pHours]);
INI_Int("ScrapMetal",PlayerInfo[playerid][pScrapMetal]);
INI_Int("Wtest", PlayerInfo[playerid][pWtest]);
INI_Int("Dtest", PlayerInfo[playerid][pDtest]);
INI_Int("Car", PlayerInfo[playerid][pCar]);
INI_Float("CarPos_x", PlayerInfo[playerid][pCarPos_x]);
INI_Float("CarPos_y", PlayerInfo[playerid][pCarPos_y]);
INI_Float("CarPos_z", PlayerInfo[playerid][pCarPos_z]);
INI_Float("CarPos_a", PlayerInfo[playerid][pCarPos_a]);
INI_Int("CarID", PlayerInfo[playerid][pCarID]);
INI_Int("RadioFreq",PlayerInfo[playerid][pRadioFreq]);
INI_Int("Radio",PlayerInfo[playerid][pRadio]);
INI_Int("Jailtime",PlayerInfo[playerid][pJailtime]);
INI_Int("Jailed",PlayerInfo[playerid][pJailed]);
INI_Int("LawLicense",PlayerInfo[playerid][pLawLicense]);
INI_Int("AseCertified",PlayerInfo[playerid][pAseCertified]);
return 1;
}
// my register code
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
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,"Admin",0);
INI_WriteInt(File,"Sex",0);
INI_WriteInt(File,"Age",0);
INI_WriteFloat(File,"Pos_x",0);
INI_WriteFloat(File,"Pos_y",0);
INI_WriteFloat(File,"Pos_z",0);
INI_WriteInt(File,"Skin",0);
INI_WriteInt(File,"Team",0);
INI_WriteInt(File,"Accent",0);
INI_WriteInt(File,"Tutorial",0);
INI_WriteInt(File, "Job", 0);
INI_WriteInt(File, "Dlvpkg", 0);
INI_WriteInt(File, "Kills", 0);
INI_WriteInt(File, "Deaths", 0);
INI_WriteInt(File, "Dead", 0);
INI_WriteInt(File, "Cop", 0);
INI_WriteInt(File, "Leader", 0);
INI_WriteInt(File, "Politician",0);
INI_WriteInt(File, "GunPermit",0);
INI_WriteInt(File, "Bank",2500);
INI_WriteInt(File, "Banned",0);
INI_WriteInt(File, "Level",1);
INI_WriteInt(File, "Hours",0);
INI_WriteInt(File, "ScrapMetal",0);
INI_WriteInt(File, "Wtest",0);
INI_WriteInt(File, "Dtest", 0);
INI_WriteInt(File, "Car", 0);
INI_WriteFloat(File, "CarPos_x", 0);
INI_WriteFloat(File, "CarPos_y", 0);
INI_WriteFloat(File, "CarPos_z", 0);
INI_WriteFloat(File, "CarPos_a", 0);
INI_WriteInt(File, "CarID", 0);
INI_WriteInt(File, "RadioFreq", 0);
INI_WriteInt(File, "Radio", 0);
INI_WriteInt(File, "Jailtime", 0);
INI_WriteInt(File, "Jailed", 0);
INI_WriteInt(File, "LawLicense", 0);
INI_WriteInt(File, "AseCertified", 0);
INI_Close(File);
SetPlayerScore(playerid, 1);
SetPlayerColor(playerid, 0xFFFFFFFF);
ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_MSGBOX, "- Sex -","What gender are you?","Male","Female");
}
}