Help me with this(to be read carefully)!!!
#1

I made a login system with dini,following a tutorial on *******:

pawn Код:
#include <dini>

public OnPlayerConnect(playerid)
{
    new String[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(String,sizeof(String),"/Accounts/PlNm.txt",name);
    if(dini_Exists(String))
    {
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Logging in","This account was found in data base,please type in your password to log in.","Login","Cancel");
    }
    else
    {
        ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registration","Type in your password","Register","Cancel");
    }
   new pname[MAX_PLAYER_NAME],string[22+MAX_PLAYER_NAME];
   GetPlayerName(playerid,pname,sizeof(pname));
   format(string,sizeof(string),"%s has joined the server",pname);
   SendClientMessageToAll(COLOR_GREY,string);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
            if(dialogid==DIALOG_LOGIN)
    {
        if(response==0)
        {
            SendClientMessage(playerid,COLOR_RED,"You have been kicked for not loging in.");
            Kick(playerid);
            return 1;
        }
        if(response==1)
        {
            if(!strlen(inputtext))

            {
                SendClientMessage(playerid,COLOR_RED,"This password is too short");
                ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Logging in","This account was found in data base,please type in your password to log in.","Login","Cancel");
                return 1;
            }
            else
            {
                Login(playerid,inputtext);
                return 1;
            }
        }
    }
    if(dialogid==DIALOG_REGISTER)
    {
        if(response==0)
        {
            SendClientMessage(playerid,COLOR_RED,"You have been kicked for not registering in.");
            Kick(playerid);
            return 1;
        }
        if(response==1)
        {
            if(!strlen(inputtext))
            {
                SendClientMessage(playerid,COLOR_RED,"This password is too short");
                ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Registration","Type in your password","Register","Cancel");
                return 1;
            }
            else
            {
                Register(playerid,inputtext);
                return 1;
            }
        }
    }
    return 1;
}

stock Register(playerid,key[])
{
    new String[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(String,sizeof(String),"/Accounts/PlNm.txt",name);
    dini_Create(String);
    dini_Set(String,"Password",key);
    SendClientMessage(playerid,COLOR_GREEN,"Successfully registered");
    dini_IntSet(String,"Level",0);
    GivePlayerMoney(playerid,2000);
    return 1;
}

stock Login(playerid,key[])
{
    new String[64];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(String,sizeof(String),"/Accounts/PlNm.txt",name);
    if(!strcmp(key,dini_Get(String,"Password"),false))
    {
        SetPlayerScore(playerid,dini_Int(String,"Level"));
        SendClientMessage(playerid,COLOR_GREEN,"Successfully logged");
        PlayerPlaySound(playerid,1057,0,0,0);
        GivePlayerMoney(playerid,2000);
        return 1;
    }
    else
    {
        SendClientMessage(playerid,COLOR_RED,"Wrong password.");
        PlayerPlaySound(playerid,1055,0,0,0);
        ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Logging in","This account was found in data base,please type in your password to log in.","Login","Cancel");
        return 1;
    }

}
Now here are the problems(no compiling errors):

1)In-game is working perfectly,there's a single problem,if someone types in a wrong password several times(as he's doing that the class selecton shows up),if he presses spawn he can spawn without logging in.How to make so that if he selects "Spawn",and he is not logged yet he can't spawn.

2)How to make a saving system(saves the score and money of a player,so when he logs in he spawns with the money and his score.

3)You may see somewhere at "stock Login" - GivePlayerMoney(playerid,2000) and I'm not sure if that's right,as I want to set 2000$ as start-in ammount money(every new player that joins will spawn with that start ammount of money)
WARNING!!!EVERY USER OF Y_INI IS ASKED NICELY NOT TO ANSWER THIS TOPIC IF HE CAN'T/NOT TELL ME SWITCH TO Y_INI BECAUSE IT'S EASIER!!!
Reply


Messages In This Thread
Help me with this(to be read carefully)!!! - by Cjgogo - 22.05.2011, 05:36
Re: Help me with this(to be read carefully)!!! - by Cjgogo - 22.05.2011, 07:32
Re: Help me with this(to be read carefully)!!! - by Elka_Blazer - 22.05.2011, 08:12
Re: Help me with this(to be read carefully)!!! - by Cjgogo - 22.05.2011, 08:19
Re: Help me with this(to be read carefully)!!! - by CrazyBlob - 22.05.2011, 09:06
Re: Help me with this(to be read carefully)!!! - by Cjgogo - 22.05.2011, 09:09

Forum Jump:


Users browsing this thread: 1 Guest(s)