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

You should just make this into a MySQL based account system, then people would LOVE you.
Reply
#22

Here's my not working :

pawn Code:
#define FILTERSCRIPT

#include <a_samp>

#include <dini>
#include <dudb>

#pragma unused ret_memcpy

enum pInfo
{
    pAdminLevel,
    pCash,
    pScore,
}
new PlayerInfo[MAX_PLAYERS][pInfo];

new gPlayerLogged[MAX_PLAYERS];

#define SERVER_USER_FILE "%s.ini"

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print(" Dialog Register System by MiRCea.");
    return 1;
}

#endif

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, your not registered, input your registration password below", "Register", "Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "This name is registered, please put your password below.", "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, "Register", "Welcome, your not registered, input your registration password below", "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, "SERVER: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
        gPlayerLogged[playerid] = 1;
    }
    return 1;
}

if (dialogid == 2)
    {
        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, 2, DIALOG_STYLE_INPUT, "Login", "This name is registered, please put your password below.", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
            SendClientMessage(playerid, 0xFF0000FF, "Wrong Password.");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "This name is registered, please put your password below.", "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, "SERVER: Successfully logged in!");
        }
    }
And the errors:

pawn Code:
C:\Documents and Settings\Home\Рабочий стол\Pawn\pawno\include\dutils.inc(28) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\pawno\include\dutils.inc(132) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\pawno\include\dutils.inc(172) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\pawno\include\dutils.inc(280) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\pawno\include\dutils.inc(298) : warning 219: local variable "tmp" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\pawno\include\dutils.inc(337) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\pawno\include\dutils.inc(379) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\pawno\include\dutils.inc(462) : warning 219: local variable "tmp" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\pawno\include\dini.inc(46) : warning 219: local variable "tmp" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(35) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(35) : warning 219: local variable "file" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(51) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(51) : warning 219: local variable "file" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(68) : warning 219: local variable "name" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(68) : warning 219: local variable "file" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(68) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(86) : error 010: invalid function or declaration
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(89) : error 021: symbol already defined: "GetPlayerName"
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(91) : error 010: invalid function or declaration
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(92) : error 010: invalid function or declaration
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(94) : error 010: invalid function or declaration
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(95) : error 010: invalid function or declaration
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(99) : error 010: invalid function or declaration
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(108) : warning 203: symbol is never used: "file"
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(108) : warning 203: symbol is never used: "name"
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(108) : warning 203: symbol is never used: "string"
C:\Documents and Settings\Home\Рабочий стол\Pawn\filterscripts\DReg.pwn(108) : warning 203: symbol is never used: "tmp"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


7 Errors.
Reply
#23

Nice tut
Reply
#24

nice tutorial tanks
Reply
#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
#26

Thank You
Reply
#27

I don't know why but money doesn't save for me. It saves only $500 which is set in your code to do so and then doesn't save any other amout as a player earns money. Everytime a player logs in gets only $500.
Reply
#28

Quote:
Originally Posted by RealCop228
View Post
@ 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;
}
Wow thanks dude! Fucking helped me!
Reply
#29

Hello,
I would like the player does'nt automatically silk housed by registering.
When it registers, I want the same dialog as when a player connects and it appears already registered.

Thanks
Lowsou
Reply
#30

Quote:
Originally Posted by Lowsou
View Post
Hello,
I would like the player does'nt automatically silk housed by registering.
When it registers, I want the same dialog as when a player connects and it appears already registered.

Thanks
Lowsou
you gotta make a folder inside the scriptfiles for ur accounts
Reply
#31

Hello,
I would like then that when the player register there a new dialog for that he logged.
But the problem is that when the player register he is logged automatically.
But i maked a system, the problem is that when the player register, the dialog for logged appears not.

In OnPlayerConnect

Code:
if(fexist(file))
    {
    	ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, "Welcome!","Your account has benn create!\nentry your password","Connect","Quit");
	}
In OnDialogResponse:

Code:
if (dialogid == 3)
    {
        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, 3, DIALOG_STYLE_INPUT,Welcome!","Your account has benn create!\nentry your password","Connect","Quit");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp)
        {
            SendClientMessage(playerid, COLOR_RED, "Your password is wrong.");
            ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, "Welcome!","Your account has benn create!\nentry your password","Connect","Quit");
        }
        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, "Your are logged");
        }
   	}
Thanks
Lowsou

(Sorry for my languages. I'am french)
Reply
#32

Theres a script released, take a look at it. Please ensure your script files are there too. ^

Edit: This register script has got Automatic login when registered. You can remove that, remove the variable and replace it with the login dialog.
Reply
#33

215) : error 017: undefined symbol "gPlayerLogged"
(215) : warning 215: expression has no effect
(215) : error 001: expected token: ";", but found "]"
(215) : error 029: invalid expression, assumed zero
(215) : fatal error 107: too many error messages on one line
Reply
#34

Hi.
I need a little help.
I already have the dini include in the paste includes but it gives the error
Code:
C:\Users\Andrй\Desktop\SAMP\gamemodes\name.pwn(6) : fatal error 100: cannot read from file: "Dini"
I hope you help me
Btw, good tutorial
Reply
#35

@GoldenM4

pawn Code:
new gPlayerLogged[MAX_PLAYERS];
@FCosta

Download the dini include by dracoblue, use google and search it.
Reply
#36

This tutorial helped me SO much!
Reply
#37

How can i add to this so it saves my pos x y z and r when i log out.
Reply
#38

That might take some time for me to write it down, i might add it to the tutorial aswell..
Reply
#39

Ive been trying to make it be able to save your position and skin, but im not really sure how, could someone help me out?
Reply
#40

Quote:
Originally Posted by Las Venturas CNR
View Post
Maybe you ought to add health and armour saving, a lot of people are asksing for this, lol.
Duplicating areas of code is easy just do that and edit it...

And to rest of the comments, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)