Szerző Téma: Fegyverek mentése a játékos mappájába!  (Megtekintve 376 alkalommal)

Fegyverek mentése a játékos mappájába!
« Dátum: 2014. Június 16. - 09:12:23 »
0 Show voters
Sziasztok!
Eddig hála nektek sikerült a fegyvermentést megoldani külön külön mindenkinek egy .ini fájlba, de most azzal próbálkoztam hogyan is lehetne elmenteni mindenkinek a saját .ini fájláb ahol a többi cucca is elvan tárolva.
Mivel a módba így történik a tárolás én is így próbálkoztam vele. Létre is kozza a dolgokat a .ini mappába de sajnos nem menti le bele a dolgokat.
Így hozza létre a mappába:
 
Level=1Weapon1Ammo1Weapon2Ammo2Weapon3Ammo3Weapon4Ammo4Weapon5Ammo5Weapon6Ammo6Weapon7Ammo7Weapon8Ammo8Weapon9Ammo9Weapon10Ammo10Weapon11Ammo11Weapon12Ammo12

 
Kicsit zavarossan :D
És így mentem le a dolgokat:
 
public OnPlayerRegister(playerid, password[])
{
if(IsPlayerConnected(playerid))
{
            new weapons[13][2];
            for (new i = 0; i < 13; i++)
            {
                GetPlayerWeaponData(playerid, i, weapons[0], weapons[1]);
            }
   new string3[32];
   new PlayerName3[MAX_PLAYER_NAME];
   GetPlayerName(playerid, PlayerName3, sizeof(PlayerName3));
   format(string3, sizeof(string3), \"%s.ini\", PlayerName3);
   new File: hFile = fopen(string3, io_write);
   if(hFile)
   {
       new var[32];
       strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
      format(var, 32, \"Key=%s\\n\", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
      format(var, 32, \"Level=%d\\n\",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
      format(var, 32, \"Terkep=%d\\n\",PlayerInfo[playerid][pMap]);fwrite(hFile, var);
      format(var, 32, \"Weapon1\", weapons[0][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo1\", weapons[0][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon2\", weapons[1][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo2\", weapons[1][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon3\", weapons[2][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo3\", weapons[2][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon4\", weapons[3][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo4\", weapons[3][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon5\", weapons[4][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo5\", weapons[4][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon6\", weapons[5][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo6\", weapons[5][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon7\", weapons[6][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo7\", weapons[6][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon8\", weapons[7][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo8\", weapons[7][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon9\", weapons[8][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo9\", weapons[8][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon10\", weapons[9][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo10\", weapons[9][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon11\", weapons[10][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo11\", weapons[10][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon12\", weapons[11][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo12\", weapons[11][1]);fwrite(hFile, var);
   }
}
return 1;
}

 

public OnPlayerSave(playerid)
{
if(IsPlayerConnected(playerid))
{
    if(IsPlayerNPC(playerid)) return 1;
if(gPlayerLogged[playerid] != 0 && gPlayerSpawned[playerid] == 1)
{
            new weapons[13][2];
            for (new i = 0; i < 13; i++)
            {
                GetPlayerWeaponData(playerid, i, weapons[0], weapons[1]);
            }
   new string3[32];
   new PlayerName3[MAX_PLAYER_NAME];
   GetPlayerName(playerid, PlayerName3, sizeof(PlayerName3));
   format(string3, sizeof(string3), \"%s.ini\", PlayerName3);
   new File: hFile = fopen(string3, io_write);
   if(hFile)
   {
      new var[64];
      if(gmx == 0)
      {
          GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
          GetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
      }
      PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
          PlayerInfo[playerid][pVirtualWorld] = GetPlayerVirtualWorld(playerid);
          GetPlayerPos(playerid, PlayerInfo[playerid][pSPos_x], PlayerInfo[playerid][pSPos_y], PlayerInfo[playerid][pSPos_z]);
      GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
      format(var, 32, \"Key=%s\\n\", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
      format(var, 32, \"Level=%d\\n\",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
      format(var, 32, \"Terkep=%s\\n\", PlayerInfo[playerid][pMap]);fwrite(hFile, var);
      format(var, 32, \"Weapon1\", weapons[0][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo1\", weapons[0][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon2\", weapons[1][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo2\", weapons[1][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon3\", weapons[2][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo3\", weapons[2][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon4\", weapons[3][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo4\", weapons[3][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon5\", weapons[4][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo5\", weapons[4][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon6\", weapons[5][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo6\", weapons[5][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon7\", weapons[6][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo7\", weapons[6][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon8\", weapons[7][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo8\", weapons[7][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon9\", weapons[8][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo9\", weapons[8][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon10\", weapons[9][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo10\", weapons[9][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon11\", weapons[10][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo11\", weapons[10][1]);fwrite(hFile, var);
      format(var, 32, \"Weapon12\", weapons[11][0]);fwrite(hFile, var);
      format(var, 32, \"Ammo12\", weapons[11][1]);fwrite(hFile, var);
   }
}
}
return 1;
}

 

public OnPlayerLogin(playerid,password[])
{
new weapons[13][2];
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[0], weapons[1]);
}
new tmp2[256];
    new string2[128];
format(string2, sizeof(string2), \"%s.ini\", PlayerName(playerid));
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
    {
        new PassData[128];
    new keytmp[256], valtmp[256];
    fread( UserFile , PassData , sizeof( PassData ) );
    keytmp = ini_GetKey( PassData );
    if( strcmp( keytmp , \"Key\" , true ) == 0 )
{
   valtmp = ini_GetValue( PassData );
   strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
}
if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
        {
       new key[ 256 ] , val[ 256 ];
   new Data[ 256 ];
   while ( fread( UserFile , Data , sizeof( Data ) ) )
   {
       key = ini_GetKey( Data );
       if( strcmp( key , \"Level\" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strvalEx( val ); }
                if( strcmp( key , \"Terkep\" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMap] = strvalEx( val ); }
       if( strcmp( key , \"Weapon1\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[0][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo1\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[0][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon2\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[1][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo2\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[1][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon3\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[2][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo3\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[2][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon4\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[3][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo4\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[3][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon5\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[4][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo5\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[4][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon6\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[5][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo6\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[5][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon7\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[6][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo7\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[6][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon8\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[7][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo8\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[7][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon9\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[8][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo9\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[8][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon10\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[9][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo10\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[9][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon11\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[10][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo11\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[10][1] = strvalEx( val ); }
       if( strcmp( key , \"Weapon12\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[11][0] = strvalEx( val ); }
       if( strcmp( key , \"Ammo12\" , true ) == 0 ) { val = ini_GetValue( Data ); weapons[11][1] = strvalEx( val ); }

 
Lehet csak én nem látom a hibát vagy nem tom :D
Mer a mód is lefut gond nélkül.
A segítséget elõre is köszönöm! :)

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal