[Y_INI] Compiler crash
#1

pawn Код:
enum playerinfo
{
    IP[20],
    Password,
    ALevel,
    Helper,
    Kills,
    Deaths,
    Money,
    Experience
}

#define DIALOG_LOGIN 1
#define DIALOG_REGISTER 2
#define DIALOG_LOGIN_SUCCESS 3
#define DIALOG_REGISTER_SUCCESS 4

#define upath "GW/Users"

stock getini(pid)
{
    format(SOS, 40, "%s/%s.ini", upath, pname(pid) );
    return SOS;
}

new pInfo[MAX_PLAYERS][playerinfo];

public OnPlayerConnect(playerid)
{
    if(fexist(getini(playerid))
    {
        INI_ParseFile(getini(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Registering...","Type your password below to register a new account.","Register","Quit");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                RegisterUser(playerid, udb_hash(inputtext) );
                ShowPlayerDialog(playerid, DIALOG_REGISTER_SUCCESS, DIALOG_STYLE_MSGBOX,"Success!","You've been successfully registered on our server!","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if (!response) return Kick (playerid);
            if(response)
            {
                if(udb_hash(inputtext) == pInfo[playerid][Password])
                {
                    INI_ParseFile(getini(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, pInfo[playerid][Money]);
                    ShowPlayerDialog(playerid, DIALOG_LOGIN_SUCCESS, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}

stock pname(pid)
{
    new name[20];
    GetPlayerName(pid, name, 20);
    return name;
}

stock pip(pid)
{
    GetPlayerIp(pid, pInfo[pid][IP], 20);
    return pInfo[pid][IP];
}

stock RegisterUser(pid, pass[] = "bleh)
{
    if(fexist(getini(pid))) return 0;
    if(!IsPlayerConnected(pid)) return 0;
    else
    {
        new INI:uh = INI_Open(getini(pid));
        INI_SetTag(uh, "
data");
        INI_WriteString(uh, "
Name", pname(pid) );
        INI_WriteString(uh, "
IP", pip(pid) );
        INI_WriteInt(uh, "
Password", pInfo[pid][Password]);
        INI_WriteInt(uh, "
Kills", pInfo[pid][Kills]);
        INI_WriteInt(uh, "
Deaths", pInfo[pid][Deaths]);
        INI_WriteInt(uh, "
Experience", pInfo[pid][Experience]);
        INI_WriteInt(uh, "
Helper", pInfo[pid][Helper]);
        INI_WriteInt(uh, "
AdminLevel", pInfo[pid][ALevel]);
    }
    return 1;
}

stock SaveUser(pid)
{
    if(!fexist(getini(pid))) return 0;
    if(!IsPlayerConnected(pid)) return 0;
    else
    {
        new INI:uh = INI_Open(getini(pid));
        INI_SetTag(uh, "
data");
        INI_WriteString(uh, "
Name", pname(pid) );
        INI_WriteString(uh, "
IP", pInfo[pid][IP] );
        INI_WriteInt(uh, "
Password", pInfo[pid][Password]);
        INI_WriteInt(uh, "
Kills", pInfo[pid][Kills]);
        INI_WriteInt(uh, "
Deaths", pInfo[pid][Deaths]);
        INI_WriteInt(uh, "
Experience", pInfo[pid][Experience]);
        INI_WriteInt(uh, "
Money", pInfo[pid][Money]);
        INI_WriteInt(uh, "
Helper", pInfo[pid][Helper]);
        INI_WriteInt(uh, "
AdminLevel", pInfo[pid][ALevel]);
    }
    return 1;
}

stock LoadUser_data(pid,name[],value[])
{
    INI_Int("
Password",pInfo[pid][Password]);
    INI_Int("
Money",pInfo[pid][Money]);
    INI_Int("
AdminLevel",pInfo[pid][ALevel]);
    INI_Int("
Kills",pInfo[pid][Kills]);
    INI_Int("
Deaths",pInfo[pid][Deaths]);
    INI_Int("
Helper", pInfo[pid][Helper]);
    INI_Int("
Password", pInfo[pid][Helper]);
    INI_Int("
Experience", pInfo[pid][Experience]);
    return 1;
}

stock udb_hash(buf[])
{
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
Compiler starts crashing, after I added this code ^.
I remove = compiles.
Reply
#2

Change

PHP код:
stock RegisterUser(pidpass[] = "bleh)
{
    if(fexist(getini(pid))) return 0;
    if(!IsPlayerConnected(pid)) return 0;
    else
    {
        new INI:uh = INI_Open(getini(pid));
        INI_SetTag(uh, "
data");
        INI_WriteString(uh, "
Name", pname(pid) );
        INI_WriteString(uh, "
IP", pip(pid) );
        INI_WriteInt(uh, "
Password", pInfo[pid][Password]);
        INI_WriteInt(uh, "
Kills", pInfo[pid][Kills]);
        INI_WriteInt(uh, "
Deaths", pInfo[pid][Deaths]);
        INI_WriteInt(uh, "
Experience", pInfo[pid][Experience]);
        INI_WriteInt(uh, "
Helper", pInfo[pid][Helper]);
        INI_WriteInt(uh, "
AdminLevel", pInfo[pid][ALevel]);
    }
    return 1;

By

PHP код:
stock RegisterUser(pidpass[] = "bleh")
{
    if(
fexist(getini(pid))) return 0;
    if(!
IsPlayerConnected(pid)) return 0;
    else
    {
        new 
INI:uh INI_Open(getini(pid));
        
INI_SetTag(uh"data");
        
INI_WriteString(uh"Name"pname(pid) );
        
INI_WriteString(uh"IP"pip(pid) );
        
INI_WriteInt(uh"Password"pInfo[pid][Password]);
        
INI_WriteInt(uh"Kills"pInfo[pid][Kills]);
        
INI_WriteInt(uh"Deaths"pInfo[pid][Deaths]);
        
INI_WriteInt(uh"Experience"pInfo[pid][Experience]);
        
INI_WriteInt(uh"Helper"pInfo[pid][Helper]);
        
INI_WriteInt(uh"AdminLevel"pInfo[pid][ALevel]);
    }
    return 
1;

Reply
#3

Quote:
Originally Posted by yusei
Посмотреть сообщение
Change

PHP код:
stock RegisterUser(pidpass[] = "bleh)
{
    if(fexist(getini(pid))) return 0;
    if(!IsPlayerConnected(pid)) return 0;
    else
    {
        new INI:uh = INI_Open(getini(pid));
        INI_SetTag(uh, "
data");
        INI_WriteString(uh, "
Name", pname(pid) );
        INI_WriteString(uh, "
IP", pip(pid) );
        INI_WriteInt(uh, "
Password", pInfo[pid][Password]);
        INI_WriteInt(uh, "
Kills", pInfo[pid][Kills]);
        INI_WriteInt(uh, "
Deaths", pInfo[pid][Deaths]);
        INI_WriteInt(uh, "
Experience", pInfo[pid][Experience]);
        INI_WriteInt(uh, "
Helper", pInfo[pid][Helper]);
        INI_WriteInt(uh, "
AdminLevel", pInfo[pid][ALevel]);
    }
    return 1;

By

PHP код:
stock RegisterUser(pidpass[] = "bleh")
{
    if(
fexist(getini(pid))) return 0;
    if(!
IsPlayerConnected(pid)) return 0;
    else
    {
        new 
INI:uh INI_Open(getini(pid));
        
INI_SetTag(uh"data");
        
INI_WriteString(uh"Name"pname(pid) );
        
INI_WriteString(uh"IP"pip(pid) );
        
INI_WriteInt(uh"Password"pInfo[pid][Password]);
        
INI_WriteInt(uh"Kills"pInfo[pid][Kills]);
        
INI_WriteInt(uh"Deaths"pInfo[pid][Deaths]);
        
INI_WriteInt(uh"Experience"pInfo[pid][Experience]);
        
INI_WriteInt(uh"Helper"pInfo[pid][Helper]);
        
INI_WriteInt(uh"AdminLevel"pInfo[pid][ALevel]);
    }
    return 
1;

Missing ", thank you so much.

NEW BUG -

The file isn't created at scriptfiles/GW/Users/%s.ini
I've only changed this part, the above script is the same

pawn Код:
stock RegisterUser(pid, pass)
{
    if(fexist(getini(pid))) return 0;
    if(!IsPlayerConnected(pid)) return 0;
    else
    {
        new INI:uh = INI_Open(getini(pid));
        INI_SetTag(uh, "data");
        INI_WriteString(uh, "Name", pname(pid) );
        INI_WriteString(uh, "IP", pip(pid) );
        INI_WriteInt(uh, "Password", pass);
        pInfo[pid][Password] = pass;
        INI_WriteInt(uh, "Kills", pInfo[pid][Kills]);
        INI_WriteInt(uh, "Deaths", pInfo[pid][Deaths]);
        INI_WriteInt(uh, "Experience", pInfo[pid][Experience]);
        INI_WriteInt(uh, "Helper", pInfo[pid][Helper]);
        INI_WriteInt(uh, "AdminLevel", pInfo[pid][ALevel]);
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by CreativityLacker
Посмотреть сообщение
Missing ", thank you so much.
your going to come back to the forums if you don't close the file.

Код:
stock RegisterUser(pid, pass[] = "bleh)
{
    if(fexist(getini(pid))) return 0;
    if(!IsPlayerConnected(pid)) return 0;
    else
    {
        new INI:uh = INI_Open(getini(pid));
        INI_SetTag(uh, "data");
        INI_WriteString(uh, "Name", pname(pid) );
        INI_WriteString(uh, "IP", pip(pid) );
        INI_WriteInt(uh, "Password", pInfo[pid][Password]);
        INI_WriteInt(uh, "Kills", pInfo[pid][Kills]);
        INI_WriteInt(uh, "Deaths", pInfo[pid][Deaths]);
        INI_WriteInt(uh, "Experience", pInfo[pid][Experience]);
        INI_WriteInt(uh, "Helper", pInfo[pid][Helper]);
        INI_WriteInt(uh, "AdminLevel", pInfo[pid][ALevel]);
        INI_Close(uh); //this
    }
    return 1;
}

stock SaveUser(pid)
{
    if(!fexist(getini(pid))) return 0;
    if(!IsPlayerConnected(pid)) return 0;
    else
    {
        new INI:uh = INI_Open(getini(pid));
        INI_SetTag(uh, "data");
        INI_WriteString(uh, "Name", pname(pid) );
        INI_WriteString(uh, "IP", pInfo[pid][IP] );
        INI_WriteInt(uh, "Password", pInfo[pid][Password]);
        INI_WriteInt(uh, "Kills", pInfo[pid][Kills]);
        INI_WriteInt(uh, "Deaths", pInfo[pid][Deaths]);
        INI_WriteInt(uh, "Experience", pInfo[pid][Experience]);
        INI_WriteInt(uh, "Money", pInfo[pid][Money]);
        INI_WriteInt(uh, "Helper", pInfo[pid][Helper]);
        INI_WriteInt(uh, "AdminLevel", pInfo[pid][ALevel]);
        INI_Close(uh); //this
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by arbit
Посмотреть сообщение
your going to come back to the forums if you don't close the file.

Код:
stock RegisterUser(pid, pass[] = "bleh)
{
    if(fexist(getini(pid))) return 0;
    if(!IsPlayerConnected(pid)) return 0;
    else
    {
        new INI:uh = INI_Open(getini(pid));
        INI_SetTag(uh, "data");
        INI_WriteString(uh, "Name", pname(pid) );
        INI_WriteString(uh, "IP", pip(pid) );
        INI_WriteInt(uh, "Password", pInfo[pid][Password]);
        INI_WriteInt(uh, "Kills", pInfo[pid][Kills]);
        INI_WriteInt(uh, "Deaths", pInfo[pid][Deaths]);
        INI_WriteInt(uh, "Experience", pInfo[pid][Experience]);
        INI_WriteInt(uh, "Helper", pInfo[pid][Helper]);
        INI_WriteInt(uh, "AdminLevel", pInfo[pid][ALevel]);
        INI_Close(uh); //this
    }
    return 1;
}

stock SaveUser(pid)
{
    if(!fexist(getini(pid))) return 0;
    if(!IsPlayerConnected(pid)) return 0;
    else
    {
        new INI:uh = INI_Open(getini(pid));
        INI_SetTag(uh, "data");
        INI_WriteString(uh, "Name", pname(pid) );
        INI_WriteString(uh, "IP", pInfo[pid][IP] );
        INI_WriteInt(uh, "Password", pInfo[pid][Password]);
        INI_WriteInt(uh, "Kills", pInfo[pid][Kills]);
        INI_WriteInt(uh, "Deaths", pInfo[pid][Deaths]);
        INI_WriteInt(uh, "Experience", pInfo[pid][Experience]);
        INI_WriteInt(uh, "Money", pInfo[pid][Money]);
        INI_WriteInt(uh, "Helper", pInfo[pid][Helper]);
        INI_WriteInt(uh, "AdminLevel", pInfo[pid][ALevel]);
        INI_Close(uh); //this
    }
    return 1;
}
Thanks to you too, I guess thats the reason the file didn't appear!
Solved.
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
The syntax highlighting alone should have shown you one problem!
IKR but it's 1:44 AM, and it's 3 degrees here, it makes my ability to analyze weaker
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)