SA-MP Forums Archive
mxINI - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Русский/Russian (https://sampforum.blast.hk/forumdisplay.php?fid=32)
+---- Thread: mxINI (/showthread.php?tid=474755)



mxINI - pozitiv4eg - 09.11.2013

Уже наверное год не работал с файлами и тут затупок...
PHP Code:
        case 2:
        {
            new 
name[MAX_PLAYER_NAME];
            new 
string[128];
            
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
            
format(string,sizeof(string),"%s.ini",name);
            
ini_createFile(string);
            
RegisterPlayer(playerid,inputtext);
        } 
PHP Code:
public RegisterPlayer(playerid,password[])
{
    new 
name[MAX_PLAYER_NAME];
    new 
string[128];
    
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    
format(string,sizeof(string),"%s.ini",name);
     new 
iniFile ini_openFile (string);
    
ini_setString(iniFile,"password",password);
    
ini_closeFile(iniFile);
    return 
true;

Файлик не создается. Помогите =(


Re: mxINI - Mutha_X - 09.11.2013

Начните уже пользоваться нативными функциями напрямую, тогда поймёте что в данном случае где "разница" - там и ошибка.


Re: mxINI - Nadim - 16.11.2013

Quote:
Originally Posted by pozitiv4eg
View Post
Уже наверное год не работал с файлами и тут затупок...
PHP Code:
        case 2:
        {
            new 
name[MAX_PLAYER_NAME];
            new 
string[128];
            
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
            
format(string,sizeof(string),"%s.ini",name);
            
ini_createFile(string);
            
RegisterPlayer(playerid,inputtext);
        } 
PHP Code:
public RegisterPlayer(playerid,password[])
{
    new 
name[MAX_PLAYER_NAME];
    new 
string[128];
    
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    
format(string,sizeof(string),"%s.ini",name);
     new 
iniFile ini_openFile (string);
    
ini_setString(iniFile,"password",password);
    
ini_closeFile(iniFile);
    return 
true;

Файлик не создается. Помогите =(
1 - Используй stock вместо public (и убери форвард) кроме таймеров! - ТАК БЫСТРЕЕ!!!
2 - Надо ЗАКРЫВАТЬ + ПРИСВАИВАТЬ ПЕРЕМЕННУЮ ФАЙЛУ!!!
Сделай так:
PHP Code:
case 2:
{
new 
name[MAX_PLAYER_NAME];
new 
string[5+MAX_PLAYER_NAME];/*Стрингов нужно столько сколько (иначе пустая трата)
Макс. размер файла + сколько символов (кроме %s) + 1
*/
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof(string),"%s.ini",name);
new 
iniFile ini_createFile(string);//Ты забыл добавить "new iniFile" и "ini_closeFile(iniFile);"
ini_closeFile(iniFile);
RegisterPlayer(playerid,inputtext);

3 - new string[128]; зачем так много? Используй new string[5+MAX_PLAYER_NAME];


Re: mxINI - ZiGGi - 17.11.2013

Quote:
Originally Posted by pozitiv4eg
View Post
Уже наверное год не работал с файлами и тут затупок...
PHP Code:
        case 2:
        {
            new 
name[MAX_PLAYER_NAME];
            new 
string[128];
            
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
            
format(string,sizeof(string),"%s.ini",name);
            
ini_createFile(string);
            
RegisterPlayer(playerid,inputtext);
        } 
PHP Code:
public RegisterPlayer(playerid,password[])
{
    new 
name[MAX_PLAYER_NAME];
    new 
string[128];
    
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    
format(string,sizeof(string),"%s.ini",name);
     new 
iniFile ini_openFile (string);
    
ini_setString(iniFile,"password",password);
    
ini_closeFile(iniFile);
    return 
true;

Файлик не создается. Помогите =(
Так будет лучше:
pawn Code:
case 2:
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    RegisterPlayer(playerid, name, inputtext);
}
pawn Code:
stock RegisterPlayer(playerid, name[], password[])
{
    new string[MAX_PLAYER_NAME + 5];
    format(string, sizeof(string), "%s.ini", name);
    new iniFile = ini_createFile(string);
    ini_setString(iniFile, "password", password);
    ini_closeFile(iniFile);
}