Register problem
#1

Hey guys i am making this:

pawn Код:
/*
-------------------------------------*
 Script.             *
-------------------------------------*
*/


#include <a_samp>
//#include <YSI/y_ini>
#include <dini>
#include <ldudb>
#include <zcmd>
#include <sscanf2>

new IsLoggedIn[MAX_PLAYERS];

new file[256];

enum pInfo
{
    pLevel,
    pCash,
    pKills,
    pDeaths,
    pColor,
    pScore,
    pSkin
}
new PlayerInfo[MAX_PLAYERS][pInfo];

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("  Script.");
    print("--------------------------------------\n");
    return 1;
}

#endif

public OnPlayerConnect(playerid)
{
    IsLoggedIn[playerid] = 0;
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "Server/Users/%s.ini", name);
    if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
    }
    if(fexist(file))
    {
       ShowPlayerDialog(playerid, 7407, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
    }
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 2196)
    {
        new name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), "Server/Users/%s.ini", name);
        if(!response) return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Register an account on our Database, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
        if(!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 2196523, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel] = 0);
        dini_IntSet(file, "Cash",PlayerInfo[playerid][pCash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        dini_IntSet(file, "Color",PlayerInfo[playerid][pColor] = 0);
        dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 0);
        format(string, 2134, "Server: You succesfully registered the nickname %s with password %s.. You have been AutoLogged In.", name, inputtext);
        SendClientMessage(playerid, 0x00FF00FF, string);
        IsLoggedIn[playerid] = 1;
    }

if (dialogid == 7407)
    {
      new name[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name, sizeof(name));
      format(file, sizeof(file), "Server/Users/%s.ini", name);
      if(!response) return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Login your account, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
      if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Hi your registered", "You are registred, please login.", "Login", "Leave");
      new tmp;
      tmp = dini_Int(file, "Password");
      if(udb_hash(inputtext) != tmp) {
      SendClientMessage(playerid, 0xFF0000FF, "The Password you entered it feels like wrong, Try again..");
      ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
      }
      else
      {
        IsLoggedIn[playerid] = 1;
        SetPlayerMoney(playerid, dini_Int(file, "pCash"));
        SetPlayerScore(playerid, dini_Int(file, "pScore"));
        SetPlayerColor(playerid, dini_Int(file, "pColor"));
        PlayerInfo[playerid][pLevel] = dini_Int(file, "pLevel");
        SetPlayerSkin(playerid, dini_Int(file, "pSkin"));
        SendClientMessage(playerid,0x00FF00FF, "Server: You have logged in your account!");
    }
    }
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[24];
    GetPlayerName(playerid,name,24);
    format(file,sizeof(file),"Server/Users/%s.ini",name);
    if(dini_Exists(file))
    {
        dini_IntSet(file,"pCash",GetPlayerMoney(playerid));
        dini_IntSet(file,"pScore",GetPlayerScore(playerid));
        dini_IntSet(file,"pColor",GetPlayerColor(playerid));
        dini_IntSet(file,"pLevel",PlayerInfo[playerid][pLevel]);
        dini_IntSet(file,"pSkin",GetPlayerSkin(playerid));
        IsLoggedIn[playerid] = 0;
        return 1;
    }
    return 1;
}


COMMAND:register(playerid, params[])
{
    if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 2196, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
    }
    if(fexist(file))
    {
       ShowPlayerDialog(playerid, 7407, DIALOG_STYLE_INPUT, "Login Account", "Welcome,\n\nYour Account is currently registered in our Database, So if you feel glad to login you may login please.\n\nEnter your Desired Password Below:", "Login", "Later");
    }
    return 1;
}
And when i go ingame there is nothing.

If i type /register i just receive register dialog, i cant register there.

I got Files in my scriptfiles Server/Users/ i got.

Please help me.

thanks
Reply
#2

you need to create the file on your register dialog you clever guy

add
pawn Код:
new File:fo = fopen(file, io_write);
fclose(fo);
above your dini_IntSet
Reply
#3

aha lol.

Like this do you mean?

pawn Код:
if (dialogid == 2196)
    {
        new name[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), "Server/Users/%s.ini", name);
        new File:fo = fopen(file, io_write);
        if(!response) return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Register an account on our Database, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
        if(!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 2196523, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel] = 0);
        dini_IntSet(file, "Cash",PlayerInfo[playerid][pCash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        dini_IntSet(file, "Color",PlayerInfo[playerid][pColor] = 0);
        dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 0);
        fclose(fo);
        format(string, 2134, "Server: You succesfully registered the nickname %s with password %s.. You have been AutoLogged In.", name, inputtext);
        SendClientMessage(playerid, 0x00FF00FF, string);
        IsLoggedIn[playerid] = 1;
    }
Dude it seems that i need to take video.

Otherwise i cant be helped greatly.
Reply
#4

I'm quite sure dini has a function dini_Create(file[]) or something like that. And don't create a file before being entirely sure that the player will register!
pawn Код:
if(!response)
    return SendClientMessage(playerid, 0xFF0000FF, "You skiped to Register an account on our Database, Please Makesure your  Kills/Deaths/Cash/Level/Color and Skin won't be saved.");
if(!strlen(inputtext))
    return ShowPlayerDialog(playerid, 2196523, DIALOG_STYLE_INPUT, "Register Account.", "Welcome,\n\nYour Account is currently not registered in our Database, So if you feel glad to register you may register please.\n\nEnter your Desired Password Below:", "Register", "Later");
new File:fo = fopen(file, io_write);
fclose(fo);
Reply
#5

yeap at the position where andret used it it's right..
@andret: yeap I guess there is such a function however I haven't worked with dini for quite a while so I just use the default way so I don't tell him something wrong
Reply
#6

It does not works

Sascha or Andret would you like to come my server and try to fix it please?

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)