12.02.2012, 17:17
Why does this code write my file like so?
As you can see, it writes the position values twice. The second value updates, the first doesn't.
Registering..
Writing on disconnect..
Quote:
[data] Passcode = 20644050 RegisteredIP = 127.0.0.1 Funds = 0 BankFunds = 0 SkinModel = 0 Kills = 0 Deaths = 0 EventsWon = 0 X Pos = 0.000000 Y Pos = 0.000000 Z Pos = 10.000000 Ang Pos = 0.000000 X Pos = 13.693827 Y Pos = -10.758239 Z Pos = 3.117187 Ang Pos = 186.591140 |
Registering..
pawn Код:
case DIALOG_CONNECT_REGISTER:
{
if( !strlen(inputtext) )
return ShowPlayerDialog(playerid, DIALOG_CONNECT_REGISTER, DIALOG_STYLE_PASSWORD, ""#WHITE"Welcome to "#LIME"RP Mod "#WHITE": "#LIME"Version 1.0", "\n\t"#LIME"RP Mod "#WHITE"was started on "#CYAN"February 10th, 2012 "#WHITE"by "#CYAN"2KY.\n\n"#WHITE"You need to "#LIME"register "#WHITE"an account on our server in order to play!", "Register", "");
/*
Creating their account
*/
new
INI:accFile = INI_Open(find_accPath(playerid) ),
accIP[16];
GetPlayerIp(playerid, accIP, sizeof(accIP));
INI_SetTag(accFile, "data");
INI_WriteInt(accFile, "Passcode", udb_hash(inputtext) );
INI_WriteString(accFile, "RegisteredIP", accIP);
INI_WriteInt(accFile, "Funds", 100);
INI_WriteInt(accFile, "BankFunds", 200);
INI_WriteInt(accFile, "SkinModel", random(299) );
INI_WriteInt(accFile, "Kills", 0);
INI_WriteInt(accFile, "Deaths", 0);
INI_WriteInt(accFile, "EventsWon", 0);
INI_WriteFloat(accFile, "X Pos", SPAWN_X);
INI_WriteFloat(accFile, "Y Pos", SPAWN_Y);
INI_WriteFloat(accFile, "Z Pos", SPAWN_Z);
INI_WriteFloat(accFile, "Ang Pos", SPAWN_ANG);
INI_Close(accFile);
/*
Now that they're logged in..
*/
accLogged[playerid] = true;
SetSpawnInfo(playerid, 0, accInfo[playerid][SkinModel], SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_ANG, 0,0, 0,0, 0,0);
SpawnPlayer(playerid);
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
if(accLogged[playerid] == true)
{
new
INI:accFile = INI_Open(find_accPath(playerid));
GetPlayerPos(playerid, accInfo[playerid][PosX], accInfo[playerid][PosY], accInfo[playerid][PosZ]);
GetPlayerFacingAngle(playerid, accInfo[playerid][PosAng]);
INI_SetTag(accFile, "data");
INI_WriteInt(accFile, "Funds", accInfo[playerid][Funds]);
INI_WriteInt(accFile, "BankFunds", accInfo[playerid][BankFunds]);
INI_WriteInt(accFile, "Kills", accInfo[playerid][Kills]);
INI_WriteInt(accFile, "Deaths", accInfo[playerid][Deaths]);
INI_WriteFloat(accFile, "X Pos", accInfo[playerid][PosX]);
INI_WriteFloat(accFile, "Y Pos", accInfo[playerid][PosY]);
INI_WriteFloat(accFile, "Z Pos", accInfo[playerid][PosZ]);
INI_WriteFloat(accFile, "Ang Pos", accInfo[playerid][PosAng]);
INI_WriteInt(accFile, "SkinModel", accInfo[playerid][SkinModel]);
INI_WriteInt(accFile, "EventsWon", accInfo[playerid][EventsWon]);
INI_Close(accFile);
}
accLogged[playerid] = false;
return true;
}