Converting to Dini
#1

Hi could i have some help converting YINI to dini?

pawn Код:
public loadaccount_user(playerid, name[], value[])
{
    INI_String("Ppassword", PlayerInfo[playerid][Ppassword],24);
    INI_Int("Padmin",PlayerInfo[playerid][Padmin]);
    INI_Int("Pmoney",PlayerInfo[playerid][Pmoney]);
    INI_Int("Pscore",PlayerInfo[playerid][Pscore]);
    INI_Int("Pbank",PlayerInfo[playerid][Pbank]);
    INI_Int("Pstat",PlayerInfo[playerid][Pstat]);
    INI_Int("Parmy",PlayerInfo[playerid][Parmy]);
    INI_Int("Pswat",PlayerInfo[playerid][Pswat]);
    INI_Int("Pcop",PlayerInfo[playerid][Pcop]);
    INI_Int("Pregdate",PlayerInfo[playerid][Pregdate]);
    INI_Int("Pprison",PlayerInfo[playerid][Pprison]);
    INI_Int("Phelper",PlayerInfo[playerid][Phelper]);
    INI_Int("Pscore",PlayerInfo[playerid][Pscore]);
    INI_String("Pemail", PlayerInfo[playerid][Pemail],255);
    INI_Int("Ptime",PlayerInfo[playerid][Ptime]);
    INI_Int("Parrest",PlayerInfo[playerid][Parrest]);
    INI_Int("Psurender",PlayerInfo[playerid][Psurender]);
    INI_Int("Prob",PlayerInfo[playerid][Prob]);
    INI_Int("Prape",PlayerInfo[playerid][Prape]);
    INI_Int("Pheal",PlayerInfo[playerid][Pheal]);
    INI_Int("Phitman",PlayerInfo[playerid][Phitman]);
    INI_Int("Psales",PlayerInfo[playerid][Psales]);
    INI_Int("Pwep",PlayerInfo[playerid][Pwep]);
    INI_Int("Ptruck",PlayerInfo[playerid][Ptruck]);
    return 1;
}

if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
    {// then
        INI_ParseFile(Path(playerid),"loadaccount_user", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
        ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"{00FF00}San Fierro Cops And Robbers","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
    }
    else //If the connected user is not registered,
    {//then we will 'force' him to register :)
        ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.","Register","Quit");
        return 1;
    }

if(fexist(Path(playerid)))//Will check if the file is exit or not inside of User's folder that we have created.
    {
        new INI:file = INI_Open(Path(playerid)); //will open their file
        INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
        INI_WriteInt(file,"Padmin",PlayerInfo[playerid][Padmin]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
        INI_WriteInt(file,"Pvip",PlayerInfo[playerid][Pvip]);//As explained above
        INI_WriteInt(file,"Pmoney",GetPlayerMoney(playerid));//We will save his money inside of his account
        INI_WriteInt(file,"Pscore",GetPlayerScore(playerid));
        INI_WriteInt(file,"Pbank",PlayerInfo[playerid][Pbank]);
        INI_WriteInt(file,"Pstat",PlayerInfo[playerid][Pstat]);
        INI_WriteInt(file,"Parmy",PlayerInfo[playerid][Parmy]);
        INI_WriteInt(file,"Pswat",PlayerInfo[playerid][Pswat]);
        INI_WriteInt(file,"Pcop",PlayerInfo[playerid][Pcop]);
        INI_WriteInt(file,"Pprison",PlayerInfo[playerid][Pprison]);
        INI_WriteInt(file,"Parrest",PlayerInfo[playerid][Parrest]);
        INI_WriteInt(file,"Psurender",PlayerInfo[playerid][Psurender]);
        INI_WriteInt(file,"Prob",PlayerInfo[playerid][Prob]);
        INI_WriteInt(file,"Prape",PlayerInfo[playerid][Prape]);
        INI_WriteInt(file,"Pheal",PlayerInfo[playerid][Pheal]);
        INI_WriteInt(file,"Phitman",PlayerInfo[playerid][Phitman]);
        INI_WriteInt(file,"Psales",PlayerInfo[playerid][Psales]);
        INI_WriteInt(file,"Pwep",PlayerInfo[playerid][Pwep]);
        INI_WriteInt(file,"Pdrug",PlayerInfo[playerid][Pdrug]);
        INI_WriteInt(file,"Ptruck",PlayerInfo[playerid][Ptruck]);//We will save his score inside of his account
        INI_Close(file);//Now after we've done saving their data, we now need to close the file
        return 1;
    }

if(dialogid == dregister)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            if(!strlen(inputtext))
            {
                ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
                return 1;
            }
            new hashpass[129];
            new nothing[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            new INI:file = INI_Open(Path(playerid));
            INI_SetTag(file,"Player's Data");
            INI_WriteString(file,"Ppassword",hashpass);
            INI_WriteInt(file,"Padmin",0);
            INI_WriteInt(file,"Pvip",0);
            INI_WriteInt(file,"Pmoney",0);
            INI_WriteInt(file,"Pscore",0);
            INI_WriteInt(file,"Pbank",0);
            INI_WriteInt(file,"Pstat",0);
            INI_WriteInt(file,"Parmy",0);
            INI_WriteInt(file,"Pswat",0);
            INI_WriteInt(file,"Pcop",0);
            INI_WriteInt(file,"Pregdate",0);
            INI_WriteInt(file,"Preg",1);
            INI_WriteInt(file,"Pprison",0);
            INI_WriteInt(file,"Phelper",0);
            INI_WriteInt(file,"Pscore",0);
            INI_WriteString(file,"Pemail",nothing);
            INI_WriteInt(file,"Ptime",0);
            INI_WriteInt(file,"Parrest",0);
            INI_WriteInt(file,"Psurender",0);
            INI_WriteInt(file,"Prob",0);
            INI_WriteInt(file,"Prape",0);
            INI_WriteInt(file,"Pheal",0);
            INI_WriteInt(file,"Phitman",0);
            INI_WriteInt(file,"Psales",0);
            INI_WriteInt(file,"Pwep",0);
            INI_WriteInt(file,"Ptruck",0);
            INI_Close(file);
            SendClientMessage(playerid,-1,"You have been successfully registered");
        }
    }
    if(dialogid == dlogin)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            new hashpass[129];
            WP_Hash(hashpass,sizeof(hashpass),inputtext);
            if(strcmp(hashpass,PlayerInfo[playerid][Ppassword]))
            {
                INI_ParseFile(Path(playerid),"loadaccount_user",.bExtra = true, .extra = playerid);
                SetPlayerScore(playerid,PlayerInfo[playerid][Pscore]);
                GivePlayerMoney(playerid,PlayerInfo[playerid][Pmoney]);
                SendClientMessage(playerid,-1,"Welcome back! You have successfully logged in");
            }
            else if(!strcmp(hashpass,PlayerInfo[playerid][Ppassword]))
            {
                ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"Login","Welcome back. This account is registered. \nInsert your password to login to your account.\nIncorrect password!","Login","Quit");//We will tell to them that they've entered an incorrect password
                return 1;
            }
        }
    }
    return 1;


CMD:chouse(playerid, params[])
{
    if(PlayerInfo[playerid][Padmin] >=4)
    {
        new id = HouseCount, interior;
        if(sscanf(params,"i",interior)) return SendClientMessage(playerid, COLOR_GREEN, "USAGE: /chouse <interior>");
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        HouseInfo[id][Interior] = interior;
        HouseInfo[id][Owned] = 0;
        HouseInfo[id][XPos] = X;
        HouseInfo[id][YPos] = Y;
        HouseInfo[id][ZPos] = Z;
        SCM(playerid, COLOR_GREEN, "You have created a house!");
        HouseEnterPickup[id]  = CreatePickup(1273,23,X,Y,Z,-1);
        new file[40];
        format(file,sizeof(file),"Sfcnr/Users/Houses/%i.ini",id);
        INI_Open(file);
        INI_WriteInt(file,"Interior",interior);
        INI_WriteInt(file,"Owned",0);
        INI_WriteFloat(file,"XPos",X);
        INI_WriteFloat(file,"YPos",Y);
        //INI_WriteFloat(file,"ZPos",Z);
        INI_WriteString(file,"Owner",HouseInfo[id][Owner]);
        INI_Close();
        HouseCount++;
        return 1;
    }
    else if(PlayerInfo[playerid][Padmin] < 4)
    {
        SendClientMessage(playerid, COLOR_RED, "You are not admin.");
        return 1;
    }
    return 1;
}
I know its alot but if u could atleast convert 1 code snippet i could do the rest
Reply


Messages In This Thread
Converting to Dini - by thefatshizms - 12.08.2012, 22:02
Re: Converting to Dini - by Speed++ - 12.08.2012, 22:03
Re: Converting to Dini - by SA-MPDrifter - 12.08.2012, 22:04
Re: Converting to Dini - by Forge - 12.08.2012, 22:11
Re: Converting to Dini - by thefatshizms - 12.08.2012, 22:16

Forum Jump:


Users browsing this thread: 1 Guest(s)