Converting from DINI to DUDB
#1

Okay, so i've read the tutorial on DUDB, it's hard to understand compared to how simple DINI is, I wanna convert my register/login script from DINI to DUDB, If you could point me in the right direction that would be great.
Heres my Filterscript.
pawn Код:
#define FILTERSCRIPT
#include <a_samp>
#include <Dini>
#include <dudb>

#pragma unused ret_memcpy
#pragma unused strtok

#define Login 0
#define Register 1

#define COLOR_GREEN 0x36D158F6
#define COLOR_YELLOW 0xF6D10AF6
#define COLOR_RED 0xC30000F6 //   COLOR_RED

enum list{level,cash,skinid,death,kill};
new stats[MAX_PLAYERS][list];
new name[20][MAX_PLAYERS];
new st[256];

public OnPlayerConnect(playerid)
{
    name[playerid] = GetName(playerid);
    Entry(playerid);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == Register)
    {
        if(response)
        {
            if(!strlen(inputtext))
            {
                SendClientMessage(playerid, COLOR_YELLOW, "The password may have a minimun of 5 characters and maximum of 20!");
                return Entry(playerid);
            }
        if(20 < strlen(inputtext) || strlen(inputtext) < 5)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "The password may have a minimun of 5 characters and maximum 20!");
                return Entry(playerid);
            }
            else
            {
              format(st,sizeof(st),"accounts/%s.user",name[playerid]);
                dini_Create((st));
                dini_IntSet((st), "Password", udb_hash(inputtext));
                dini_Set((st),"Pass",inputtext);
            dini_IntSet((st), "Level", 0);
        dini_IntSet((st), "Cash", 5000);
                dini_IntSet((st), "Skinid", 0);
            dini_IntSet((st), "Deaths", 0);
                dini_IntSet((st), "Kills", 0);
            printf(st);
                format(st, sizeof(st), "** [SERVER] Your account '%s' has been created with the password %s **", name[playerid], inputtext);
                SendClientMessage(playerid, COLOR_YELLOW, st);
                Entry(playerid);
            }
        }
        else
        {
            Entry(playerid);
        }
    }
    if(dialogid == Login)
    {
        if(response)
        {
            if(!strlen(inputtext))
            {
                SendClientMessage(playerid, COLOR_RED, "Wrong Password");
                return Entry(playerid);
            }
        if(20 < strlen(inputtext) || strlen(inputtext) < 5 )
            {
                SendClientMessage(playerid, COLOR_RED, "Wrong Password");
                return Entry(playerid);
            }
            else
            {
                format(st,sizeof(st),"accounts/%s.user",name[playerid]);

                  new string[256];
                    string = dini_Get((st), "Password");
                    if (udb_hash(inputtext) != strval(string))
                    {
                    SendClientMessage(playerid, COLOR_RED, "Wrong Password");
                    return Entry(playerid);
                    }
                    else
                    {
                        dini_Set((st),"Pass",inputtext);
                stats[playerid][level] = dini_Int((name[playerid]), "Level");
            stats[playerid][cash] = dini_Int((name[playerid]), "Cash");
                stats[playerid][skinid] = dini_Int((name[playerid]), "Skinid");
                stats[playerid][death] = dini_Int((name[playerid]), "Deaths");
                stats[playerid][kill] = dini_Int((name[playerid]), "Kills");
                GivePlayerMoney(playerid, stats[playerid][cash]);
                        SendClientMessage(playerid, COLOR_GREEN, "Welcome to Esperanza Roleplay.");
            SpawnPlayer(playerid);
                    }
            }

        }
        else
        {
            Entry(playerid);
        }
    }
    return 1;
}

Entry(playerid)
{
  format(st,sizeof(st),"accounts/%s.user",name[playerid]);
    if(dini_Exists(st))
    {
      format(st,256,"Welcome to ESP-RP, Please input your Password\nTo Login:");
        ShowPlayerDialog(playerid,Login,DIALOG_STYLE_INPUT,"Login System",st,"Login","Quit");
    }
    else
    {
      format(st,256,"Welcome to ESP-RP, Please input your Password\nTo create an account:");
        ShowPlayerDialog(playerid,Register,DIALOG_STYLE_INPUT,"Register System",st,"Register","Quit");
    }
    return 1;
}

GetName(playerid)
{
    new pseudo[20];
    GetPlayerName(playerid,pseudo,sizeof(pseudo));
    return pseudo;
}
[/list]
Reply
#2

Anyone?
Reply
#3

You said that you have read a DUDB tutorial, so you can change this DINI functions to DUDB one's.
what's the problem?
Reply
#4

Did you not read all of the opening post? I said that i've read it, but found it harder to understand. If there wasn't a problem i wouldn't of posted this.

thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)