Register Script Issue
#1

Alright, so I have a registration script issue, but it does not seem to be working, it worked before I added gTeam in and shizz.

Here is what I have...

pawn Код:
public OnPlayerConnect(playerid)
{
    enum pInfo
{
    pAdmin,
    pCash,
    pScore,
    gTeam,
}
    new request[MAX_PLAYERS];
    new PlayerInfo[MAX_PLAYERS][pInfo];
    new gPlayerLogged[MAX_PLAYERS];
    #define SERVER_USER_FILE "users/%s.ini"

    gPlayerLogged[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Welcome, Please type in a desired password below!", "Register", "Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome Back!", "Please type your password below to continue!", "Login", "Leave");
    }
    return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    enum pInfo
    {
    pAdmin,
    pCash,
    pScore,
    pSkin,
    }
    new PlayerInfo[MAX_PLAYERS][pInfo];
    new gPlayerLogged[MAX_PLAYERS];

    new name[MAX_PLAYER_NAME];
    new file[25];
    format(file, sizeof(file), "%s.ini",GetPlayerName(playerid,name,sizeof(name)));
    if(!fexist(file))
    {
        dini_Create(file);
    }

    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(gPlayerLogged[playerid] == 1)
    {
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(file, "Skin", PlayerInfo[playerid][pSkin]);
        dini_IntSet(file, "team", PlayerInfo[playerid][gTeam]);
    }
    gPlayerLogged[playerid] = 0;
    return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    enum pInfo
    {
    pAdmin,
    pCash,
    pScore,
    gTeam,
    }
    new PlayerInfo[MAX_PLAYERS][pInfo];
    new gPlayerLogged[MAX_PLAYERS];

    if (dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Welcome, Please type in a desired password below!", "Register", "Leave");
            dini_Create(file);
            dini_IntSet(file, "Password", udb_hash(inputtext));
            dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdmin] = 0);
            dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 5000);
            dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
            dini_IntSet(file, "Team",PlayerInfo[playerid][gTeam] = 2);
            format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
            SendClientMessage(playerid, 0xFFFF00AA, string);
            gPlayerLogged[playerid] = 1;
    }
    if (dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome Back!", "Please type your password below to continue!", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
            SendClientMessage(playerid, 0x00FFFFFF, "Invalid password!");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome Back!", "Please type your password below to continue!", "Login", "Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdmin] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][gTeam] = dini_Int(file, "Team");
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
            GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
            SendClientMessage(playerid,0x00FFFFFF, "[SYSTEM]: Successfully logged in!");
            if(!dini_Exists(file))
            {
                dini_Create(file);
                dini_IntSet(file, "Score", 0);
                dini_IntSet(file, "Money", 0);
                dini_IntSet(file, "Team", 2);
                SetPlayerScore(playerid, dini_Int(file, "Score"));
                SetPlayerMoney(playerid, dini_Int(file, "Money"));
                return 1;
            }
        }
    }
    return 0;
}
I cannot seem to find my mistake, please help, if you are helpful, I will kindly +rep you!
Reply
#2

enum pInfo
{
pAdmin,
pCash,
pScore,
gTeam,
}

In each callback will create separate DIFFERENT variables which won't share any data. Good use ot it is to Create them as Global Variables
pawn Код:
#include <a_samp>
#include <Dini>
#include <dudb>

enum pInfo
{
    pAdmin,
    pCash,
    pScore,
    gTeam,
    pSkin
}

new request[MAX_PLAYERS];
new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];
#define SERVER_USER_FILE "users/%s.ini"

public OnPlayerConnect(playerid)
{
    gPlayerLogged[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Welcome, Please type in a desired password below!", "Register", "Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome Back!", "Please type your password below to continue!", "Login", "Leave");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[MAX_PLAYER_NAME];
    new file[25];
    format(file, sizeof(file), "%s.ini",GetPlayerName(playerid,name,sizeof(name)));
    if(!fexist(file))
    {
        dini_Create(file);
    }

    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), SERVER_USER_FILE, name);
    if(gPlayerLogged[playerid] == 1)
    {
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(file, "Skin", PlayerInfo[playerid][pSkin]);
        dini_IntSet(file, "team", PlayerInfo[playerid][gTeam]);
    }
    gPlayerLogged[playerid] = 0;
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "Welcome, Please type in a desired password below!", "Register", "Leave");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdmin] = 0);
        dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 5000);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        dini_IntSet(file, "Team",PlayerInfo[playerid][gTeam] = 2);
        format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, 0xFFFF00AA, string);
        gPlayerLogged[playerid] = 1;
    }
    if (dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome Back!", "Please type your password below to continue!", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp)
        {
            SendClientMessage(playerid, 0x00FFFFFF, "Invalid password!");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Welcome Back!", "Please type your password below to continue!", "Login", "Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdmin] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][gTeam] = dini_Int(file, "Team");
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
            GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
            SendClientMessage(playerid,0x00FFFFFF, "[SYSTEM]: Successfully logged in!");
            if(!dini_Exists(file))
            {
                dini_Create(file);
                dini_IntSet(file, "Score", 0);
                dini_IntSet(file, "Money", 0);
                dini_IntSet(file, "Team", 2);
                SetPlayerScore(playerid, dini_Int(file, "Score"));
                SetPlayerMoney(playerid, dini_Int(file, "Money"));
                return 1;
            }
        }
    }
    return 0;
}
In Pastebin: http://pastebin.com/uvHZLfvr
Reply
#3

Nope, When I get in game, it does the same thing as before, the dialog never opens etc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)