Loading data with Y_INI
#6

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
Mayne, you are teaching him a wrong stuff....

pawn Код:
#include <a_samp>
#include <YSI\y_ini>

#define MENU_LOGIN 0
#define MENU_REGISTER 1

#define COLOR_YELLOW -1
#define COLOR_GREY -1
#define COLOR_GREEN -1
#define COLOR_DARKRED -1

native WP_Hash(buffer[],len,const str[]);

enum pInfo
{
    pPassword[129]
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_String("Password", PlayerInfo[playerid][pPassword], 129);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),"Accounts/%s.ini",playername);
    return string;
}

public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME];
    if(!fexist(UserPath(playerid)))
    {
        new string[367 + MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "-MSG- The username '%s' is not registered. Please enter a Password to Register",name);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "{FFFF00}Requested username: {FFFFFF}%s\nThis username is: {009900}Available\n\n{AF0000}We suggest that you don't register\nwith an RP name (Firstname_Lastname)\nbecause you can manage multiple\ncharacters from one account.\nThe name you register now will not\nbe your in-game name.\n\n{FFFFFF}By registering,\nyou agree to our terms of use.\n\n{FFFF00}Enter a Password to register",name);
        ShowPlayerDialog(playerid, MENU_REGISTER, DIALOG_STYLE_PASSWORD, "Hopes Hills RP Account", string, "Register", "Quit");
    }
    else
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        new string[80 + MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "-MSG- The username '%s' is already registered. Please log in with your Password",name);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        SendClientMessage(playerid, COLOR_GREY, "-MSG- Not your account? Then relog with another name");
        format(string, sizeof(string), "{FFFF00}Your username: {FFFFFF}%s\n\nEnter your Password to log in",name);
        ShowPlayerDialog(playerid, MENU_LOGIN, DIALOG_STYLE_PASSWORD, "Hopes Hills RP Account", string, "Login", "Quit");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case MENU_LOGIN:
        {
            if (!response)
            {
                SendClientMessage(playerid, COLOR_DARKRED, "-MSG- You must log in in order to play on this server");
                Kick(playerid);
            }
            else
            {
                new buf[129];
                WP_Hash(buf, sizeof(buf), inputtext);
                if(!strcmp(buf, PlayerInfo[playerid][pPassword], false))
                {
                    new string[80 + MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, name, sizeof(name));
                    format(string, sizeof(string), "{FFFF00}Your username: {FFFFFF}%s\n\n{AF0000}Incorrect password!\n\n{FFFF00}Enter your Password to log in",name);
                    ShowPlayerDialog(playerid, MENU_LOGIN, DIALOG_STYLE_PASSWORD, "Hopes Hills RP Account", string, "Login", "Quit");
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREEN, "-MSG- Welcome back!");
                }
            }
        }
        case MENU_REGISTER:
        {
            // code .....
        }
    }
    return true;
}
Compilation
Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           2700 bytes
Code size:            64420 bytes
Data size:         17057772 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:17141276 bytes
[Finished in 6.1s]
The problem is you have an outdated YSI version, update it and your code should work fine

Lastest Update: https://sampforum.blast.hk/showthread.php?tid=321092
Thank you. But I still get the errors... Strange
Reply


Messages In This Thread
Loading data with Y_INI - by sim_sima - 15.12.2013, 21:01
Re: Loading data with Y_INI - by dakata994 - 15.12.2013, 21:07
Re: Loading data with Y_INI - by sim_sima - 15.12.2013, 21:12
Re: Loading data with Y_INI - by dakata994 - 15.12.2013, 21:16
Re: Loading data with Y_INI - by Patrick - 15.12.2013, 21:20
Re: Loading data with Y_INI - by sim_sima - 15.12.2013, 21:26
Re: Loading data with Y_INI - by Sgt.TheDarkness - 15.12.2013, 21:28
Re: Loading data with Y_INI - by dakata994 - 15.12.2013, 21:33
Re: Loading data with Y_INI - by sim_sima - 15.12.2013, 21:34
Re: Loading data with Y_INI - by sim_sima - 15.12.2013, 21:39

Forum Jump:


Users browsing this thread: 1 Guest(s)