Проблема со сменой пароля
#1

Здравствуйте у меня возникла такая проблема при смене пароля.
После смены пароля на папример с 123456 на 5516 пароль меняется на 523456
Сам код смены пароля:
PHP код:
if(dialogid == 7007)//Смена пароля 7007
    
{
        if(
response)
        {
            if(!
strcmp(inputtextPlayerInfo[playerid][pPass], true))
            {
                new 
str[1148];
                
strcat(str"{FF0000}НОВЫЙ {C3C3C3}Введите свой старый пароль от своего аккаунта:\n");
                
strcat(str"{C3C3C3}Проверка на владельца аккаунта.\n");
                
ShowPlayerDialog(playerid47,DIALOG_STYLE_INPUT,"{FFA500}Смена пароля"str"Дальше""Назад");
                return 
true;
            }
            else
            {
                
SendClientMessage(playerid0xFF0000AA"Неверный пароль Тест.");
            }
        }
        else
        {
        
        }
    }
//=============
if(dialogid == 47)
    {
        if(
response)
        {
            new 
string[200];
            new 
sendername[MAX_PLAYER_NAME];
            
GetPlayerName(playerid,sendername,sizeof(sendername));
            
format(string,sizeof(string), "users/%s.ini"sendername);
            new 
File ini_openFile(string);
            
ini_setString(File"Pass"inputtext);
            
ini_closeFile(File);
            
//PlayerInfo[playerid][pPass] = inputtext;
            //PlayerInfo[playerid][pPass] = inputtext/*[playerid]*/;
            
format(stringsizeof(string), "Вы успешно сменили пароль! Ваш новый пароль: {FFFF00}%s"inputtext);
            
SendClientMessage(playerid0x00FF00AAstring);
            
//SavePlayer(playerid);
            
return 1;
        }
    } 
Если добавить ещё и
PHP код:
PlayerInfo[playerid][pPass] = inputtext
То получается такая ошибка
PHP код:
C:\Users\Admin\Desktop\Test\gamemodes\Test.pwn(9628) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Error

Сразу скину паблики OnPlayerLogin, OnPlayerRegister

PHP код:
public OnPlayerRegister(playeridpassword[])// Паблик регистрации
{
    if(
IsPlayerConnected(playerid))
    {
        new 
string[256];// Масив с путём для файла
        
new playername[MAX_PLAYER_NAME];// Масив для получения имени игрока
        
GetPlayerName(playeridplayernamesizeof(playername));// Получаем Имя игрока
        
format(string,sizeof(string), "users/%s.ini"playername);// Добавляем имя игрока, в путь для сохранения
        
new iniFile ini_createFile(string);// Создаём файл с именем игрока в папке players
        
if(iniFile 0)// Если Файла нет
        
{
            
iniFile ini_openFile(string);// Открываем
        
}
        if(
iniFile >= 0)// Если файл есть
        
{
            
strmid(PlayerInfo[playerid][pPass],password,0,strlen(password),255);// Присваиваем масиву pPass, значение password[]
            
ini_setString(iniFile,"Pass",PlayerInfo[playerid][pPass]);// Записываем пароль игрока в файл
            
ini_setInteger(iniFile,"AdminLevel",PlayerInfo[playerid][pAdmin]);
            
ini_setInteger(iniFile,"VipLevel",PlayerInfo[playerid][pVip]);
            
ini_setInteger(iniFile,"Registered",PlayerInfo[playerid][pReg]);
            
ini_setInteger(iniFile,"Int",PlayerInfo[playerid][pInt]);
            
ini_setInteger(iniFile,"Local",PlayerInfo[playerid][pLocal]);
            
ini_setInteger(iniFile,"Muted",PlayerInfo[playerid][pMuted]);
            
ini_setInteger(iniFile,"MuteTime",PlayerInfo[playerid][pMuteTime]);
            
ini_setInteger(iniFile,"TeamClosed",PlayerInfo[playerid][pTeamClosed]);
            
ini_setInteger(iniFile,"TeamTime",PlayerInfo[playerid][pTeamTime]);
            
ini_setInteger(iniFile,"CheatSystem",PlayerInfo[playerid][pCheatSystem]);
            
ini_setInteger(iniFile,"SpawnKill",PlayerInfo[playerid][pSpawnKill]);
            
ini_setInteger(iniFile,"Visits",PlayerInfo[playerid][pVisits]);
            
ini_setInteger(iniFile,"Freeze",PlayerInfo[playerid][pFreeze]);
            
ini_setInteger(iniFile,"Level",PlayerInfo[playerid][pLevel]);
            
ini_setInteger(iniFile,"Deaths",PlayerInfo[playerid][pDeaths]);
            
ini_setInteger(iniFile,"Kills",PlayerInfo[playerid][pKills]);
            
ini_setInteger(iniFile,"Money",PlayerInfo[playerid][pMoney]);
            
ini_setInteger(iniFile,"SkinAdm",PlayerInfo[playerid][pSkinAdm]);
            
ini_setInteger(iniFile,"TextChat",PlayerInfo[playerid][pTextChat]);
            
ini_setInteger(iniFile,"NickColor",PlayerInfo[playerid][pNickColor]);
            
ini_setInteger(iniFile,"Time",PlayerInfo[playerid][pTime]);
            
ini_setInteger(iniFile,"Weather",PlayerInfo[playerid][pWeather]);
            
ini_setInteger(iniFile,"StyleFight",PlayerInfo[playerid][pStyleFight]);
            
ini_setInteger(iniFile,"MenuWeapons",PlayerInfo[playerid][pMenuWeapons]);
            
ini_setInteger(iniFile,"WeaponsAdm",PlayerInfo[playerid][pWeaponsAdm]);
            
ini_setInteger(iniFile,"SmsChat",PlayerInfo[playerid][pSmsChat]);
            
ini_setInteger(iniFile,"SmsOff",PlayerInfo[playerid][pSmsOff]);
            
ini_setInteger(iniFile,"TeamPlayer",PlayerInfo[playerid][pTeamPlayer]);
            
ini_setInteger(iniFile,"FreeMode",PlayerInfo[playerid][pFreeMode]);
            
ini_setInteger(iniFile,"Passive",PlayerInfo[playerid][pPassive]);
            
ini_setInteger(iniFile,"WonDuel",PlayerInfo[playerid][pWonDuel]);
            
ini_setInteger(iniFile,"LostDuel",PlayerInfo[playerid][pLostDuel]);
            
ini_setInteger(iniFile,"CallDuel",PlayerInfo[playerid][pCallDuel]);
            
ini_setInteger(iniFile,"ChitChat",PlayerInfo[playerid][pChitChat]);
            
ini_setInteger(iniFile,"Softonic",PlayerInfo[playerid][pSoftonic]);
            
ini_setInteger(iniFile,"LanguageServer",PlayerInfo[playerid][pLanguageServer]);
            
ini_setInteger(iniFile,"Laser",PlayerInfo[playerid][pLaser]);
            
ini_setInteger(iniFile,"Bandana",PlayerInfo[playerid][pBandana]);
            
ini_setInteger(iniFile,"Parrot",PlayerInfo[playerid][pParrot]);
            
ini_setInteger(iniFile,"Horn",PlayerInfo[playerid][pHorn]);
            
ini_setInteger(iniFile,"BodyWeapons",PlayerInfo[playerid][pBodyWeapons]);
            
ini_setInteger(iniFile,"Pistol",PlayerInfo[playerid][pPistol]);
            
ini_setInteger(iniFile,"Silenced",PlayerInfo[playerid][pSilenced]);
            
ini_setInteger(iniFile,"DesertEagle",PlayerInfo[playerid][pDesertEagle]);
            
ini_setInteger(iniFile,"Shotgun",PlayerInfo[playerid][pShotgun]);
            
ini_setInteger(iniFile,"Bleed",PlayerInfo[playerid][pBleed]);
            
ini_setInteger(iniFile,"CombatShotgun",PlayerInfo[playerid][pCombatShotgun]);
            
ini_setInteger(iniFile,"MicroSMGUz",PlayerInfo[playerid][pMicroSMGUz]);
            
ini_setInteger(iniFile,"MP5",PlayerInfo[playerid][pMP5]);
            
ini_setInteger(iniFile,"AK47",PlayerInfo[playerid][pAK47]);
            
ini_setInteger(iniFile,"M4",PlayerInfo[playerid][pM4]);
            
ini_setInteger(iniFile,"Tec9",PlayerInfo[playerid][pTec9]);
            
ini_setInteger(iniFile,"SniperRifle",PlayerInfo[playerid][pSniperRifle]);
            
ini_closeFile(iniFile);// Закрываем файл
            
PlayerPlaySound(playerid11380.00.00.0);
            
format(string,sizeof(string),"\
              {C3C3C3}Вы успешно зарегистрировали свой аккаунт: {39E33C}%s{C3C3C3}.\n\n\
              {C3C3C3}Теперь ведите свой пароль:\n\
            {C3C3C3}Проверка на владельца аккаунта."
playername);
              
ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD"{FFA500}Вход в Аккаунт",string"Войти""Опции");// Показываем диалог входа в игру.
              
return true;
        }
    }
    return 
1;

PHP код:
public OnPlayerLogin(playeridpassword[])
{
    if(
IsPlayerConnected(playerid))// Проверка на подключение игрока
    
{
        new 
string[400];// Масив с путём для файла
        
new pass[64];// Масив с паролем
          
new playersip[125];
        new 
playername[MAX_PLAYER_NAME];// Масив для получения имени игрока
        
GetPlayerName(playeridplayernamesizeof(playername));// Получаем Имя игрока
        
GetPlayerIp(playeridplayersipsizeof(playersip));
        
format(string,sizeof(string), "users/%s.ini"playername);// Добавляем имя игрока, в путь для загрузки
        
new iniFile ini_openFile(string);// Открываем файл
        
ini_getString(iniFile,"Pass",pass,64);// Загружаем пароль
        
ini_getInteger(iniFile,"AdminLevel",PlayerInfo[playerid][pAdmin]);
        
ini_getInteger(iniFile,"VipLevel",PlayerInfo[playerid][pVip]);
        
ini_getInteger(iniFile,"Registered",PlayerInfo[playerid][pReg]);
        
ini_getInteger(iniFile,"Int",PlayerInfo[playerid][pInt]);
        
ini_getInteger(iniFile,"Local",PlayerInfo[playerid][pLocal]);
        
ini_getInteger(iniFile,"Muted",PlayerInfo[playerid][pMuted]);
        
ini_getInteger(iniFile,"MuteTime",PlayerInfo[playerid][pMuteTime]);
        
ini_getInteger(iniFile,"TeamClosed",PlayerInfo[playerid][pTeamClosed]);
        
ini_getInteger(iniFile,"TeamTime",PlayerInfo[playerid][pTeamTime]);
        
ini_getInteger(iniFile,"CheatSystem",PlayerInfo[playerid][pCheatSystem]);//
        
ini_getInteger(iniFile,"SpawnKill",PlayerInfo[playerid][pSpawnKill]);
        
ini_getInteger(iniFile,"Visits",PlayerInfo[playerid][pVisits]);
        
ini_getInteger(iniFile,"Freeze",PlayerInfo[playerid][pFreeze]);
        
ini_getInteger(iniFile,"Level",PlayerInfo[playerid][pLevel]);
        
ini_getInteger(iniFile,"Deaths",PlayerInfo[playerid][pDeaths]);
        
ini_getInteger(iniFile,"Kills",PlayerInfo[playerid][pKills]);
        
ini_getInteger(iniFile,"Money",PlayerInfo[playerid][pMoney]);
        
ini_getInteger(iniFile,"SkinAdm",PlayerInfo[playerid][pSkinAdm]);
        
ini_getInteger(iniFile,"TextChat",PlayerInfo[playerid][pTextChat]);
        
ini_getInteger(iniFile,"NickColor",PlayerInfo[playerid][pNickColor]);
        
ini_getInteger(iniFile,"Time",PlayerInfo[playerid][pTime]);
        
ini_getInteger(iniFile,"Weather",PlayerInfo[playerid][pWeather]);
        
ini_getInteger(iniFile,"StyleFight",PlayerInfo[playerid][pStyleFight]);
        
ini_getInteger(iniFile,"MenuWeapons",PlayerInfo[playerid][pMenuWeapons]);
        
ini_getInteger(iniFile,"WeaponsAdm",PlayerInfo[playerid][pWeaponsAdm]);
        
ini_getInteger(iniFile,"SmsChat",PlayerInfo[playerid][pSmsChat]);
        
ini_getInteger(iniFile,"SmsOff",PlayerInfo[playerid][pSmsOff]);
        
ini_getInteger(iniFile,"TeamPlayer",PlayerInfo[playerid][pTeamPlayer]);
        
ini_getInteger(iniFile,"FreeMode",PlayerInfo[playerid][pFreeMode]);
        
ini_getInteger(iniFile,"Passive",PlayerInfo[playerid][pPassive]);
        
ini_getInteger(iniFile,"WonDuel",PlayerInfo[playerid][pWonDuel]);
        
ini_getInteger(iniFile,"LostDuel",PlayerInfo[playerid][pLostDuel]);
        
ini_getInteger(iniFile,"CallDuel",PlayerInfo[playerid][pCallDuel]);
        
ini_getInteger(iniFile,"ChitChat",PlayerInfo[playerid][pChitChat]);
        
ini_getInteger(iniFile,"Softonic",PlayerInfo[playerid][pSoftonic]);
        
ini_getInteger(iniFile,"LanguageServer",PlayerInfo[playerid][pLanguageServer]);
        
ini_getInteger(iniFile,"Laser",PlayerInfo[playerid][pLaser]);
        
ini_getInteger(iniFile,"Bandana",PlayerInfo[playerid][pBandana]);
        
ini_getInteger(iniFile,"Parrot",PlayerInfo[playerid][pParrot]);
        
ini_getInteger(iniFile,"Horn",PlayerInfo[playerid][pHorn]);
        
ini_getInteger(iniFile,"BodyWeapons",PlayerInfo[playerid][pBodyWeapons]);
        
ini_getInteger(iniFile,"Pistol",PlayerInfo[playerid][pPistol]);
        
ini_getInteger(iniFile,"Silenced",PlayerInfo[playerid][pSilenced]);
        
ini_getInteger(iniFile,"DesertEagle",PlayerInfo[playerid][pDesertEagle]);
        
ini_getInteger(iniFile,"Shotgun",PlayerInfo[playerid][pShotgun]);
        
ini_getInteger(iniFile,"Bleed",PlayerInfo[playerid][pBleed]);
        
ini_getInteger(iniFile,"CombatShotgun",PlayerInfo[playerid][pCombatShotgun]);
        
ini_getInteger(iniFile,"MicroSMGUz",PlayerInfo[playerid][pMicroSMGUz]);
        
ini_getInteger(iniFile,"MP5",PlayerInfo[playerid][pMP5]);
        
ini_getInteger(iniFile,"AK47",PlayerInfo[playerid][pAK47]);
        
ini_getInteger(iniFile,"M4",PlayerInfo[playerid][pM4]);
        
ini_getInteger(iniFile,"Tec9",PlayerInfo[playerid][pTec9]);
        
ini_getInteger(iniFile,"SniperRifle",PlayerInfo[playerid][pSniperRifle]);
        if(
strcmp(pass,password,true) == 0)// Если введёный пароль, соответсвует паролю при регистрации, то загружаем акк
        
{
            
ini_getString(iniFile,"Pass",PlayerInfo[playerid][pPass],64);// Загружаем пароль
            
ini_closeFile(iniFile);// Закрываем файл
        
}
        else
// Если пароль не верен..
        
{
            
ini_closeFile(iniFile);// Закрываем файл
               
if(WrPass[playerid] == MAX_WRPASSES)
             {
                 
format(stringsizeof(string), "[A]: >> Игрок %s [ID: %d] ввел 3 раза неверный пароль и был отсоединен от игрового сервера [IP: %s] [Ping: %d]"playernameplayeridplayersipGetPlayerPing(playerid));
                
ABroadCast(0xC3C3C3AA,string,4);
                
Kick(playerid);
            }
            else
            {
                
ShowPlayerDialog(playerid,12,DIALOG_STYLE_LIST,"{FFA500}Опции","{C3C3C3}Отправить новый пароль на прикрепленный {10F441}Email\n{C3C3C3}Покинуть сервер с Авто выходом","Выбрать","Назад");
            }
            
format(string,sizeof(string),"\
            {C3C3C3}Вы ввели неправильный пароль!\n\
            {C3C3C3}У вас осталось {FF0000}%d {C3C3C3}из {FF0000}%d {C3C3C3}попыток!\n\n\
            {C3C3C3}После {FF0000}3 {C3C3C3}из {FF0000}3 {C3C3C3}неверных попыток.\n\
            {C3C3C3}Вы будите отсоединены от игрового сервера."
WrPass[playerid], MAX_WRPASSES);
            
ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD"{FF0000}Вход в Аккаунт",string"Войти""Опции");
            
WrPass[playerid]++;//прибавляем к переменной единицу
            
PlayerPlaySound(playerid10850.00.00.0);
            return 
1;
        } 
Reply
#2

проблема в том что в файле строка не затирается, а пишется поверх. Вот поэтому я не использую всякие файлочиталки, и работаю со встренными функциями.
А по поводу копирования строки в строку strmid тебе в помощь.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)