[Tutorial] How to make a register system - DIALOG
#25

@ GangsTa[MD]

Okay, I've re-created your script. Please keep in mind I've removed the callbacks and functions that weren't used, or relevant to this system. I usually recommend MySQL, but your going with Dini, which is alright. Please review the attached files, you'll need them to be located in your 'pawno/includes' folder.

pawn Code:
#define FILTERSCRIPT

#include <a_samp>
#include <dini>
#include <dudb>

#pragma unused ret_memcpy

#define COLOR_YELLOW 0xFFFF00
#define COLOR_RED 0xFF0000

#define SERVER_USER_FILE "%s.ini"

enum pInfo
{
    pAdminLevel,
    pCash,
    pScore,
}

new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];

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, "Hello There! You are not registered.", "Please input a password below to create an account...", "Register", "Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hello There! You are registered.", "Please input your password below to login to your account...", "Login", "Leave");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{

    new name[MAX_PLAYER_NAME], file[256];
    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][pAdminLevel]);
    }
    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, "Hello There! You are not registered.", "Please input a password below to create an account...", "Register", "Leave");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
        dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        gPlayerLogged[playerid] = 1;
    }
    else 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, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp)
        {
            SendClientMessage(playerid, COLOR_RED, "Wrong PW sir.");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hello There! You are registered.", "Please input your password below to login to your account...", "Login", "Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
            GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
            SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
        }
    }
    return 1;
}
Reply


Messages In This Thread
How to make a register system - DIALOG - by Lorenc_ - 14.08.2010, 11:15
Re: How to make a register system - DIALOG - by Hiddos - 14.08.2010, 11:22
Re: How to make a register system - DIALOG - by Lorenc_ - 14.08.2010, 11:23
Re: How to make a register system - DIALOG - by Retardedwolf - 14.08.2010, 11:38
Re: How to make a register system - DIALOG - by Mimic - 14.08.2010, 11:41
Re: How to make a register system - DIALOG - by Hor1z0n - 14.08.2010, 12:01
Re: How to make a register system - DIALOG - by Lorenc_ - 14.08.2010, 12:02
Re: How to make a register system - DIALOG - by Lorenc_ - 14.08.2010, 12:14
Re: How to make a register system - DIALOG - by Hor1z0n - 14.08.2010, 12:34
Re: How to make a register system - DIALOG - by Hiddos - 14.08.2010, 12:54
Re: How to make a register system - DIALOG - by Lorenc_ - 15.08.2010, 11:28
Re: How to make a register system - DIALOG - by Hor1z0n - 15.08.2010, 14:32
Re: How to make a register system - DIALOG - by Lorenc_ - 16.08.2010, 11:07
Re: How to make a register system - DIALOG - by Retardedwolf - 16.08.2010, 11:39
Re: How to make a register system - DIALOG - by Hor1z0n - 16.08.2010, 12:28
Re: How to make a register system - DIALOG - by Lorenc_ - 18.08.2010, 10:31
Re: How to make a register system - DIALOG - by Hor1z0n - 18.08.2010, 12:01
Re: How to make a register system - DIALOG - by CSMajor - 20.08.2010, 01:35
Re: How to make a register system - DIALOG - by Shyaam - 20.08.2010, 02:46
Re: How to make a register system - DIALOG - by CSMajor - 20.08.2010, 02:51
Re: How to make a register system - DIALOG - by Scenario - 20.08.2010, 02:56
Re: How to make a register system - DIALOG - by GangsTa_ - 20.08.2010, 06:54
Re: How to make a register system - DIALOG - by Ernis456 - 22.08.2010, 14:15
Respuesta: How to make a register system - DIALOG - by DarkChildren - 22.08.2010, 17:56
Re: How to make a register system - DIALOG - by Scenario - 22.08.2010, 19:08
Re: How to make a register system - DIALOG - by International - 22.08.2010, 20:23
Re: How to make a register system - DIALOG - by bertuspiteri - 22.08.2010, 22:27
Re: How to make a register system - DIALOG - by GangsTa_ - 29.09.2010, 18:38
Re: How to make a register system - DIALOG - by Lowsou - 22.12.2010, 15:29
Re: How to make a register system - DIALOG - by Sledge - 22.12.2010, 19:01
Re: How to make a register system - DIALOG - by Lowsou - 22.12.2010, 20:34
Re: How to make a register system - DIALOG - by Lorenc_ - 23.12.2010, 05:19
Re: How to make a register system - DIALOG - by GoldenM4 - 23.12.2010, 16:44
Re: How to make a register system - DIALOG - by FCosta - 23.12.2010, 18:21
Re: How to make a register system - DIALOG - by Lorenc_ - 25.12.2010, 11:24
Re: How to make a register system - DIALOG - by SkizzoTrick - 25.12.2010, 11:29
Re: How to make a register system - DIALOG - by yarrum3 - 28.12.2010, 01:58
Re: How to make a register system - DIALOG - by Lorenc_ - 28.12.2010, 02:39
Re: How to make a register system - DIALOG - by phatlaced - 03.01.2011, 10:44
Re: How to make a register system - DIALOG - by Lorenc_ - 06.01.2011, 09:08
Re: How to make a register system - DIALOG - by Tee - 08.01.2011, 07:13
Re: How to make a register system - DIALOG - by Outcast - 08.01.2011, 20:55
Re: How to make a register system - DIALOG - by Tee - 09.01.2011, 00:33
Re: How to make a register system - DIALOG - by Lorenc_ - 09.01.2011, 01:05
Re: How to make a register system - DIALOG - by Tee - 09.01.2011, 02:10
Re: How to make a register system - DIALOG - by Kasis - 10.01.2011, 03:09
Re: How to make a register system - DIALOG - by Lorenc_ - 10.01.2011, 03:26
Re: How to make a register system - DIALOG - by Kasis - 10.01.2011, 03:36
Re: How to make a register system - DIALOG - by LiamM - 16.01.2011, 20:58
Re: How to make a register system - DIALOG - by Janek17 - 19.01.2011, 22:41
Re: How to make a register system - DIALOG - by Alex.Cone - 26.02.2011, 20:48
Re: How to make a register system - DIALOG - by destroyern1 - 30.05.2011, 20:29
Re: How to make a register system - DIALOG - by Lorenc_ - 11.06.2011, 05:27
Re: How to make a register system - DIALOG - by StrawHat - 11.06.2011, 05:30
Re: How to make a register system - DIALOG - by StrawHat - 11.06.2011, 06:12
Re: How to make a register system - DIALOG - by Mean - 11.06.2011, 07:43
Re: How to make a register system - DIALOG - by Lorenc_ - 12.06.2011, 06:51
Re: How to make a register system - DIALOG - by zouyun - 12.06.2011, 23:31
Re: How to make a register system - DIALOG - by Lorenc_ - 13.06.2011, 02:12
Re: How to make a register system - DIALOG - by SpiderWalk - 13.06.2011, 09:29
Re: How to make a register system - DIALOG - by Kaperstone - 18.06.2011, 06:35
Re: How to make a register system - DIALOG - by Lorenc_ - 18.06.2011, 11:01
Re: How to make a register system - DIALOG - by Remba031 - 20.06.2011, 12:15
Re: How to make a register system - DIALOG - by Glorian - 30.06.2011, 19:57
Re: How to make a register system - DIALOG - by Revolutionary Roleplay - 30.06.2011, 20:05
Re: How to make a register system - DIALOG - by Glorian - 30.06.2011, 21:02
Re: How to make a register system - DIALOG - by romanzi - 15.07.2011, 07:06
Re: How to make a register system - DIALOG - by Kush - 15.07.2011, 07:09
Re: How to make a register system - DIALOG - by romanzi - 15.07.2011, 08:05
Re: How to make a register system - DIALOG - by Lorenc_ - 16.07.2011, 07:20
Re: How to make a register system - DIALOG - by Cody9611 - 17.07.2011, 13:37
Re: How to make a register system - DIALOG - by Lorenc_ - 19.07.2011, 06:55
Re: How to make a register system - DIALOG - by Davz*|*Criss - 03.08.2011, 17:00
Re: How to make a register system - DIALOG - by Shockey HD - 03.08.2011, 18:05
Re : How to make a register system - DIALOG - by Alvin007 - 29.10.2011, 20:33
Re: How to make a register system - DIALOG - by Lorenc_ - 29.10.2011, 20:51
Re: How to make a register system - DIALOG - by noder51 - 31.10.2011, 19:14
Re: How to make a register system - DIALOG - by Prumpuz - 31.10.2011, 20:57
Re: How to make a register system - DIALOG - by Langley - 01.11.2011, 22:37
Re: How to make a register system - DIALOG - by Lorenc_ - 03.11.2011, 06:11

Forum Jump:


Users browsing this thread: 2 Guest(s)