Big loading data problem -
admantis - 17.04.2012
Hello, I'm running a new server, and I experienced a problem where players can load other players stats, randomly.
This is my code loading the stats
pawn Код:
stock LoadUserData( playerid )
{
new File[ 64 ];
ResetServerMoney( playerid );
format( File, 64, "Accounts/%s.ini", GetName( playerid ) );
if( LoadedData[playerid] == 1 ) return 1;
if ( fexist ( File ) && LoadedData[playerid] != 1 )
{
INI_Open( File );
// bunch of loading
// another bunch of loading
INI_Save( );
INI_Close( );
}
return 1;
}
And for saving;
pawn Код:
stock SaveUserData( playerid, password[] = "null" )
{
if( IsPlayerConnected( playerid ) )
{
if( ( PlayerInfo[playerid][LoggedIn] == 1 && GotLogged[playerid] == 1 ) || PlayerInfo[playerid][Tutorial] == 1 )
{
if ( PlayerInfo[playerid][InHospital] == 0 )
{
new File[ 128 ];
format( File, 128, "Accounts/%s.ini", GetName( playerid ) );
if ( !fexist( File ) ) INI_Create( File );
INI_Open( File );
// more and more saving
// seriously, alot of saving
INI_Save( );
INI_Close( );
}
}
}
return 1;
}
What are the possible causes? Help me as I am very worried for the safety of my server, thanks beforehand.
Re: Big loading data problem -
ViniBorn - 17.04.2012
So, if I log in as "ViniBorn," I can load data from "admantis"?
Respuesta: Big loading data problem -
admantis - 17.04.2012
Yes, if ViniBorn logged in with the same ID that admantis had.
Re: Big loading data problem -
MP2 - 17.04.2012
Post your GetName() function, and put a print() to see what the filename gets formatted as.
Re: Big loading data problem -
PrawkC - 17.04.2012
You probably arent reseting the array, show your OnPlayerDisconnect
Respuesta: Big loading data problem -
admantis - 17.04.2012
pawn Код:
public OnPlayerDisconnect( playerid, reason )
{
if ( IsPlayerNPC( playerid ) )
return 1;
GotLogged[playerid]=0;
PlayerInfo2[playerid][Helmet]=0;
PlayerInfo2[playerid][Seatbelt]=0;
LoadedData[playerid]=0;
KillTimer( LoadingTimer[playerid] );
new veh = GetPlayerVehicleID( playerid );
if( IsABusVehicle( veh ) && BusCP[playerid] != 0 )
SetVehicleToRespawn( veh );
if ( IsAQuarryVehicle( veh ) && ( QuarryCP[playerid] == 3 || QuarryCP[playerid] == 1 ) )
{
SetVehicleToRespawn( veh );
if( IsValidObject( VehicleObject[veh] ) ) { DestroyObject( VehicleObject[veh] ); VehicleObject[veh]=0; }
}
DestroyPlayerObject( playerid, FirstViewObject[playerid] );
StopAudioStreamForPlayer( playerid );
InCall[playerid] = 0;
Calling[playerid] = -1;
FlashLight[playerid] = 0;
RiotShield[playerid] = 0;
new qStr[92];
switch( reason )
{
case 0: format( qStr, 92, "* %s has disconnected from the server. (Timed out)", GetPName( playerid ) );
case 1: format( qStr, 92, "* %s has disconnected from the server. (Leaving)", GetPName( playerid ) );
case 2: format( qStr, 92, "* %s has disconnected from the server. (Kicked/Banned)", GetPName( playerid ) );
}
if( !isnull( qStr ) ) ProxDetector( 30.0, playerid, qStr, -1, -1, -1, -1, -1 );
if( Roped[playerid] == 1 )
{
for(new d = 0; d <= ROPE_LENGHT; d++ )
{
DestroyDynamicObject(Ropes[playerid][d]);
}
}
for( new k = 0; k < 10; k++ )
RemovePlayerAttachedObject( playerid, k );
if ( PlayerInfo[playerid][LoggedIn] == 1 )
{
GetPlayerPos( playerid, PlayerInfo[playerid][LastX], PlayerInfo[playerid][LastY], PlayerInfo[playerid][LastZ] );
GetPlayerFacingAngle( playerid, PlayerInfo[playerid][LastA] );
InCall[playerid] = 0;
Calling[playerid] = -1;
if ( PlayerInfo[playerid][LoggedIn] == 1 )
{
if ( InHouse[playerid] != 0 )
{
PlayerInfo[playerid][LastX] = HouseInfo[InHouse[playerid]][hx];
PlayerInfo[playerid][LastY] = HouseInfo[InHouse[playerid]][hy];
PlayerInfo[playerid][LastZ] = HouseInfo[InHouse[playerid]][hz];
PlayerInfo[playerid][VirtualWorld] = 0;
PlayerInfo[playerid][Interior] = 0;
SetPlayerInterior( playerid, 0 );
SetPlayerVirtualWorld( playerid, 0 );
}
if ( InBusiness[playerid] != 0 )
{
PlayerInfo[playerid][LastX] = BusinessInfo[InBusiness[playerid]][bx];
PlayerInfo[playerid][LastY] = BusinessInfo[InBusiness[playerid]][by];
PlayerInfo[playerid][LastZ] = BusinessInfo[InBusiness[playerid]][bz];
PlayerInfo[playerid][VirtualWorld] = 0;
PlayerInfo[playerid][Interior] = 0;
SetPlayerInterior( playerid, 0 );
SetPlayerVirtualWorld( playerid, 0 );
}
if ( InBuilding[playerid] != 0 )
{
PlayerInfo[playerid][LastX] = PublicBuildings[InBuilding[playerid]][enterx];
PlayerInfo[playerid][LastY] = PublicBuildings[InBuilding[playerid]][entery];
PlayerInfo[playerid][LastZ] = PublicBuildings[InBuilding[playerid]][enterz];
PlayerInfo[playerid][VirtualWorld] = 0;
PlayerInfo[playerid][Interior] = 0;
SetPlayerInterior( playerid, 0 );
SetPlayerVirtualWorld( playerid, 0 );
}
if ( InHq[playerid] != 0 )
{
PlayerInfo[playerid][LastX] = FactionInfo[InHq[playerid]][EntranceX];
PlayerInfo[playerid][LastY] = FactionInfo[InHq[playerid]][EntranceY];
PlayerInfo[playerid][LastZ] = FactionInfo[InHq[playerid]][EntranceZ];
PlayerInfo[playerid][VirtualWorld] = 0;
PlayerInfo[playerid][Interior] = 0;
SetPlayerInterior( playerid, 0 );
SetPlayerVirtualWorld( playerid, 0 );
}
SetPlayerInterior( playerid, 0 );
SetPlayerVirtualWorld( playerid, 0 );
SaveUserData( playerid );
PlayerInfo[playerid][LoggedIn] = 0;
}
}
if ( PlayerInfo2[playerid][RentCarKey] != -255 )
{
new car = PlayerInfo2[playerid][RentCarKey];
RentalInfo[car][RentedBy] = -255;
PlayerInfo2[playerid][RentCarKey] = -255;
SetVehicleToRespawn( car );
}
if ( PlayerInfo[playerid][LoggedIn] == 1 )
KillTimer( MinutePayTimer[playerid] );
PlayerTextDrawDestroy( playerid, ErrorMessage[playerid] );
PlayerTextDrawDestroy( playerid, Pay1[playerid] );
PlayerTextDrawDestroy( playerid, Pay2[playerid] );
PlayerTextDrawDestroy( playerid, Watch1[playerid] );
PlayerTextDrawDestroy( playerid, Watch2[playerid] );
PlayerTextDrawDestroy( playerid, BloodMeter[playerid] );
PlayerTextDrawDestroy( playerid, FillTextdraw0[playerid] );
PlayerTextDrawDestroy( playerid, FillTextdraw1[playerid] );
PlayerTextDrawDestroy( playerid, FillTextdraw2[playerid] );
PlayerTextDrawDestroy( playerid, FillTextdraw3[playerid] );
PlayerTextDrawDestroy( playerid, HorseBetting[playerid] );
PlayerTextDrawDestroy( playerid, HorseInfo[playerid] );
PlayerTextDrawDestroy( playerid, FishingText[playerid] );
PlayerTextDrawDestroy( playerid, WireText[playerid] );
PlayerTextDrawDestroy( playerid, CarInfo[playerid] );
PlayerTextDrawDestroy( playerid, Ammu2[playerid] );
PlayerTextDrawDestroy( playerid, CopRadar[playerid] );
PlayerTextDrawDestroy( playerid, Speedo1[playerid] );
PlayerTextDrawDestroy( playerid, Speedo2[playerid] );
PlayerTextDrawDestroy( playerid, Speedo3[playerid] );
PlayerTextDrawDestroy( playerid, SpectateDraw[playerid] );
TextDrawHideForPlayer( playerid, IntroGraphic0 );
TextDrawHideForPlayer( playerid, IntroGraphic1 );
TextDrawHideForPlayer( playerid, IntroGraphic2 );
TextDrawHideForPlayer( playerid, IntroGraphic3 );
TextDrawHideForPlayer( playerid, IntroGraphic4 );
TextDrawHideForPlayer( playerid, IntroGraphic5 );
TextDrawHideForPlayer( playerid, IntroGraphic6 );
TextDrawHideForPlayer( playerid, Text:TestTextdraw3 );
TextDrawHideForPlayer( playerid, Text:TestTextdraw4 );
TextDrawHideForPlayer( playerid, Text:TestTextdraw5 );
PlayerInfo[playerid][LoggedIn]=0;
memset( PlayerInfo[playerid], 0 );
return 1;
}
GetName:
pawn Код:
stock GetName( playerid )
{
new szName[ 24 ];
GetPlayerName( playerid, szName, 24 );
return szName;
}
print Results:
BTW I'm certain this problem is regarding loading because when someone disconnects their user file is correct but when they login they can adquire other stats.
Re: Big loading data problem -
ViniBorn - 17.04.2012
Where you use ' LoadUserData ' ?
You can show?
Respuesta: Big loading data problem -
admantis - 17.04.2012
There's a login dialog when you connect, which response is more or less this:
pawn Код:
if( response && DIALOG_REGISTER == dialogid )
{
if ( !strlen( inputtext ) )
return ShowPlayerDialog( playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{66ccff} Log in your account", "{FFFFFF}Welcome!\nWrong Password!\nIntroduce your password below to log in your account and start playing.", "Log In", "Quit");
new szPass[129];
new sz_inputHash[129];
new sz_buf[128];
INI_Open( UserPath ( playerid ) );
szPass = INI_ReadString( "Password");
INI_Close( );
// Since we can't save strings longer than 129 on bIni we create a 128 char string.
// In that string, we put the hash, but since the last value can't fit, it will be cut.
WP_Hash( sz_inputHash, sizeof sz_inputHash, inputtext );
format( sz_buf, 128, "%s", sz_inputHash );
if( strcmp ( sz_buf, szPass, false ) == 0 )
{
GotLogged[playerid]=1;
TextDrawHideForPlayer( playerid, IntroGraphic0 );
TextDrawHideForPlayer( playerid, IntroGraphic1 );
TextDrawHideForPlayer( playerid, IntroGraphic2 );
TextDrawHideForPlayer( playerid, IntroGraphic3 );
TextDrawHideForPlayer( playerid, IntroGraphic4 );
TextDrawHideForPlayer( playerid, IntroGraphic5 );
TextDrawHideForPlayer( playerid, IntroGraphic6 );
GameTextForPlayer( playerid, "~w~loading account...~n~~b~~h~~h~~h~please wait...", 2500, 3 );
LoadUserData( playerid );
if( PlayerInfo[playerid][Banned] == 1 )
{
SendClientMessage( playerid, COLOR_GRAY, "This account is locked." );
Kick( playerid );
}
The rest is irrevelant and I'd prefer to not post it.