[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


Messages In This Thread
[Y_INI] Compiler crash - by CreativityLacker - 10.01.2013, 17:31
Re : [Y_INI] Compiler crash - by yusei - 10.01.2013, 18:13
Re: Re : [Y_INI] Compiler crash - by CreativityLacker - 10.01.2013, 18:18
Re: Re : [Y_INI] Compiler crash - by u3ber - 10.01.2013, 18:21
Re: Re : [Y_INI] Compiler crash - by CreativityLacker - 10.01.2013, 18:26
Re: [Y_INI] Compiler crash - by CreativityLacker - 10.01.2013, 18:53

Forum Jump:


Users browsing this thread: 1 Guest(s)