bug with register
#1

Hey guys

i am getting some bugs with this register system..
it is also creating a player stats file in desired path also
but when player reconnects instead of asking to login it is asking to register and account it getting reset

this is my problem

codes:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{


    new plrIP[64];
    if (dialogid == DIALOG_REGISTER) {
        new cMenuString[408];
        cMenuString = "";
        SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
        new PlayerName[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        format(file, sizeof(file), SERVER_USER_FILE, PlayerName);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You're not registered.", "Welcome, Register by inputting a password below.", "Register", "Cancel");
        dini_Create(file);
        new Year, Month, Day;
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "RegisterDate",PlayerInfo[playerid][RegisterDate] = getdate(Day, Month, Year));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel] = 0);
        dini_IntSet(file, "VIPLevel",PlayerInfo[playerid][VIPLevel] = 0);
        dini_IntSet(file, "Money",PlayerInfo[playerid][Cash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][Score] = 0);
        dini_IntSet(file, "Skin",PlayerInfo[playerid][Skin] = 0);
        dini_IntSet(file, "Kills",PlayerInfo[playerid][Kills] = 0);
        dini_IntSet(file, "Deaths",PlayerInfo[playerid][Deaths] = 0);
        dini_IntSet(file, "IP",PlayerInfo[playerid][IP] = GetPlayerIp(playerid, plrIP, 64));
        dini_IntSet(file, "Banned",PlayerInfo[playerid][Banned] = 0);
        dini_IntSet(file, "Seconds",PlayerInfo[playerid][Seconds] = 0);
        dini_IntSet(file, "Minutes",PlayerInfo[playerid][Minutes] = 0);
        dini_IntSet(file, "Hours",PlayerInfo[playerid][Hours] = 0);
        PlayerLogged[playerid] = 1;
        SetPlayerScore(playerid, PlayerInfo[playerid][Score]);

        PlayerLogged[playerid] = 1;
        new qwe[256];
        format(qwe, 255, "acc.ini");
        if(!dini_Exists(qwe) ) {
            dini_Create(qwe);
            dini_IntSet(qwe, "accounts", 0);
        }
        new noa;
        noa = dini_Int(qwe,"accounts");
        dini_IntSet(qwe, "accounts", noa+1);

        format(szString, 128, "{F070F2}[oXS]{40FFFF} You succesfully registered the nickname %s with password %s", PlayerName, inputtext);
        SendClientMessage(playerid, 0x40FFFFFF, szString);
        SendClientMessage(playerid, 0x40FFFFFF, "{F070F2}[oXS]{40FFFF} /Admins For Online Admins, /VIPs For Online Vips");
    }
    if (dialogid == DIALOG_LOGIN) {
        new PlayerName[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        format(file, sizeof(file), SERVER_USER_FILE, PlayerName);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) {
            if (PlayerInfo[playerid][IP] == GetPlayerIp(playerid, plrIP, 64)) {
                PlayerLogged[playerid] = 1;
                PlayerInfo[playerid][RegisterDate] = dini_Int(file, "RegisterDate");
                PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
                PlayerInfo[playerid][VIPLevel] = dini_Int(file, "VIPLevel");
                PlayerInfo[playerid][Cash] = dini_Int(file, "Money");
                PlayerInfo[playerid][Score] = dini_Int(file, "Score");
                PlayerInfo[playerid][Skin] = dini_Int(file, "Skin");
                PlayerInfo[playerid][Kills] = dini_Int(file, "Kills");
                PlayerInfo[playerid][Deaths] = dini_Int(file, "Deaths");
                PlayerInfo[playerid][IP] = dini_Int(file, "IP");
                PlayerInfo[playerid][Banned] = dini_Int(file, "Banned");
                PlayerInfo[playerid][Seconds] = dini_Int(file, "Seconds");
                PlayerInfo[playerid][Minutes] = dini_Int(file, "Minutes");
                PlayerInfo[playerid][Hours] = dini_Int(file, "Hours");
                SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
                GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
                PlayerLogged[playerid] = 1;
                SendClientMessage(playerid, 0x40FFFFFF, "{F070F2}[oXS]{40FFFF} Auto-IP Login.");
                SetTimerEx("NameColor",1000,false,"u",playerid);
                if (PlayerInfo[playerid][Banned] == 1) {
                    SendClientMessage(playerid, 0xFF444499, "{F070F2}[oXS]{FF4444} You are banned, do not evade, you making ur chances to get unbaned lower by ban evading!");
                    Kick(playerid);
                }
            }
            else {
                ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You're registered.", "Welcome, You are registered, Please login.", "Login", "Cancel");
            }
        }
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
            SendClientMessage(playerid, 0xFF444499, "Incorrect Password.");
            wrongpass[playerid] ++;
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You're registered.", "Welcome, You are registered, Please login.", "Login", "Cancel");
            if(wrongpass[playerid] == 3) {
                format(szString, sizeof(szString), "* Your name has been changed to: [oXS]%s for too many invalid passwords.", PlayerName);
                SendClientMessage(playerid, COLOR_RED, szString);
                format(szString, sizeof(szString), "[oXS]%s", PlayerName);
                SetPlayerName(playerid, szString);
                wrongpass[playerid] = 0;
                SendClientMessage(playerid, COLOR_GREEN, "*** Please make a new name when you leave, because you are on a temporary account for too many invalid logins. ***");
                ShowPlayerDialog(playerid, 100, DIALOG_STYLE_MSGBOX, "New Name", "Since you have too many incorrect logins, your name has been changed.\nThis account will not be saved onto the server.", "Okay", "Cancel");
            }
        }
        else
        {
            PlayerLogged[playerid] = 1;
            PlayerInfo[playerid][RegisterDate] = dini_Int(file, "RegisterDate");
            PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][VIPLevel] = dini_Int(file, "VIPLevel");
            PlayerInfo[playerid][Cash] = dini_Int(file, "Money");
            PlayerInfo[playerid][Score] = dini_Int(file, "Score");
            PlayerInfo[playerid][Skin] = dini_Int(file, "Skin");
            PlayerInfo[playerid][Kills] = dini_Int(file, "Kills");
            PlayerInfo[playerid][Deaths] = dini_Int(file, "Deaths");
            PlayerInfo[playerid][IP] = dini_Int(file, "IP");
            PlayerInfo[playerid][Banned] = dini_Int(file, "Banned");
            PlayerInfo[playerid][Seconds] = dini_Int(file, "Seconds");
            PlayerInfo[playerid][Minutes] = dini_Int(file, "Minutes");
            PlayerInfo[playerid][Hours] = dini_Int(file, "Hours");
            SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
            GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
            PlayerLogged[playerid] = 1;

            SendClientMessage(playerid, 0x40FFFFFF, "{F070F2}[oXS]{40FFFF} Successfully logged in!");
            PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
            if (PlayerInfo[playerid][Banned] == 1) {
                SendClientMessage(playerid, 0xFF444499, "{F070F2}[oXS]{FF4444} You are banned, do not evade.");
                Kick(playerid);
            }
        }
}
return 0;
}
pawn Код:
public OnPlayerConnect(playerid)
{

    new PlayerName[MAX_PLAYER_NAME];
    PlayerLogged[playerid] = 0;
    new file[256];
    format(file, sizeof(file), SERVER_USER_FILE, PlayerName);
    if (!dini_Exists(file)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{F070F2}[oXS]{FF0000} You're not registered.", "{FFFFFF}Welcome To The {FF0000}Oblivion Xtreme Stunts{FFFFFF}, Register by creating a password.", "Register", "Cancel");    if(fexist(file)) {
        new plrIP[64];
        GetPlayerIp(playerid, plrIP, 64);
        if (PlayerInfo[playerid][IP] == GetPlayerIp(playerid, plrIP, 64)) {
            PlayerInfo[playerid][RegisterDate] = dini_Int(file, "RegisterDate");
            PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][VIPLevel] = dini_Int(file, "VIPLevel");
            PlayerInfo[playerid][Cash] = dini_Int(file, "Money");
            PlayerInfo[playerid][Score] = dini_Int(file, "Score");
            PlayerInfo[playerid][Skin] = dini_Int(file, "Skin");
            PlayerInfo[playerid][Kills] = dini_Int(file, "Kills");
            PlayerInfo[playerid][Deaths] = dini_Int(file, "Deaths");
            PlayerInfo[playerid][IP] = dini_Int(file, "IP");
            PlayerInfo[playerid][Banned] = dini_Int(file, "Banned");
            PlayerInfo[playerid][Seconds] = dini_Int(file, "Seconds");
            PlayerInfo[playerid][Minutes] = dini_Int(file, "Minutes");
            PlayerInfo[playerid][Hours] = dini_Int(file, "Hours");
            PlayerInfo[playerid][TotalTime] = dini_Int(file, "TotalTime");
            PlayerInfo[playerid][ConnectTime] = dini_Int(file, "ConnectTime");
            PlayerLogged[playerid] = 1;
            GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
            SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
            SendClientMessage(playerid, 0xB1FB44FF, "{F070F2}[oXS]{B1FB44} Auto-IP Login.");

            if (PlayerInfo[playerid][Banned] == 1) {
                SendClientMessage(playerid, 0xFF444499, "{F070F2}[oXS]{FF0000} You are banned, do not evade.");
                Kick(playerid);
            }
        }
        else {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "{F070F2}[oXS]{FF0000} You're registered.", "Welcome, You are registered, Please login.", "Login", "Cancel");
        }
    }

return 1;
}
please help me

thanks in advance
Reply
#2

first of all: GetPlayerIp returns only 0 or 1, so you can't compare IP like this, you have to use strcmp for it
Change this:
pawn Код:
if (PlayerInfo[playerid][IP] == GetPlayerIp(playerid, plrIP, 64))
to this:
pawn Код:
if (!strcmp(PlayerInfo[playerid][IP], plrIP))
Also you forget to use GetPlayerName before formating file string in OnPlayerConnect (don't forget to add GetPlayerIp in OnDialogResponse before comparing player IP)
Reply
#3

Quote:
Originally Posted by Scottas
Посмотреть сообщение
Also you forget to use GetPlayerName before formating file string in OnPlayerConnect (don't forget to add GetPlayerIp in OnDialogResponse before comparing player IP)
i used GetPlayerName in OnPlayerConnect but didn't post everything of my OnPlayerConnect


and other thing....where should i add this GetPlayerIp??
Reply
#4

and maybe you removed something that we should see, and now we are not able to help with it
Reply
#5

Quote:
Originally Posted by Scottas
Посмотреть сообщение
and maybe you removed something that we should see, and now we are not able to help with it
ok ill post everything gimme a min

and i am getting 0 errors and warnings
Reply
#6

pawn Код:
public OnPlayerConnect(playerid)
{

    new PlayerName[MAX_PLAYER_NAME];
    PlayerLogged[playerid] = 0;
    new file[256];
    format(file, sizeof(file), SERVER_USER_FILE, PlayerName);
    if (!dini_Exists(file)) return  ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{F070F2}[oXS]{FF0000} You're not registered.", "{FFFFFF}Welcome To The {FF0000}Oblivion Xtreme Stunts{FFFFFF}, Register by creating a password.", "Register", "Cancel");
    if(fexist(file)) {
        new plrIP[64];
        GetPlayerIp(playerid, plrIP, 64);
        if (!strcmp(PlayerInfo[playerid][IP], plrIP)) {
            PlayerInfo[playerid][RegisterDate] = dini_Int(file, "RegisterDate");
            PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
            PlayerInfo[playerid][VIPLevel] = dini_Int(file, "VIPLevel");
            PlayerInfo[playerid][Cash] = dini_Int(file, "Money");
            PlayerInfo[playerid][Score] = dini_Int(file, "Score");
            PlayerInfo[playerid][Skin] = dini_Int(file, "Skin");
            PlayerInfo[playerid][Kills] = dini_Int(file, "Kills");
            PlayerInfo[playerid][Deaths] = dini_Int(file, "Deaths");
            PlayerInfo[playerid][IP] = dini_Int(file, "IP");
            PlayerInfo[playerid][Banned] = dini_Int(file, "Banned");
            PlayerInfo[playerid][Seconds] = dini_Int(file, "Seconds");
            PlayerInfo[playerid][Minutes] = dini_Int(file, "Minutes");
            PlayerInfo[playerid][Hours] = dini_Int(file, "Hours");
            PlayerInfo[playerid][TotalTime] = dini_Int(file, "TotalTime");
            PlayerInfo[playerid][ConnectTime] = dini_Int(file, "ConnectTime");
            PlayerLogged[playerid] = 1;
            GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
            SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
            SendClientMessage(playerid, 0xB1FB44FF, "{F070F2}[oXS]{B1FB44} Auto-IP Login.");

            if (PlayerInfo[playerid][Banned] == 1) {
                SendClientMessage(playerid, 0xFF444499, "{F070F2}[oXS]{FF0000} You are banned, do not evade.");
                Kick(playerid);
            }
        }
        else {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "{F070F2}[oXS]{FF0000} You're registered.", "Welcome, You are registered, Please login.", "Login", "Cancel");
        }
    }



    SendClientMessage(playerid, COLOR_YELLOW, "{F070F2}[oXS]{FFFF00} Welcome to Oblivion Xtreme, Enjoy your stay! ");

    new pname[MAX_PLAYER_NAME], string[110];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "weapons/%s.ini", pname);
    if (!dini_Exists(file))
    {
        dini_Create(file);
        dini_IntSet(file, "Weapon1",WeaponInfo[playerid][Weapon1] = 0);
        dini_IntSet(file, "Weapon1a",WeaponInfo[playerid][Weapon1a] = 0);
        dini_IntSet(file, "Weapon2",WeaponInfo[playerid][Weapon2] = 0);
        dini_IntSet(file, "Weapon2a",WeaponInfo[playerid][Weapon2a] = 0);
        dini_IntSet(file, "Weapon3",WeaponInfo[playerid][Weapon3] = 0);
        dini_IntSet(file, "Weapon3a",WeaponInfo[playerid][Weapon3a] = 0);
        dini_IntSet(file, "Weapon4",WeaponInfo[playerid][Weapon4] = 0);
        dini_IntSet(file, "Weapon4a",WeaponInfo[playerid][Weapon4a] = 0);
        dini_IntSet(file, "Weapon5",WeaponInfo[playerid][Weapon5] = 0);
        dini_IntSet(file, "Weapon5a",WeaponInfo[playerid][Weapon5a] = 0);
        dini_IntSet(file, "Weapon6",WeaponInfo[playerid][Weapon6] = 0);
        dini_IntSet(file, "Weapon6a",WeaponInfo[playerid][Weapon6a] = 0);
        dini_IntSet(file, "Weapon7",WeaponInfo[playerid][Weapon7] = 0);
        dini_IntSet(file, "Weapon7a",WeaponInfo[playerid][Weapon7a] = 0);
        dini_IntSet(file, "Weapon8",WeaponInfo[playerid][Weapon8] = 0);
        dini_IntSet(file, "Weapon8a",WeaponInfo[playerid][Weapon8a] = 0);
        dini_IntSet(file, "Weapon9",WeaponInfo[playerid][Weapon9] = 0);
        dini_IntSet(file, "Weapon9a",WeaponInfo[playerid][Weapon9a] = 0);
        dini_IntSet(file, "Weapon10",WeaponInfo[playerid][Weapon10] = 0);
        dini_IntSet(file, "Weapon10a",WeaponInfo[playerid][Weapon10a] = 0);
        dini_IntSet(file, "Weapon11",WeaponInfo[playerid][Weapon11] = 0);
        dini_IntSet(file, "Weapon11a",WeaponInfo[playerid][Weapon11a] = 0);
        dini_IntSet(file, "Weapon12",WeaponInfo[playerid][Weapon12] = 0);
        dini_IntSet(file, "Weapon12a",WeaponInfo[playerid][Weapon12a] = 0);
    }
    else
    {
        WeaponInfo[playerid][Weapon1] = dini_Int(file, "Weapon1");
        WeaponInfo[playerid][Weapon1a] = dini_Int(file, "Weapon1a");
        WeaponInfo[playerid][Weapon2] = dini_Int(file, "Weapon2");
        WeaponInfo[playerid][Weapon2a] = dini_Int(file, "Weapon2a");
        WeaponInfo[playerid][Weapon3] = dini_Int(file, "Weapon3");
        WeaponInfo[playerid][Weapon3a] = dini_Int(file, "Weapon3a");
        WeaponInfo[playerid][Weapon4] = dini_Int(file, "Weapon4");
        WeaponInfo[playerid][Weapon4a] = dini_Int(file, "Weapon4a");
        WeaponInfo[playerid][Weapon5] = dini_Int(file, "Weapon5");
        WeaponInfo[playerid][Weapon5a] = dini_Int(file, "Weapon5a");
        WeaponInfo[playerid][Weapon6] = dini_Int(file, "Weapon6");
        WeaponInfo[playerid][Weapon6a] = dini_Int(file, "Weapon6a");
        WeaponInfo[playerid][Weapon7] = dini_Int(file, "Weapon7");
        WeaponInfo[playerid][Weapon7a] = dini_Int(file, "Weapon7a");
        WeaponInfo[playerid][Weapon8] = dini_Int(file, "Weapon8");
        WeaponInfo[playerid][Weapon8a] = dini_Int(file, "Weapon8a");
        WeaponInfo[playerid][Weapon9] = dini_Int(file, "Weapon9");
        WeaponInfo[playerid][Weapon9a] = dini_Int(file, "Weapon9a");
        WeaponInfo[playerid][Weapon10] = dini_Int(file, "Weapon10");
        WeaponInfo[playerid][Weapon10a] = dini_Int(file, "Weapon10a");
        WeaponInfo[playerid][Weapon11] = dini_Int(file, "Weapon11");
        WeaponInfo[playerid][Weapon11a] = dini_Int(file, "Weapon11a");
        WeaponInfo[playerid][Weapon12] = dini_Int(file, "Weapon12");
        WeaponInfo[playerid][Weapon12a] = dini_Int(file, "Weapon12a");
    }
    format(string, sizeof(string), "***%s has joined the server.", pname);
    SendClientMessageToAll(0xAAAAAAAA, string);
    return 1;
}
this is the total thing in the OnPlayerConnect and here is OnPlayerDisconnect

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[256];
    dini_IntSet(file, "RegisterDate", PlayerInfo[playerid][RegisterDate]);
    dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
    dini_IntSet(file, "VIPLevel", PlayerInfo[playerid][VIPLevel]);
    dini_IntSet(file, "Money", GetPlayerMoney(playerid));
    dini_IntSet(file, "Score", GetPlayerScore(playerid));
    dini_IntSet(file, "Skin", GetPlayerSkin(playerid));
    dini_IntSet(file, "Kills", PlayerInfo[playerid][Kills]);
    dini_IntSet(file, "Deaths", PlayerInfo[playerid][Deaths]);
    dini_IntSet(file, "IP", PlayerInfo[playerid][IP]);
    dini_IntSet(file, "Seconds", PlayerInfo[playerid][Seconds]);
    dini_IntSet(file, "Minutes", PlayerInfo[playerid][Minutes]);
    dini_IntSet(file, "Hours", PlayerInfo[playerid][Hours]);
   
   
    KillTimer(paydayTimer);

   
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    switch(reason)
    {
        case 0: format(string, sizeof(string), "***%s has left the server. (Timeout)", pname);
        case 1: format(string, sizeof(string), "***%s has left the server. (Quit)", pname);
        case 2: format(string, sizeof(string), "***%s has left the server. (Kick/Ban)", pname);
    }
    SendClientMessageToAll(0xAAAAAAAA, string);
    printf("Player Disconnected");
    if(PlayerCar[playerid] != -1) DestroyVehicle(PlayerCar[playerid]);
return 1;
}
Reply
#7

But I still can't find GetPlayerName, before filename formating.
pawn Код:
public OnPlayerConnect(playerid)
{

    new PlayerName[MAX_PLAYER_NAME];
    PlayerLogged[playerid] = 0;
    new file[256];
    format(file, sizeof(file), SERVER_USER_FILE, PlayerName);
Should be
pawn Код:
public OnPlayerConnect(playerid)
{

    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    PlayerLogged[playerid] = 0;
    new file[256];
    format(file, sizeof(file), SERVER_USER_FILE, PlayerName);
Reply
#8

and whats about ondialogresponse
where should i add GetPlayerIp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)