login problem
#8

try this

pawn Код:
//Includes
#include <a_samp>
#include <dini>
#include <dudb>

//Pragma unused
#pragma unused strtok
#pragma unused ret_memcpy

#define DIALOG_REGISTER 227 // Define a Dialog for Register
#define DIALOG_LOGIN 225 // Define a Dialog for Login

#define SERVER_USER_FILE "PlayerAccount/%s.ini" // This will save the Player Account when he's Register

new PlayerLogged[MAX_PLAYERS];

enum pInfo // Setup your Variables
{
    pAdmin, //Admin Variables
    pMoney //Money Variables
}
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerRequestClass(playerid, classid)
{
        // You can change this to OnplayerConnect / OnplayerSpawn / OnplayerRequestClass
        new name[MAX_PLAYER_NAME], dfile[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
        if (!dini_Exists(dfile))
        {
            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome {FF0000}Guest! {FFFFFF}- {FFFF00}Register", "{00FF00}Welcome! {FFFFFF}This account isn't {FF0000}registered!\n{FFFFFF}Please input your password to {FF0000}register!", "Register", "Refuse");
        }
        if(fexist(dfile))
        {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
        }
        return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    //here when the player left the server , the Admin/Money will be save !
    new pName[MAX_PLAYER_NAME], dfile[256];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(dfile, sizeof(dfile), SERVER_USER_FILE, pName);
    if(PlayerLogged[playerid] == 1)
    {
        dini_IntSet(dfile, "Admin", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(dfile, "Money", GetPlayerMoney(playerid));
    }
    PlayerLogged[playerid] = 0;
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == DIALOG_REGISTER) // Dialog Register
    {
        new name[MAX_PLAYER_NAME], dfile[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome {FF0000}Guest! {FFFFFF}- {FFFF00}Register", "{00FF00}Welcome! {FFFFFF}This account isn't {FF0000}registered!\n{FFFFFF}Please input your password to {FF0000}register!", "Register", "Refuse");
        dini_Create(dfile);
        dini_IntSet(dfile, "Password", udb_hash(inputtext));
        dini_IntSet(dfile, "Admin", PlayerInfo[playerid][pAdmin]);
        dini_IntSet(dfile, "Money", GetPlayerMoney(playerid));
        format(string, 128, "[SERVER]: You succesfully registered the nickname {00FF00}%s", name);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
    }
    if (dialogid == DIALOG_LOGIN) // Dialog Login
    {
        new name[MAX_PLAYER_NAME], dfile[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(dfile, sizeof(dfile), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return  ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
        new tmp;
        tmp = dini_Int(dfile, "Password");
        if(udb_hash(inputtext) != tmp) {
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome {00FF00}Back! {FFFFFF}- {FFFF00}Login", "{00FF00}Welcome Back! {FFFFFF}This account is {FF0000}{00FF00}registered!\n{FFFFFF}Please input your password to {00FF00}login!", "Login", "Refuse");
        }
        else
        {
            PlayerInfo[playerid][pAdmin] = dini_Int(dfile, "Admin");
            GivePlayerMoney(playerid, dini_Int(dfile, "Cash")-GetPlayerMoney(playerid));
            SpawnPlayer(playerid);
        }
    }
    return 1;
}
a new login/register i made in a few mins to help you
this is more simple and easy

EDIT:Let me try fix your script . .
Reply


Messages In This Thread
login problem - by Youice - 27.07.2012, 01:46
Re: login problem - by Devilxz97 - 27.07.2012, 01:48
Re: login problem - by Youice - 27.07.2012, 01:51
Re: login problem - by Marlon_Lorran - 27.07.2012, 01:54
Re: login problem - by Youice - 27.07.2012, 02:03
Re: login problem - by Marlon_Lorran - 27.07.2012, 02:08
Re: login problem - by Youice - 27.07.2012, 02:10
Re: login problem - by Devilxz97 - 27.07.2012, 02:15
Re: login problem - by Marlon_Lorran - 27.07.2012, 02:20
Re: login problem - by Youice - 27.07.2012, 02:44

Forum Jump:


Users browsing this thread: 3 Guest(s)