dialog based register/login
#1

OK so in my server it ask people to login/register in chat
but i want that when people join the server, it comes in dialog asking people to register.
Here is my /register /login cmd, and when player registers, he gets 3000$ into his account.

pawn Код:
new cmd[256], idx, tmp[256], name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s.czj", name);
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/register", true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /register [PASSWORD]");
        format(file,sizeof(file),"%s.czj", name);
        if(!fexist(file))
        {
            dini_Create(file);
            dini_IntSet(file, "Password", udb_hash(tmp));
            dini_IntSet(file, "Money", 2500);
            dini_IntSet(file, "Score", 1);
            dini_IntSet(file, "Bank", 1000);
            dini_IntSet(file, "RobSkill", 1);
            dini_IntSet(file, "TerSkill", 1);
            dini_IntSet(file, "Admin", 0);
            dini_IntSet(file, "Warnings", 0);
            dini_IntSet(file, "WantedLevel", 0);
            dini_IntSet(file, "Jail", 0);
            dini_IntSet(file, "RentalOwner", 0);
            dini_IntSet(file, "BarOwner", 0);
            dini_IntSet(file, "Drugs", 0);
            dini_IntSet(file, "C4", 0);
            SendClientMessage(playerid, GRAY, "Thanks for registering!");
            SendClientMessage(playerid, GRAY, "You may now login.");
            SendClientMessage(playerid, GRAY, "To do so, type: /login [PASSWORD]");
            GameTextForPlayer(playerid, "~r~Registered!", 3000, 1);
        }
        else SendClientMessage(playerid, ERROR, "This account is already registered in our system. Use: /login [PASSWORD]");
        return true;
    }

    if(strcmp(cmd, "/login", true) == 0)
    {
        new tmp2[256];
        tmp = strtok(cmdtext, idx);
        if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /login [PASSWORD]");
        else
        {
            if(IsPlayerLogged[playerid] == 1) return SendClientMessage(playerid, ERROR, "You are already logged in.");
            else
            {
                if(fexist(file))
                {
                    tmp2 = dini_Get(file, "Password");
                    if(udb_hash(tmp) != strval(tmp2)) return SendClientMessage(playerid, ERROR, "Wrong password.");
                    else
                    {
                        IsPlayerLogged[playerid] = 1;
                        SetPlayerMoney(playerid, dini_Int(file, "Money"));
                        SetPlayerScore(playerid, dini_Int(file, "Score"));
                        SetPlayerWantedLevel(playerid, dini_Int(file, "WantedLevel"));
                        SendClientMessage(playerid, GRAY, "You are now logged in. Your status will be saved on your logout.");
                        GameTextForPlayer(playerid, "~r~Logged In!", 3000, 1);
                    }
                }
                else return SendClientMessage(playerid, ERROR, "This username was not found on our database. Use: /register [PASSWORD]");
            }
        }
        return true;
    }
Please help.
Reply


Messages In This Thread
dialog based register/login - by 0utLaW_ - 07.09.2012, 16:39
Re: dialog based register/login - by 0utLaW_ - 08.09.2012, 06:48
Re: dialog based register/login - by ThePrograme - 08.09.2012, 07:08

Forum Jump:


Users browsing this thread: 1 Guest(s)