what is the problem?
#1

in this FS.. (one system of adm/vip/accounts) the dialog REGISTER works BUT when clicking in register no works in the create of accounts nor create the dialog login... whats is the problem ??

The fs is this :

pawn Code:
#include <a_samp>
#include <dini>
#include <dudb>
#include <zcmd>

#define SCRIPT_VERSION          "v3"

#define colorRed                0xFF0000FF
#define colorGreen              0x008000FF

#define DIALOG_REGISTER         1
#define DIALOG_LOGIN            2
#define DIALOG_ACCOUNT          3
#define DIALOG_CHANGEPASS       4
#define DIALOG_VIEWSTATS        5
#define DIALOG_CHECKSTATS       6

#pragma unused                  ret_memcpy
#pragma unused                  strtok

forward UpdateTime(playerid);

new str[128];
new file[128];
new playerIP[16];

new Update;

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    format(file, 128, "/tReg/%s.ini", GetName(playerid));

    GetPlayerIp(playerid, playerIP, 16);

    TogglePlayerSpectating(playerid, 1);

    if(!dini_Exists(file))
    {
        format(str, 128, "Welcome %s \n\nPlease register your account", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Account Management", str, "Register", "Quit");
    }
    else
    {
    format(str, 128, "Welcome %s \n\nPlease login to your account", GetName(playerid));
    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    format(file, 128, "/tReg/%s.ini", GetName(playerid));

    if(GetPVarInt(playerid, "Logged") == 1)
    {
        dini_IntSet(file, "Money", GetPlayerMoney(playerid));
        dini_IntSet(file, "Score", GetPlayerScore(playerid));
        dini_IntSet(file, "Kills", GetPVarInt(playerid, "Kills"));
        dini_IntSet(file, "Deaths", GetPVarInt(playerid, "Deaths"));
        dini_IntSet(file, "Minutes Ingame", GetPVarInt(playerid, "Time"));
        dini_IntSet(file, "Adminlvl",GetPVarInt(playerid, "Admin"));             // new
        dini_IntSet(file, "VIPlvl",GetPVarInt(playerid, "VIP"));             // new
        KillTimer(Update);
    }
    return 1;
}

public OnFilterScriptInit()
{
    printf("\n  [FS] torran's Registration System %s \n", SCRIPT_VERSION);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    format(file, 128, "/tReg/%s.ini", GetName(playerid));

    if(dialogid == DIALOG_REGISTER)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            if(strlen(inputtext) == 0)
            {
                format(str, 128, "Welcome %s \n\nPlease register your account", GetName(playerid));
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Account Management", str, "Register", "Quit");
                return 0;
            }
            if(!dini_Exists(file))
            {
                dini_Create(file);
                dini_IntSet(file, "Password", udb_hash(inputtext));
                dini_IntSet(file, "Money", GetPlayerMoney(playerid));
                dini_IntSet(file, "Score", GetPlayerScore(playerid));
                dini_IntSet(file, "Kills", GetPVarInt(playerid, "Kills"));
                dini_IntSet(file, "Deaths", GetPVarInt(playerid, "Deaths"));
                dini_IntSet(file, "Minutes Ingame", GetPVarInt(playerid, "Time"));
                dini_IntSet(file, "Adminlvl",GetPVarInt(playerid, "Admin"));             // new
                dini_IntSet(file, "VIPlvl",GetPVarInt(playerid, "VIP"));             // new

                format(str, 128, "Account successfully Registered \n\n\nWelcome %s \n\nPlease login to your account", GetName(playerid));
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
            }
        }
    }
    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) return Kick(playerid);
        if(response)
        {
            if(strlen(inputtext) == 0)
            {
                format(str, 128, "Welcome %s \n\nPlease login to your account", GetName(playerid));
                ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
                return 0;
            }
            if(fexist(file))
            {
                new password = dini_Int(file, "Password");
                if(udb_hash(inputtext) != password)
                {
                    if(GetPVarInt(playerid, "Attempts") == 0)
                    {
                        SetPVarInt(playerid, "Attempts", 1);
                        SendClientMessage(playerid, colorRed, "Incorrect password, You have 1 more attempt");

                        format(str, 128, "Welcome %s \n\nPlease login to your account", GetName(playerid));
                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Management", str, "Login", "Quit");
                    }
                    else if(GetPVarInt(playerid, "Attempts") == 1)
                    {
                        SendClientMessage(playerid, colorRed, "Incorrect password, You do not have any attempts left");
                        Kick(playerid);
                    }
                }
                else
                {
                    SetPVarInt(playerid, "Logged", 1);

                    SetPlayerCash(playerid, dini_Int(file, "Money"));
                    SetPlayerScore(playerid, dini_Int(file, "Score"));
                    SetPVarInt(playerid, "Kills", dini_Int(file, "Kills"));
                    SetPVarInt(playerid, "Deaths", dini_Int(file, "Deaths"));
                    SetPVarInt(playerid, "Time", dini_Int(file, "Minutes Ingame"));
                    SetPVarInt(playerid, "Admin", dini_Int(file, "Admin"));             // new
                    SetPVarInt(playerid, "VIP", dini_Int(file, "VIP"));                  // new

                    GetPlayerIp(playerid, playerIP, 16);
                    dini_Set(file, "IP", playerIP);

                    Update = SetTimerEx("UpdateTime", 60*1000, 1, "i", playerid);

                    TogglePlayerSpectating(playerid, 0);

                    SendClientMessage(playerid, colorGreen, "You have successfully logged in.");
                }
            }
        }
    }
    if(dialogid == DIALOG_CHANGEPASS)
    {
        if(response)
        {
            if(GetPVarInt(playerid, "PassStage") == 1)
            {
                new password = dini_Int(file, "Password");
                if(udb_hash(inputtext) == password)
                {
                    SetPVarInt(playerid, "PassStage", 2);
                    ShowPlayerDialog(playerid, DIALOG_CHANGEPASS, DIALOG_STYLE_INPUT, "Account Management", "Please input your new password", "Change Pass", "Cancel");
                }
                else
                {
                    SendClientMessage(playerid, colorRed, "Incorrect password.");
                }
            }
            else if(GetPVarInt(playerid, "PassStage") == 2)
            {
                if(GetPVarInt(playerid, "Logged") == 1)
                {
                    dini_IntSet(file, "Password", udb_hash(inputtext));
                    SendClientMessage(playerid, colorGreen, "Password successfully changed.");
                }
            }
        }
    }

    return 0;
}

public UpdateTime(playerid)
{
    format(file, 128, "/tReg/%s.ini", GetName(playerid));

    SetPVarInt(playerid, "Time", GetPVarInt(playerid, "Time")+1);
    return 1;
}

CMD:changepass(playerid, params[])
{
    if(GetPVarInt(playerid, "Logged") == 1)
    {
        SetPVarInt(playerid, "PassStage", 1);
        ShowPlayerDialog(playerid, DIALOG_CHANGEPASS, DIALOG_STYLE_INPUT, "Account Management", "Please input your current password for verification", "Continue", "Cancel");
    }
    return 1;
}


CMD:viewstats(playerid, params[])
{
    if(GetPVarInt(playerid, "Logged") == 1)
    {
        new Float:health; GetPlayerHealth(playerid, health);
        new Float:armour; GetPlayerArmour(playerid, armour);

        format(str, 128, "Name: %s\nHealth: %0.00f\nArmour: %0.00f\nMoney: %i\nScore: %i\nKills: %i\nDeaths: %i", GetName(playerid), health, armour, GetPlayerMoney(playerid), GetPlayerScore(playerid), GetPVarInt(playerid, "Kills"), GetPVarInt(playerid, "Deaths"));
        ShowPlayerDialog(playerid, DIALOG_VIEWSTATS, DIALOG_STYLE_MSGBOX, "Account Management", str, "Ok", "Cancel");
    }
    return 1;
}

CMD:checkstats(playerid, params[])
{
    new targetid;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, colorRed, "You need to be an RCON Admin to use this command.");
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, colorRed, "Usage: /checkstats [PlayerID/PartOfName]");
    if(targetid == playerid) return SendClientMessage(playerid, colorRed, "You are trying to view the stats of you, To do this type: /viewstats");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, colorRed, "Player not Found");

    if(GetPVarInt(playerid, "Logged") == 1)
    {
        new Float:health; GetPlayerHealth(targetid, health);
        new Float:armour; GetPlayerArmour(targetid, armour);

        format(str, 128, "Name: %s\nHealth: %0.00f\nArmour: %0.00f\nMoney: %i\nScore: %i\nKills: %i\nDeaths: %i", GetName(targetid), health, armour, GetPlayerMoney(targetid), GetPlayerScore(targetid), GetPVarInt(targetid, "Kills"), GetPVarInt(targetid, "Deaths"));
        ShowPlayerDialog(playerid, DIALOG_VIEWSTATS, DIALOG_STYLE_MSGBOX, "Account Management", str, "Ok", "Cancel");
    }
    return 1;
}

stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof name);
    return name;
}

stock SetPlayerCash(playerid, amount)
{
    ResetPlayerMoney(playerid);
    return GivePlayerMoney(playerid, amount);
}

stock sscanf(string[], format[], {Float,_}:...)
{
    #if defined isnull
        if (isnull(string))
    #else
        if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
    #endif
        {
            return format[0];
        }
    #pragma tabsize 4
    new
        formatPos = 0,
        stringPos = 0,
        paramPos = 2,
        paramCount = numargs(),
        delim = ' ';
    while (string[stringPos] && string[stringPos] <= ' ')
    {
        stringPos++;
    }
    while (paramPos < paramCount && string[stringPos])
    {
        switch (format[formatPos++])
        {
            case '\0':
            {
                return 0;
            }
            case 'i', 'd':
            {
                new
                    neg = 1,
                    num = 0,
                    ch = string[stringPos];
                if (ch == '-')
                {
                    neg = -1;
                    ch = string[++stringPos];
                }
                do
                {
                    stringPos++;
                    if ('0' <= ch <= '9')
                    {
                        num = (num * 10) + (ch - '0');
                    }
                    else
                    {
                        return -1;
                    }
                }
                while ((ch = string[stringPos]) > ' ' && ch != delim);
                setarg(paramPos, 0, num * neg);
            }
            case 'h', 'x':
            {
                new
                    num = 0,
                    ch = string[stringPos];
                do
                {
                    stringPos++;
                    switch (ch)
                    {
                        case 'x', 'X':
                        {
                            num = 0;
                            continue;
                        }
                        case '0' .. '9':
                        {
                            num = (num << 4) | (ch - '0');
                        }
                        case 'a' .. 'f':
                        {
                            num = (num << 4) | (ch - ('a' - 10));
                        }
                        case 'A' .. 'F':
                        {
                            num = (num << 4) | (ch - ('A' - 10));
                        }
                        default:
                        {
                            return -1;
                        }
                    }
                }
                while ((ch = string[stringPos]) > ' ' && ch != delim);
                setarg(paramPos, 0, num);
            }
            case 'c':
            {
                setarg(paramPos, 0, string[stringPos++]);
            }
            case 'f':
            {

                new changestr[16], changepos = 0, strpos = stringPos;
                while(changepos < 16 && string[strpos] && string[strpos] != delim)
                {
                    changestr[changepos++] = string[strpos++];
                    }
                changestr[changepos] = '\0';
                setarg(paramPos,0,_:floatstr(changestr));
            }
            case 'p':
            {
                delim = format[formatPos++];
                continue;
            }
            case '\'':
            {
                new
                    end = formatPos - 1,
                    ch;
                while ((ch = format[++end]) && ch != '\'') {}
                if (!ch)
                {
                    return -1;
                }
                format[end] = '\0';
                if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
                {
                    if (format[end + 1])
                    {
                        return -1;
                    }
                    return 0;
                }
                format[end] = '\'';
                stringPos = ch + (end - formatPos);
                formatPos = end + 1;
            }
            case 'u':
            {
                new
                    end = stringPos - 1,
                    id = 0,
                    bool:num = true,
                    ch;
                while ((ch = string[++end]) && ch != delim)
                {
                    if (num)
                    {
                        if ('0' <= ch <= '9')
                        {
                            id = (id * 10) + (ch - '0');
                        }
                        else
                        {
                            num = false;
                        }
                    }
                }
                if (num && IsPlayerConnected(id))
                {
                    setarg(paramPos, 0, id);
                }
                else
                {
                    #if !defined foreach
                        #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
                        #define __SSCANF_FOREACH__
                    #endif
                    string[end] = '\0';
                    num = false;
                    new
                        name[MAX_PLAYER_NAME];
                    id = end - stringPos;
                    foreach (Player, playerid)
                    {
                        GetPlayerName(playerid, name, sizeof (name));
                        if (!strcmp(name, string[stringPos], true, id))
                        {
                            setarg(paramPos, 0, playerid);
                            num = true;
                            break;
                        }
                    }
                    if (!num)
                    {
                        setarg(paramPos, 0, INVALID_PLAYER_ID);
                    }
                    string[end] = ch;
                    #if defined __SSCANF_FOREACH__
                        #undef foreach
                        #undef __SSCANF_FOREACH__
                    #endif
                }
                stringPos = end;
            }
            case 's', 'z':
            {
                new
                    i = 0,
                    ch;
                if (format[formatPos])
                {
                    while ((ch = string[stringPos++]) && ch != delim)
                    {
                        setarg(paramPos, i++, ch);
                    }
                    if (!i)
                    {
                        return -1;
                    }
                }
                else
                {
                    while ((ch = string[stringPos++]))
                    {
                        setarg(paramPos, i++, ch);
                    }
                }
                stringPos--;
                setarg(paramPos, i, '\0');
            }
            default:
            {
                continue;
            }
        }
        while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
        {
            stringPos++;
        }
        while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
        {
            stringPos++;
        }
        paramPos++;
    }
    do
    {
        if ((delim = format[formatPos++]) > ' ')
        {
            if (delim == '\'')
            {
                while ((delim = format[formatPos++]) && delim != '\'') {}
            }
            else if (delim != 'z')
            {
                return delim;
            }
        }
    }
    while (delim > ' ');
    return 0;
}
Can you help me and one member of the forum??
from already thank you very much.

PD: Sorry of my english is badd D: xD but attempt
Reply
#2

Do you have another FS?
Make sure their OnDialogResponse is returned 0 at the end
Reply
#3

I tryed your code and works fine for me if I
pawn Code:
return 1;
OnDialogResponse
Reply
#4

yeapp.. ^^ ends in Return 0; another idea?
Reply
#5

End it in return 1;
Reply
#6

Only return 0 in the end on OnDialogResponse, the other (perhaps) should be 1.
Reply
#7

nop , still not working... would not be better if they tried it, so you see what I mean

ie, the register dialog appears .. but when click on register him, stops working, does not create the file in the folder scriptfiles nor get the dialog of login,

as if it locks the lock but not gta
Reply
#8

no more ideas?? :/
Reply
#9

That dini, that's the problem.
Reply
#10

https://sampforum.blast.hk/showthread.php?tid=273088 - Credits: Kush
Reply
#11

Right dini is stupid annoying!
Reply
#12

Quote:
Originally Posted by Davz*|*Criss
View Post
Right dini is stupid annoying!
Indeed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)